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

ring linking errors #32

Closed
Boscop opened this issue Jan 7, 2018 · 17 comments
Closed

ring linking errors #32

Boscop opened this issue Jan 7, 2018 · 17 comments

Comments

@Boscop
Copy link

Boscop commented Jan 7, 2018

The rocket master contains a fix that allows not setting SameSite on a cookie at all, which I need.
But I also depend on this crate.
But this crate depends on rocket 0.3.3 which depends on a different version of the ring crate than rocket master, which gives linking errors. So it will only work if this crate is updated to also depend on rocket master so both depend on the same version of the ring crate.

@lawliet89
Copy link
Owner

The crate does not depend specifically on Rocket 0.3.3 -- in fact I do not even have a Cargo.lock checked in as per usual library practices. It depends on all 0.3.x.

Anyway neither this crate nor Rocket depend on ring directly. You can add these lines to your Cargo.toml to use the same workaround as Rocket does.

@lawliet89 lawliet89 changed the title Please update rocket dependency to master ring linking errors Jan 8, 2018
@Boscop
Copy link
Author

Boscop commented Jan 9, 2018

The problem is, this crate depends on rocket 0.3 but rocket master is 0.4.0-dev, so I get this error:

error: Multiple packages link to native library `ring-asm`. A native library can be linked only once.

Package `ring v0.11.0`
    ... which is depended on by `cookie v0.9.1`
    ... which is depended on by `rocket v0.3.5`
    ... which is depended on by `rocket_cors v0.2.1`
    ... which is depended on by `webserver v0.1.0 (file:///D:/docs/foo/foo-server/server)`
    ... which is depended on by `foo-server v0.1.0 (file:///D:/docs/foo/foo-server)`
links to native library `ring-asm`.

Package `ring v0.12.1`
    ... which is depended on by `cookie v0.11.0-dev (https://github.com/alexcrichton/cookie-rs?rev=a15b37a#a15b37af)`
    ... which is depended on by `webserver v0.1.0 (file:///D:/docs/foo/foo-server/server)`
    ... which is depended on by `foo-server v0.1.0 (file:///D:/docs/foo/foo-server)`
also links to native library `ring-asm`.

How can I fix this? :)

@Boscop
Copy link
Author

Boscop commented Jan 9, 2018

I bumped up the rocket version in a fork for now: https://github.com/Boscop/rocket_cors

@lawliet89
Copy link
Owner

lawliet89 commented Jan 10, 2018

Another way to fix this is to simply replace the Rocket dependency to point to Rocket's master branch in your own crate:

[patch.crates-io]
rocket = { git = "https://github.com/SergioBenitez/Rocket", version = "0.4.0-dev" }

I don't intend to update the master branch to point to an unreleased version of Rocket at the moment.

@Boscop
Copy link
Author

Boscop commented Jan 10, 2018

I don't intend to update the master branch to point to an unreleased version of Rocket at the moment.

I didn't mean to suggest you to do that..

But I like the patch solution more, I tried to do it:

[patch.crates-io]
ring = { git = "https://github.com/SergioBenitez/ring", branch = "v0.12" }
rocket = { git = "https://github.com/SergioBenitez/Rocket", version = "0.4.0-dev" }

(the ring patch was from before, to make it work)
But now I get the same error again:

error: multiple packages link to native library `ring-asm`, but a native library can be linked only once

package `ring v0.12.2 (https://github.com/SergioBenitez/ring?branch=v0.12#9ccfa153)`
    ... which is depended on by `cookie v0.11.0-dev (https://github.com/alexcrichton/cookie-rs?rev=a15b37a#a15b37af)`
    ... which is depended on by `rocket v0.4.0-dev (https://github.com/SergioBenitez/Rocket#9bf33bdd)`
    ... which is depended on by `rocket_contrib v0.4.0-dev (https://github.com/SergioBenitez/Rocket#9bf33bdd)`
    ... which is depended on by `webserver v0.1.0 (file:///D:/docs/foo/foo-server/server)`
    ... which is depended on by `foo-server v0.1.0 (file:///D:/docs/foo/foo-server)`
links to native library `ring-asm`

