rust - Consolidating cargo dependencies -


i have project has dependency (a cookie utility) has dependency on iron >= 0.3, <= 0.4.

my project has dependency on iron 0.3 (so can use router middleware hasn't yet been updated latest iron).

when try compile project, cookie utility pulls 0.4 version of iron, , errors since different versions of iron being used.

however, can do:

cargo update -p <cookie utility> 

which (usually) changes package's dependency on iron match 1 using, , removes extraneous dependency on iron 0.4. (bizarrely, have run command couple of times before updates.)

apparently can't specify dependency version of dependency: set specific version of dependency of project's dependency in cargo.toml or cargo.lock.

it nice if cargo guess want use single version of iron, understand why can't. however, i'm confused why cargo update -p <package> works; seems non-intuitive update dependency package.


i guess first real question is: how can specify dependency versions of dependencies (when , when version want within supported version range of library)? don't think solutions suggested in question linked above ideal. feel better if cargo support well, libraries leave dependency version ranges open functionality allows.

at same time, found "trick" seems want (cargo update -p <pkg>). haven't looked super hard, behavior doesn't seem described in obvious place. second question is: valid way coalesce dependencies? there place can find more information this?


and steps reproduce:

  1. create new project: cargo new --bin ironapp; cd ironapp.
  2. create cookie dependency: cargo new cookie_util.
  3. in cookie_util/cargo.toml add 1 dependency: iron = ">= 0.3, <= 0.4".
  4. in cargo.toml add 2 dependencies: iron = "0.3.0" , cookie_util = { path = "cookie_util"}.
  5. cargo build. confirm 2 versions of iron required in cargo.lock.
  6. run cargo update -p cookie_util anywhere between 1 , 4 (or more) times. remove dependency on iron 0.4.0.

i tested on rustc-1.10.0/cargo-0.11.0. made sure target , cargo.lock both absent @ start of step 1.

reading through comments of cargo/issues/2064, realized more robust way of resolving these types of dependencies use --precise flag. example,

cargo update -p iron:0.4.0 --precise 0.3.0 

removes unnecessary dependency. requires 1 dig cargo.lock , manually determine dependencies can converge, far better running cargo update -p <pkg> , hoping best, or manually editing cargo.lock.


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -