Is it possible to have multiple coexisting Rust installations?

后端 未结 6 1036
爱一瞬间的悲伤
爱一瞬间的悲伤 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条回答
  •  北海茫月
    2020-12-10 16:30

    Usually when dealing with rustup, you're dealing with toolchains–a single installation of the Rust compiler. There are 3 major release channels:

    • stable
    • beta
    • nightly

    The channel can be appended with optional date and host names: channel[-date][-host].

    You can install multiple toolchains using rustup:

    rustup toolchain install nightly
    rustup toolchain install stable-x86_64-pc-windows-msvc
    

    Be careful when nightly is installed as any updates using rustup update will also update stable.

    You can have different level of overrides:

    # command level
    rustc +beta 
    cargo +beta 
    
    # environment level
    export RUSTUP_TOOLCHAIN=nightly-2019-05-22
    
    # directory level
    rustup override set stable
    

    The toolchain configuration can also be version controlled using a rust-toolchain file, which contains just the toolchain name.

    $ cat rust-toolchain
    nightly-2019-05-22
    

    No host name can be configured in the rust-toolchain file.

    The override precedence is:

    • An explicit toolchain, e.g. cargo +beta
    • The RUSTUP_TOOLCHAIN environment variable
    • A directory override, ala rustup override set beta
    • The rust-toolchain file
    • The default toolchain

    Reference: https://github.com/rust-lang/rustup.rs#toolchain-specification

提交回复
热议问题