Cargo: Panic in cargo::version

Created on 12 Mar 2017  路  6Comments  路  Source: rust-lang/cargo

Using the newest nightly cargo. I can't get the version because --version panics. Rustup installed it along with rustc 1.17.0-nightly (e4eb964dd 2017-03-11).

$ RUST_BACKTRACE=1 cargo --version
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /checkout/src/libcore/option.rs:323
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: cargo::version
             at /checkout/src/libcore/macros.rs:21
             at /checkout/cargo/src/cargo/lib.rs:263
   1: cargo::execute
             at /checkout/cargo/src/bin/cargo.rs:156
   2: cargo::call_main_without_stdin
             at /checkout/cargo/src/cargo/lib.rs:128
   3: cargo::main
             at /checkout/cargo/src/bin/cargo.rs:91
             at /checkout/cargo/src/bin/cargo.rs:84

It affects other commands as well:

$ RUST_BACKTRACE=1 cargo update
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /checkout/src/libcore/option.rs:323
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: cargo::version
             at /checkout/src/libcore/macros.rs:21
             at /checkout/cargo/src/cargo/lib.rs:263
   1: cargo::ops::registry::http_handle
             at /checkout/cargo/src/cargo/ops/registry.rs:227
   2: <cargo::sources::registry::remote::RemoteRegistry<'cfg> as cargo::sources::registry::RegistryData>::update_index
             at /checkout/cargo/src/cargo/sources/registry/remote.rs:63
   3: cargo::sources::registry::RegistrySource::do_update
             at /checkout/cargo/src/cargo/sources/registry/mod.rs:309
   4: <cargo::sources::registry::RegistrySource<'cfg> as cargo::core::source::Source>::update
             at /checkout/cargo/src/cargo/sources/registry/mod.rs:353
   5: cargo::core::registry::PackageRegistry::ensure_loaded
             at /checkout/cargo/src/cargo/core/registry.rs:191
             at /checkout/cargo/src/cargo/util/errors.rs:58
             at /checkout/cargo/src/cargo/core/registry.rs:180
             at /checkout/cargo/src/cargo/core/registry.rs:141
   6: <cargo::core::registry::PackageRegistry<'cfg> as cargo::core::registry::Registry>::query
             at /checkout/cargo/src/cargo/core/registry.rs:339
   7: <&'a mut I as core::iter::iterator::Iterator>::next
             at /checkout/cargo/src/cargo/core/resolver/mod.rs:859
             at /checkout/cargo/src/cargo/core/resolver/mod.rs:832
             at /checkout/src/libcore/ops.rs:2654
             at /checkout/src/libcore/option.rs:383
             at /checkout/src/libcore/iter/mod.rs:999
             at /checkout/src/libcore/result.rs:1087
             at /checkout/src/libcore/iter/iterator.rs:2197
   8: cargo::core::resolver::activate
             at /checkout/src/libcollections/vec.rs:1649
             at /checkout/src/libcollections/vec.rs:1562
             at /checkout/src/libcore/result.rs:1104
             at /checkout/src/libcore/iter/iterator.rs:1221
             at /checkout/cargo/src/cargo/core/resolver/mod.rs:831
             at /checkout/cargo/src/cargo/core/resolver/mod.rs:340
   9: cargo::core::resolver::activate_deps_loop
             at /checkout/cargo/src/cargo/core/resolver/mod.rs:457
  10: cargo::core::resolver::resolve
             at /checkout/cargo/src/cargo/core/resolver/mod.rs:280
  11: cargo::ops::resolve::resolve_with_previous
             at /checkout/cargo/src/cargo/ops/resolve.rs:225
  12: cargo::ops::cargo_generate_lockfile::update_lockfile
             at /checkout/cargo/src/cargo/ops/cargo_generate_lockfile.rs:77
  13: cargo::try_execute_builtin_command
             at /checkout/cargo/src/bin/update.rs:77
             at /checkout/cargo/src/cargo/lib.rs:128
             at /checkout/cargo/src/bin/cargo.rs:259
  14: cargo::execute
             at /checkout/cargo/src/bin/cargo.rs:223
  15: cargo::call_main_without_stdin
             at /checkout/cargo/src/cargo/lib.rs:128
  16: cargo::main
             at /checkout/cargo/src/bin/cargo.rs:91
             at /checkout/cargo/src/bin/cargo.rs:84

Most helpful comment

@ruuda we in fact have these tests and run them in rust-lang/rust. We just don't run the test suite for the right Cargo, and that's tracked by https://github.com/rust-lang/rust/issues/38531.

Just trying to point out that we're not trying to be negligent here, the interactions are all very tricky.

All 6 comments

I've started fixing this in https://github.com/rust-lang/cargo/pull/3820, next step is to land the submodule update in rust-lang/rust

This bug has quite some impact, because Travis CI runs cargo --version and cargo build/test --verbose by default, so all builds that use the nightly channel were broken. While #3820 fixes the cause in this case, that is no guarantee that things aren鈥檛 going to break in the future. Would it be possible to add a dry-run check to the test suite? Something as simple as the shell script below, which should exit with a 0 exit code, would have caught this, right?

set -e
cargo --version
cargo new foo
cd $_
cargo build --verbose
cargo test --verbose

@ruuda we in fact have these tests and run them in rust-lang/rust. We just don't run the test suite for the right Cargo, and that's tracked by https://github.com/rust-lang/rust/issues/38531.

Just trying to point out that we're not trying to be negligent here, the interactions are all very tricky.

(oops didn't mean to close yet)

Looks like the same issue is happening again: #3844.

Was this page helpful?
0 / 5 - 0 ratings