package `ring v0.11.0`
    ... which is depended on by `cookie v0.9.2`
    ... which is depended on by `rocket v0.3.5`
    ... which is depended on by `rocket_cors v0.2.1`
    ... which is depended on by `webserver v0.1.0 (file:///D:/docs/foo/foo-server/server)`
    ... which is depended on by `foo-server v0.1.0 (file:///D:/docs/foo/foo-server)`
also links to native library `ring-asm`

Why does it use the ring patch but not the one for rocket?

Btw, in the rest of my Cargo.toml I have:

rocket = { git = "https://github.com/SergioBenitez/Rocket", version = "0.4.0-dev" }
rocket_codegen = { git = "https://github.com/SergioBenitez/Rocket", version = "0.4.0-dev" }
rocket_contrib = { git = "https://github.com/SergioBenitez/Rocket", version = "0.4.0-dev" }

@lawliet89
Copy link
Owner

Looks like you need to do the same for Cookie. Might just be better off using your forked version if you have to do this for every other dependency.

@Boscop
Copy link
Author

Boscop commented Jan 11, 2018

But how to do this for cookie? Am I not doing it globally for ALL crates that depend on rocket?

@Boscop
Copy link
Author

Boscop commented Jan 11, 2018

11:04 <Sergio> You can only patch within semver compatible versions

Seems like there is no way to patch it, so I have to keep using my fork..

@lawliet89
Copy link
Owner

lawliet89 commented Jan 11, 2018 via email

@lawliet89
Copy link
Owner

@Boscop There is a PR in ring that will hopefully prevent this issue in the future.

I'll keep this open to keep an eye on that PR and I'll update accordingly when rocket also upgrades.

@lawliet89
Copy link
Owner

Rocket 0.4 now requires ring 0.13.

@incker
Copy link

incker commented Dec 3, 2018

My Cargo.toml

[package]
name = "rocket2"
version = "0.1.0"
authors = ["incker"]
edition = "2018"

[dependencies]
rocket = "0.4.0-rc.2"

[dependencies.rocket_contrib]
version = "*"
default-features = false
features = ["handlebars_templates", "tera_templates"]

Error that I see:

error: multiple packages link to native library `ring-asm`, but a native library can be linked only once

package `ring v0.13.5`
    ... which is depended on by `cookie v0.11.0`
    ... which is depended on by `rocket_http v0.4.0-rc.2`
    ... which is depended on by `rocket v0.4.0-rc.2`
    ... which is depended on by `rocket2 v0.1.0 (C:\rust\rocket2)`
links to native library `ring-asm`

package `ring v0.11.0`
    ... which is depended on by `cookie v0.9.2`
    ... which is depended on by `rocket v0.3.17`
    ... which is depended on by `rocket_contrib v0.3.17`
    ... which is depended on by `rocket2 v0.1.0 (C:\rust\rocket2)`
also links to native library `ring-asm`

What I did wrong?

@lawliet89
Copy link
Owner

@incker: I haven't updated the crate to support Rocket 0.4.0.rc.2.

Fixed in #53.

New release: https://github.com/lawliet89/rocket_cors/releases/tag/v0.4.0-rc.3

@incker
Copy link

incker commented Dec 4, 2018

@incker: I haven't updated the crate to support Rocket 0.4.0.rc.2.

Fixed in #53.

New release: https://github.com/lawliet89/rocket_cors/releases/tag/v0.4.0-rc.3

I am not sure, what exactly have helped me, but this code works for me:

[package]
name = "rocket2"
version = "0.1.0"
authors = ["incker"]
edition = "2018"

[dependencies]
rocket = "0.4.0-rc.2"
rocket_cors = { git = "https://github.com/lawliet89/rocket_cors", branch = "master" }

[dependencies.rocket_contrib]
version = "0.4.0-rc.2"
default-features = false
features = ["handlebars_templates", "tera_templates"]

maybe version of dependencies.rocket_contrib was also needed

Thank you

@incker
Copy link

incker commented Dec 4, 2018

Maybe it is already not that topic to write,
but now I have same problem when I added line rocket_static_fs = "*" to Cargo.toml

@lawliet89
Copy link
Owner

rocket_cors = "0.4.0-rc.3"

would be sufficient.

Like the earlier comments in the issue, anything that depends directly or transitively on ring needs to be on the same version. There's not much I can do about it for you.

@lawliet89
Copy link
Owner

I am closing this issue for now. The version of Ring supported by this crate will track that of Rocket's.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants