pchampin / sophia_rs

Sophia: a Rust toolkit for RDF and Linked Data
Other
228 stars 24 forks source link

Build error: "two different versions of crate `oxiri` are being used?" #111

Closed nwagner84 closed 2 years ago

nwagner84 commented 2 years ago

Hi,

I've problems building a project, which depends on sophia and sophia_api. It's no longer possible to build the project, because of the following build error:

[...]
   Compiling sophia_iri v0.7.1
   Compiling sophia_api v0.7.1
   Compiling sophia_term v0.7.1
   Compiling sophia_rio v0.7.1
   Compiling sophia_indexed v0.7.1
   Compiling sophia_inmem v0.7.1
   Compiling sophia_turtle v0.7.1
error[E0308]: mismatched types
  --> /home/nico/.cargo/registry/src/github.com-1ecc6299db9ec823/sophia_turtle-0.7.1/src/parser/gtrig.rs:20:64
   |
20 |         GeneralizedRioSource::Parser(RioGTriGParser::new(data, base))
   |                                                                ^^^^ expected struct `oxiri::Iri`, found a different struct `oxiri::Iri`
   |
   = note: expected enum `Option<oxiri::Iri<String>>` (struct `oxiri::Iri`)
              found enum `Option<oxiri::Iri<String>>` (struct `oxiri::Iri`)
   = note: perhaps two different versions of crate `oxiri` are being used?

error[E0308]: mismatched types
  --> /home/nico/.cargo/registry/src/github.com-1ecc6299db9ec823/sophia_turtle-0.7.1/src/parser/trig.rs:20:58
   |
20 |         StrictRioSource::Parser(RioTriGParser::new(data, base))
   |                                                          ^^^^ expected struct `oxiri::Iri`, found a different struct `oxiri::Iri`
   |
   = note: expected enum `Option<oxiri::Iri<String>>` (struct `oxiri::Iri`)
              found enum `Option<oxiri::Iri<String>>` (struct `oxiri::Iri`)
   = note: perhaps two different versions of crate `oxiri` are being used?

error[E0308]: mismatched types
  --> /home/nico/.cargo/registry/src/github.com-1ecc6299db9ec823/sophia_turtle-0.7.1/src/parser/turtle.rs:23:60
   |
23 |         StrictRioSource::Parser(RioTurtleParser::new(data, base))
   |                                                            ^^^^ expected struct `oxiri::Iri`, found a different struct `oxiri::Iri`
   |
   = note: expected enum `Option<oxiri::Iri<String>>` (struct `oxiri::Iri`)
              found enum `Option<oxiri::Iri<String>>` (struct `oxiri::Iri`)
   = note: perhaps two different versions of crate `oxiri` are being used?

For more information about this error, try `rustc --explain E0308`.
error: could not compile `sophia_turtle` due to 3 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile `pica v0.9.1 (https://github.com/deutsche-nationalbibliothek/pica-rs?branch=count-command#5d8535fd)`, intermediate artifacts can be found at `/tmp/cargo-installHnUwiE`

Caused by:
  build failed

My Cargo.toml looks like:

[dependencies]
atty = "0.2"
bstr = "0.2"
clap = { version = "3.0", features = ["cargo"] }
clap_complete = "3.0"
csv = "1.1"
directories = "4.0"
flate2 = "1.0"
nom = "7.1"
rand = "0.8"
regex = "1.5"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
sophia = "0.7"
sophia_api = "0.7"
strsim = "0.10"
termcolor = "1.1"
toml = "0.5"
xml-rs = "0.8"

I guess the problem is related due to new versions of the oxiri crate (0.2.0 and 0.2.1); I tried to fix this issue by setting the version of oxiri explicitly to "=0.1.1". You can find a complete error log here: https://github.com/deutsche-nationalbibliothek/pica-rs/runs/4850074708

Do you have an idea what goes wrong here?

pchampin commented 2 years ago

I can reproduce the problem: a fresh clone of sophia_rs does not build :-(

I believe the problem comes from rio_xml and rio_turtle. Their version 0.6.1 depend on oxiri ^0.1, while their version 0.6.2 depends on oxiri >=0.1, <0.3.

Now, consider sophia_turtle: it depends on rio_turtle ^0.6.1 and oxiri ^0.1.1. This makes rio_turtle 0.6.2 a good candidate, for which oxiri 0.2.1 is a good candidate. However, rio_turtle itself can not use oxiri 0.2.1, and is stuck with 0.1.1 . And so they can't properly communicate with each other.

I was able to fix the problem with:

cargo update -p oxiri:0.2.1 --precise 0.1.1

but maybe I should release 0.7.2 depending on oxiri 0.2.1...

pinging @Tpt as you might be interested in this side effect -- maybe worth reconsidering your policy re. versioning and dependencies...

Tpt commented 2 years ago

pinging @Tpt as you might be interested in this side effect -- maybe worth reconsidering your policy re. versioning and dependencies...

Yes, it seems I got tricked by cargo dependency resolver. I though that just extending a version range would not break builds because the resolver would stay with oxiri 0.1 if it is required elsewhere. But it does not seems to be the case, sorry.

nwagner84 commented 2 years ago

@pchampin Thanks for the detailed explanation. A new release which depends on oxiri 0.2.1 would be great!

nwagner84 commented 2 years ago

@pchampin Do you have a plan, when a new release will be available. Unfortunately, I'm blocked unless this bug is fixed.

Many thanks in advance.

pchampin commented 2 years ago

Doesn't the cargo update trick above solve your problem?

nwagner84 commented 2 years ago

Some of my collegues doing code reviews and they install the crate with cargo install --git ... and then this trick doesn't work. I found a temporary solution: I removed the RDF/SKOS component; this was already planned. I'm going to re-implement this component in a new crate.

pchampin commented 2 years ago

Ok, sorry about that. I'll hurry in publishing 0.7.2. with the dependencies fixed, then.

pchampin commented 2 years ago

should be fixed now