-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 build ---offline
with optional dependency
#10352
Comments
I think this is still due to lockfile generation that was mentioned after #5655 (comment)
|
Can you elaborate on how this should be used? Just I'll go try this and report back, but either way, the error message should probably be changed, and the behavior of |
This argument seems not supported for cargo 1.58.0 ?
It's also not seemingly a supported argument for
I did some googling and some browsing through the issue you linked and am still not sure how to use |
The flags in that issue refer to unstable features which would only be available to a nightly cargo. While |
I'm new to the Rust community. What's the best way to proceed here? Are you affiliated with the Rust project? Do you agree that there is in fact a problem with the way the |
I am a user of cargo trying to connect the dots here as well, rather than a member of the team.
Rather than an issue I agree expanding on the error message could help; perhaps something like, "use
When asked in #5133 (comment), more design work and time for the team was needed. It has been a couple years since then so the situation could have changed. Let's wait to hear back from the team. |
Yea, that error message is unfortunately confusing. It sounds like you are trying to run The error message definitely could be improved here. If it tries to do resolution without an index in offline mode, then it should say that more clearly. And possibly add a recommendation to run |
Thank you for the response @ehuss. Good idea to improve the error message and make it more self-explanatory. What does running |
|
What are the likely bad outcomes of checking this into git, possibly as last-step procedure when preparing a release? The motivation here is to use Rust in a system that requires the ability to build offline, so if the alternative is to commit some dependency-management artifacts then it might be worth enduring a slightly confusing development-time experience for people who start from a tarball of source. |
I believe they're talking about It's not a part of one's specific project repo, but the global metadata store for things that exist on the package repositories you're configured to depend on. EDIT: It's also over a gigabyte in size. |
Problem
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 runcargo test --offline
in our GitHub CI workflows. Unfortunately, this doesn't work. We have one single dependency on thecapstone
library which is clearly marked as optional, and even with the--offline
flag, we get this error: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, which is basically telling the user "maybe just don't use this feature, because it's cryptic, and doesn't actually do what you want".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.
Steps
Cargo.toml
file with an optional dependency which is only used by an optional feature.cargo build --offline
Linking the
Cargo.toml
file for our project in case someone can spot something wrong with our setup: https://github.com/Shopify/ruby/blob/70fee18c9947ab50b93ec0018f0d6cf4c6c2772f/yjit/Cargo.tomlPossible Solution(s)
Optional dependencies should not be fetched when features requiring them are not enabled. This should be true in general, but especially when the
--offline
switch is passed.Notes
I also tried:
Cargo.lock
(doesn't help)cargo test --locked --offline
(doesn't help)cargo test --frozen --offline
(doesn't help)Version
The text was updated successfully, but these errors were encountered: