Is it possible to have multiple coexisting Rust installations?

后端 未结 6 1055
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-10 15:58

Would it be possible to have a nightly build Rust compiler for convenience (faster build cycle, auto-update) and a dev version of Rust cloned from GitHub for experimentation

6条回答
  •  Happy的楠姐
    2020-12-10 16:47

    The current solution is to use rustup. Once installed, you can install multiple toolchains:

    rustup install nightly
    rustup install stable
    rustup install 1.7
    

    If you have a local build of Rust, you can link it as a toolchain

    rustup toolchain link my-development /path/to/rust/code
    

    You can pick a default toolchain

    rustup default stable
    

    Or add an override toolchain for a specific directory on your machine only via rustup

    cd /my/cool/project
    rustup override set nightly
    

    Or add an override toolchain that lives with a specific directory, like a repository, via a rust-toolchain file

    cd /my/cool/project
    echo "nightly" > rust-toolchain
    

    If you want to just use a different toolchain temporarily, you can use the "plus syntax":

    rustc +1.7 --help
    cargo +nightly build
    

    In other cases you can use rustup run to run any arbitrary command in a specific toolchain:

    rustup run nightly any command you want here 
    

    See also:

    • How to execute cargo test using the nightly channel?

提交回复
热议问题