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

Can't run cargo test ---offline with optional dependency #93512

Closed
maximecb opened this issue Jan 31, 2022 · 1 comment
Closed

Can't run cargo test ---offline with optional dependency #93512

maximecb opened this issue Jan 31, 2022 · 1 comment

Comments

@maximecb
Copy link

maximecb commented Jan 31, 2022

We have a situation where we'd really like for our Rust project to be able to build completely offline without accessing crates.io. We'd also like to be able to run cargo test --offline in our GitHub CI workflows. Unfortunately, this doesn't work. We have one single dependency on the capstone library which is clearly marked as optional, and even with the --offline flag, we get this error:

Run cargo test --offline
error: no matching package named `capstone` found
location searched: registry `crates-io`
required by package `yjit v0.1.0 (/home/runner/work/ruby/ruby/yjit)`
As a reminder, you're using offline mode (--offline) which can sometimes cause surprising resolution failures, if this error is too confusing you may wish to retry without the offline flag.

IMO this is clearly a bug. It violates user intuition as to how the --offline switch should behave. The error message even recommends just... Not using the offline switch because it might be too confusing (!?). Well, you're right, it is confusing. The dependency is optional, and we haven't enabled the feature requiring it. Therefore there should be no need to fetch said dependency. It really should be that simple.

I also tried

  • Removing Cargo.lock (doesn't help)
  • cargo test --locked --offline (doesn't help)

Linking the Cargo.toml file for the project in case someone can spot something wrong with our setup: https://github.com/Shopify/ruby/blob/70fee18c9947ab50b93ec0018f0d6cf4c6c2772f/yjit/Cargo.toml

@maximecb
Copy link
Author

Opened an issue on the cargo repository instead: rust-lang/cargo#10352

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

1 participant