Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix check for existing install of rustup #38

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
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
47 changes: 31 additions & 16 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ if [ -z ${VERSION+x} ]; then
exit 1
fi


# Notify users running old, unstable versions of Rust about how to deploy
# successfully.
if [ $RUST_SKIP_BUILD -ne 1 ] && ( [ ! -z ${CARGO_URL+x} ] || [ ! -f "$BUILD_DIR/$BUILD_PATH/Cargo.toml" ] ); then
Expand All @@ -60,7 +61,6 @@ To deploy a modern Rust app, make sure you have a Cargo.toml file, and that
you do not define CARGO_URL or CARGO_VERSION in RustConfig. If you're
using an older version of Rust, and you need to re-deploy an existing
application, try setting your buildpack to:

https://github.com/emk/heroku-buildpack-rust.git#old-rust
EOF
exit 1
Expand All @@ -77,16 +77,30 @@ EOF
fi

# Record our Rust build environment configuration in an export file, in
cat <<EOF > $BP_DIR/export
# Our rustup installation.
export RUSTUP_HOME="$CACHE_DIR/multirust"
# Our cargo installation. We implicitly trust Rustup and Cargo
# to do the right thing when new versions are released.
export CARGO_HOME="$CACHE_DIR/cargo"
# Include binaries installed by cargo and rustup in our path.
PATH="\$CARGO_HOME/bin:\$PATH"
EOF

# Read our build environment back in and evaluate it so that we can use it.
. $BP_DIR/export
# case another buildpack needs it to build Ruby gems that use Rust or
# something like that.
cat <<EOF > $BP_DIR/export

# Our rustup installation.
export RUSTUP_HOME="$CACHE_DIR/multirust"

cat <<EOF > $BP_DIR/export
# Our rustup installation.
export RUSTUP_HOME="$CACHE_DIR/multirust"
# Our cargo installation. We implicitly trust Rustup and Cargo
# to do the right thing when new versions are released.
export CARGO_HOME="$CACHE_DIR/cargo"

# Include binaries installed by cargo and rustup in our path.
PATH="\$CARGO_HOME/bin:\$PATH"
EOF
Expand All @@ -98,21 +112,22 @@ EOF
mkdir -p "$CACHE_DIR"
cd "$CACHE_DIR"

# Make sure we have an appropriate Rust toolchain installed.
if [ -d "$CARGO_HOME" ]; then
echo "-----> Checking for new releases of Rust $VERSION channel"
# It's possible that $VERSION has changed, or the `stable` channel has updated.
rustup self update
rustup update "$VERSION"
rustup default "$VERSION"
if which rustup; then
echo "-----> Checking for new releases of Rust $VERSION channel"
# It's possible that $VERSION has changed, or the `stable` channel has updated.
rustup self update
rustup update "$VERSION"
rustup default "$VERSION"
else
echo "-----> Downloading rustup"
curl https://sh.rustup.rs -sSf > rustup.sh
chmod u+x rustup.sh
echo "-----> Using rustup to install Rust channel $VERSION"
./rustup.sh -y --default-toolchain "$VERSION"
rm rustup.sh
# Make sure we have an appropriate Rust toolchain installed.
echo "-----> Downloading rustup"
curl https://sh.rustup.rs -sSf > rustup.sh
chmod u+x rustup.sh
echo "-----> Using rustup to install Rust channel $VERSION"
./rustup.sh -y --default-toolchain "$VERSION"
rm rustup.sh
fi

if [ ! -x "$CARGO_HOME/bin/rustc" ]; then
echo "failed: Cannot find Rust binaries at $CARGO_HOME"
exit 1
Expand Down