Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build script fails to resolve syntex::Registry #202

Closed
jimmycuadra opened this issue Jan 7, 2016 · 14 comments
Closed

Build script fails to resolve syntex::Registry #202

jimmycuadra opened this issue Jan 7, 2016 · 14 comments

Comments

@jimmycuadra
Copy link
Contributor

This started happening in a crate that uses Serde with code generation.

  • Stable Rust 1.5
  • serde_codegen 0.6.7
  • syntex 0.24.0 (0.25.0 exhibits the same behavior)

Output from cargo build

   Compiling serde_codegen v0.6.7
/Users/user/.cargo/registry/src/github.aaakk.us.kg-88ac128001ac3a9a/serde_codegen-0.6.7/build.rs:12:33: 12:46 error: mismatched types:
 expected `&mut syntex::Registry`,
    found `&mut inner::syntex::Registry`
(expected struct `syntex::Registry`,
    found struct `inner::syntex::Registry`) [E0308]
/Users/user/.cargo/registry/src/github.aaakk.us.kg-88ac128001ac3a9a/serde_codegen-0.6.7/build.rs:12         quasi_codegen::register(&mut registry);
                                                                                                                             ^~~~~~~~~~~~~
/Users/user/.cargo/registry/src/github.aaakk.us.kg-88ac128001ac3a9a/serde_codegen-0.6.7/build.rs:12:33: 12:46 help: run `rustc --explain E0308` to see a detailed explanation
error: aborting due to previous error
Could not compile `serde_codegen`.
@jimmycuadra
Copy link
Contributor Author

Apparently this is happening due to rust-lang/cargo#2064.

@JohnHeitmann
Copy link
Contributor

As a workaround you can lock quasi to 0.3.11, aster to 0.9.2, syntex to 0.24.0, and syntex_syntax to 0.24.0.

I think the problem here might be a bit simpler than that cargo bug. I think here it's just breaking API changes that weren't versioned perfectly.

@erickt
Copy link
Member

erickt commented Jan 8, 2016

@JohnHeitmann: I did do a release yesterday which should have fixed this issue on stable rust. nightly rust support is currently broken due to rust-lang/rust#30713.

I was thinking about this issue yesterday, and yeah, I think I did make a semver violation here. While I didn't have to modify any quasi code when I updated it to 0.3.12, I did do a major change on a public dependency. Along with rust-lang/cargo#2064, this means I ended up with two instances of syntex, which caused this confusing error message. I'll be more careful next time.

@codyps
Copy link
Contributor

codyps commented Jan 12, 2016

I'm still seeing this today (2 different versions of syntex), but might be related to another cargo issue: rust-lang/cargo#2277

Edit: for me the following worked:

cargo update -p aster --precise 0.9.3
cargo update -p quasi --precise 0.3.12
# probably due to something pulling in a too new version, cargo responds to this by removing it
cargo update -p syntex:0.26.0 --precise 0.25.0
# after the former command, this one now functions:
cargo update -p syntex --precise 0.25.0

# This notably fails to run, but doesn't seem to matter
cargo update -p syntex_syntax --precise 0.25.0

The last command outputs the very strange:

% cargo update -p syntex_syntax --precise 0.25.0
    Updating registry `https://github.com/rust-lang/crates.io-index`
no matching package named `syntex` found (required by `my_project`)
location searched: registry https://github.com/rust-lang/crates.io-index
version required: = 0.25.0
% cargo -V
cargo 0.8.0-nightly (08da2f5 2015-12-21)

Unclear how this can be the case, as 'my_project' uses a bare wildcard ("*") to specify the syntex version. Might be (another) cargo bug.

@erickt
Copy link
Member

erickt commented Jan 16, 2016

This should be fixed now. Please reopen if you still have problems.

@erickt erickt closed this as completed Jan 16, 2016
@jimmycuadra
Copy link
Contributor Author

This is happening to me on nightly now, not sure if it's the same issue or not:

/Users/user/.cargo/registry/src/github.aaakk.us.kg-88ac128001ac3a9a/quasi_macros-0.4.0/src/lib.rs:19:29: 19:32 error: mismatched types:
 expected `&mut syntex::Registry`,
    found `&mut rustc_plugin::registry::Registry<'_>`
(expected struct `syntex::Registry`,
    found struct `rustc_plugin::registry::Registry`) [E0308]
/Users/user/.cargo/registry/src/github.aaakk.us.kg-88ac128001ac3a9a/quasi_macros-0.4.0/src/lib.rs:19     quasi_codegen::register(reg);
                                                                                                                          ^~~
/Users/user/.cargo/registry/src/github.aaakk.us.kg-88ac128001ac3a9a/quasi_macros-0.4.0/src/lib.rs:19:29: 19:32 help: run `rustc --explain E0308` to see a detailed explanation
error: aborting due to previous error
Build failed, waiting for other jobs to finish...
Could not compile `quasi_macros`.

In Cargo.toml:

[dependencies]
serde = "0.6.11"
serde_json = "0.6.0"
serde_macros = "0.6.11"
$ rustc -V
rustc 1.8.0-nightly (9a07087bc 2016-01-30)

@jimmycuadra
Copy link
Contributor Author

Disregard that last comment. I discovered the issue: I was depending on a crate that uses Serde but only supported building Rust stable/serde_codegen. Modifying that dependency to build on both stable and nightly did the trick. I'm not totally clear why, but it seems that if syntex is added to the build at all, quasi_macros will choke.

@jimmycuadra
Copy link
Contributor Author

Can this be reopened? I'm having the same issue again: failing to build on nightly because a dependency somehow introduced syntex (and so far I'm not spotting how to get rid of it.) Seems like this is a problem more people might run into and perhaps there's a way to deal with it at the library level.

Edit: Like the previous time I reported it, the error shows the problem as being in quasi_macros, not serde_codegen like in my original report.

@erickt erickt reopened this Feb 11, 2016
@erickt
Copy link
Member

erickt commented Feb 11, 2016

@jimmycuadra: Any chance you could push up your work somewhere in a branch so I could look into it?

@jimmycuadra
Copy link
Contributor Author

It's already public, actually! The main project is https://github.com/rusoto/rusoto. Check out the feature-rust-codegen branch. You'll also need https://github.com/rusoto/botocore_parser checked out to a sibling directory (there's a path dependency.) Thanks for reopening.

@indiv0
Copy link

indiv0 commented Feb 27, 2016

I'm getting this too. Is there a way to work around this?

@SkylerLipthay
Copy link
Contributor

Is there actually anything that can be done to solve this? This seems like a very unfortunately cargo edge case. I'm stuck in syntex hell because my project's dependencies use serde_codegen instead of serde_macros. 😭

@Manicqin
Copy link

Happens to me too :(
Is the textnonce's commit suppose to fix the problem?

@dtolnay
Copy link
Member

dtolnay commented Jun 13, 2016

Check out this forum topic for how to fix this permanently by using serde_codegen::expand. It is supported as of Serde 0.7.9.

@dtolnay dtolnay closed this as completed Jun 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

8 participants