How to find rust compiler version used by cargo. is it same as rustc --version
If you don't override how Cargo builds your project, i.e. by changing the [build]
section of your Cargo configuration or using or adding a toolchain override shorthand if you're using rustup to your Cargo invocation, like cargo +nightly ...
, Cargo will use the rustc
program to build your project, which means that yes, the version of rustc
Cargo uses will be equivalent to rustc --version
.
thanks! but is there a way to check rustc version used by cargo . I mean something like cargo rustc --version
Yes, your command is almost correct, but you need an additional --
before --version
:
cargo rustc -- --version
invokes the rustc
binary Cargo uses and passes the --version
flag to it. (Depending on your package, you might need to further restrict which target should be build by passing an additional argument like --lib
or --bin <binary_name>
to Cargo, like cargo rustc --lib -- --version
for example.)
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.