Live data from Hacker News

Cargo: predictable dependency management

blog.rust-lang.org

31–40 of 146 posts

Re: Cargo: predictable dependency management

#31
post #25

How does Cargo manage the case when dependencies X and Y both require a different version of dependency Z?

It attempts to unify them if it can, but if they cannot be unified, it will include both versions.

Include both how? Make renamed copies to have two and modify the code to use the new names?

Re: Cargo: predictable dependency management

#33

I like many things about Rust, but Cargo alone is what initially got me started with it. I was in the process of setting up a fresh C++ project with vendored dependencies, and it was just an absolute nightmare. In contrast, it took me about 5 minutes to get a Rust project set up with comparable dependency complexity.

[deleted]

Re: Cargo: predictable dependency management

#34

I like many things about Rust, but Cargo alone is what initially got me started with it. I was in the process of setting up a fresh C++ project with vendored dependencies, and it was just an absolute nightmare. In contrast, it took me about 5 minutes to get a Rust project set up with comparable dependency complexity.

I understand that old languages like C++ or Java have problems providing a single package manager. It seems that newer languages have roughly equivalent services.

Are there any big differences between Cargo and Python/Go/D/Ruby/Javascript/etc?

Re: Cargo: predictable dependency management

#35
post #32

I see there is `cargo install` which will fetch and build an executable from crates.io, is there no `cargo update` for `install`?

https://github.com/rust-lang/cargo/pull/2405 landed, but https://github.com/rust-lang/cargo/issues/2082 is similar too and is still open.

Re: Cargo: predictable dependency management

#36
post #34

I like many things about Rust, but Cargo alone is what initially got me started with it. I was in the process of setting up a fresh C++ project with vendored dependencies, and it was just an absolute nightmare. In contrast, it took me about 5 minutes to get a Rust project set up with comparable dependency complexity.

I understand that old languages like C++ or Java have problems providing a single package manager. It seems that newer languages have roughly equivalent services. Are there any big differences between Cargo and Python/Go/D/Ruby/Javascript/etc?

It depends on how you define "big". Cargo is closest to Bundler + rubygems, but with some aspects of npm.

Re: Cargo: predictable dependency management

#37
post #31

Earlier quoted context omitted.

It attempts to unify them if it can, but if they cannot be unified, it will include both versions.

Include both how? Make renamed copies to have two and modify the code to use the new names?

It doesn't have to do any renaming or modifying of names. Rust has a module system, so each dependency will use the version they need.

The only time it doesn't Just Work is if one of those crates re-exports a type from the sub-crate in a public manner, and then you try to call something from the other crate with a value of that type. You'll get a compile-time error about mismatched types.

Re: Cargo: predictable dependency management

#38
post #31

Earlier quoted context omitted.

Include both how? Make renamed copies to have two and modify the code to use the new names?

It doesn't have to do any renaming or modifying of names. Rust has a module system, so each dependency will use the version they need. The only time it doesn't Just Work is if one of those crates re-exports a type from the sub-crate in a public manner, and then you try to call something from the other crate with a value of that type. You'll get a compile-time error about mismatched types.

But it sounds like that's what's going on. Using foo-1.1 in bar.rs and foo-2.2 in rabbit.rs.

Re: Cargo: predictable dependency management

#39
post #32

I see there is `cargo install` which will fetch and build an executable from crates.io, is there no `cargo update` for `install`?

https://github.com/rust-lang/cargo/pull/2405 landed, but https://github.com/rust-lang/cargo/issues/2082 is similar too and is still open.

Interesting, but I was thinking more of something like "update installed binaries with latest version from index". This doesn't look like it.

Re: Cargo: predictable dependency management

#40
post #39

Earlier quoted context omitted.

https://github.com/rust-lang/cargo/pull/2405 landed, but https://github.com/rust-lang/cargo/issues/2082 is similar too and is still open.

Interesting, but I was thinking more of something like "update installed binaries with latest version from index". This doesn't look like it.

Ah yeah, it's per-thing, not every thing you've installed, currently. cargo install --list does list all the things you've installed, so it wouldn't be too big of a deal to add; the pieces are all there.
Post reply on HN