When Installing Rust Toolchain in Docker, Bash 'Source' Command Doesn't Work

When installing Rust toolchain in Docker, Bash `source` command doesn't work

You have to add the sourcing inside the .bashrc.

This works:

FROM ubuntu:16.04

# Update default packages
RUN apt-get update

# Get Ubuntu packages
RUN apt-get install -y \
build-essential \
curl

# Update new packages
RUN apt-get update

# Get Rust
RUN curl https://sh.rustup.rs -sSf | bash -s -- -y

RUN echo 'source $HOME/.cargo/env' >> $HOME/.bashrc

EDIT

Instead of

RUN echo 'source $HOME/.cargo/env' >> $HOME/.bashrc

you can use

ENV PATH="/root/.cargo/bin:${PATH}"

which is a less bash-only solution

Rust incremental build not working in vscode devcontainer

Got correct answer on Github Issues

Problem was because of enabled VirtioFS on macOS 12.2

  • works w/o extra configuration if VirtioFS disabled in docker settings on macOS 12.2 (but very slow)
  • also works with VirtioFS enabled on macOS 12.4

Error in pip install transformers: Building wheel for tokenizers (pyproject.toml): finished with status 'error'

The logs say

error: can't find Rust compiler

You need to install a rust compiler. See https://www.rust-lang.org/tools/install. You can modify the installation instructions for a docker image like this (from https://stackoverflow.com/a/58169817/5666087):

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"

How to install Cargo, Rust package manager on Databricks

rustup-init 1.22.1 (76644d669 2020-07-08)
The installer for rustup

USAGE:
rustup-init [FLAGS] [OPTIONS]

FLAGS:
-v, --verbose Enable verbose output
-q, --quiet Disable progress output
-y Disable confirmation prompt.
--no-modify-path Don't configure the PATH environment variable
-h, --help Prints help information
-V, --version Prints version information

OPTIONS:
--default-host <default-host> Choose a default host triple
--default-toolchain <default-toolchain> Choose a default toolchain to install
--default-toolchain none Do not install any toolchains
--profile [minimal|default|complete] Choose a profile
-c, --component <components>... Component name to also install
-t, --target <targets>... Target name to also install

you can use -y to Disable confirmation prompt.

like this

curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf > rustup.sh
sh rustup.sh -y
sudo bash -c "echo source $HOME/.cargo/env >> /etc/bash.bashrc"

Unable to compile Rust hello world on Windows: linker link.exe not found

I downloaded and installed the Build Tools for Visual Studio 2019. During installation I selected the C++ tools. It downloaded almost 5GB of data. I restarted the machine after installation and compiling the code worked fine:

> cargo run
Compiling helloworld v0.1.0 (C:\Users\DELL\helloworld)
Finished dev [unoptimized + debuginfo] target(s) in 12.05s
Running `target\debug\helloworld.exe`
Hello, world!


Related Topics



Leave a reply



Submit