Skip to content

Instantly share code, notes, and snippets.

@fabiotatsuo
Last active February 24, 2024 02:05
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save fabiotatsuo/e88b025baf3dfa47683419948723706f to your computer and use it in GitHub Desktop.
Save fabiotatsuo/e88b025baf3dfa47683419948723706f to your computer and use it in GitHub Desktop.
Install Rust, Cargo and Rustup Toolchain inside FreeBSD 12 Jail
  1. Install rust

    jail-app is name of jail.

    $ jexec jail-app
    $ pkg install curl
    

    Download and install rustup
    $ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

    root@jail-app:~ # curl https://sh.rustup.rs -sSf | sh
    info: downloading installer
    
    Welcome to Rust!
    
    This will download and install the official compiler for the Rust programming
    language, and its package manager, Cargo.
    
    It will add the cargo, rustc, rustup and other commands to Cargo's bin
    directory, located at:
    
      /root/.cargo/bin
    
    This path will then be added to your PATH environment variable by modifying the
    profile file located at:
    
      /root/.profile
    
    You can uninstall at any time with rustup self uninstall and these changes will
    be reverted.
    
    Current installation options:
    
       default host triple: x86_64-unknown-freebsd
         default toolchain: stable
      modify PATH variable: yes
    
    1) Proceed with installation (default)
    2) Customize installation
    3) Cancel installation
    >1
    
    info: installing component 'cargo'
    info: default toolchain set to 'stable'
    
      stable installed - rustc 1.37.0 (eae3437df 2019-08-13)
    
    
    Rust is installed now. Great!
    
    To get started you need Cargo's bin directory ($HOME/.cargo/bin) in your PATH
    environment variable. Next time you log in this will be done automatically.
    
    To configure your current shell run source $HOME/.cargo/env
    
  2. Set path $HOME/.cargo/bin

    $ vim /home/jail/jail-app/.cshrc
    set path = (/sbin /bin /usr/sbin /usr/bin /usr/local/sbin /usr/local/bin $HOME/bin $HOME/.cargo/bin)
    

    Reload
    $ source .cshrc

    Check version and default

    $ rustc --version
    rustc 1.37.0 (eae3437df 2019-08-13)
    
    $ rustup default
    stable (default)
    

    Rustup folder

    $ jexec jail-app
    $ cd /home/.rustup
    

    Install other versions

    $ rustup install nightly
    $ rustup install stable
    $ rustup install 1.7
    

    Test new install

    $ rustup run nightly rustc --version
    rustc 1.39.0-nightly (521d78407 2019-08-25)
    

    List Rust toolchains and Show active
    $ rustup show

    Uninstall
    $ rustup toolchain uninstall nightly

    Full uninstall
    $ rustup self uninstall

    Update
    $ rustup update

    Cargo nightly

    $ cargo +nightly build
    $ cargo +nightly run
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment