Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ RUST_WITHOUT=rust-docs,rust-other-component asdf install rust 1.51.0
export RUST_WITHOUT=rust-docs
```

Also, the Standalone installers do not install source code, which may cause problems in some development environments. If you need the source code, please use the environment variable `RUST_SOURCE` to perform an additional installation.

```sh
RUST_SOURCE=1 asdf install rust 1.51.0
```

## License

Licensed under the
Expand Down
13 changes: 13 additions & 0 deletions bin/install
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ install_rust() {
esac

local download_url="https://static.rust-lang.org/dist/rust-${version}-${architecture}-${platform}.tar.gz"
local download_src_url="https://static.rust-lang.org/dist/rustc-${version}-src.tar.xz"
local tmp_download_dir
tmp_download_dir=$(mktemp -d -t rust_tmp_XXXXXX)
local source_path="${tmp_download_dir}/rust.tar.gz"
local source_src_path="${tmp_download_dir}/rust-src.tar.gz"
local distination_path="${tmp_download_dir}/dist"

(
Expand All @@ -60,6 +62,17 @@ install_rust() {
cd "$distination_path"
./install.sh "$configure_options" || fail "Could not install"

if [ "${RUST_SOURCE}" ]; then
echo "RUST_SOURCE is set, download and install source code..."
echo "∗ Downloading Source Code..."
curl --silent --location --create-dirs --output "$source_src_path" "$download_src_url" || fail "Could not download rust source code $version"

echo "∗ Installing Source Code..."
local rustlib_src_path="$install_path/lib/rustlib/src/rust"
mkdir -p "$rustlib_src_path"
tar zxf "$source_src_path" -C "$rustlib_src_path" --strip-components=1 || fail "Could not uncompress source code"
fi

rm -rf "$tmp_download_dir"

echo "The installation was successful!"
Expand Down
Loading