emk / heroku-buildpack-rust

A buildpack for Rust applications on Heroku, with full support for Rustup, cargo and build caching.
522 stars 186 forks source link

Build failing on Heroku #30

Closed Floppy closed 6 years ago

Floppy commented 6 years ago

I'm getting odd build errors using this buildpack on Heroku:

-----> Rust app detected
-----> Checking for new releases of Rust 1.25.0 channel
/app/tmp/buildpacks/2203aab785e02c47ff95174d7e631633e83fa90010efce9a5d8ac8a35661280d39a58ff430859981c23547da7ff13b84a22749dc31aa7bcc3283c9678757b447/bin/compile: line 98: rustup: command not found
 !     Push rejected, failed to compile Rust app.
 !     Push failed

I've run the test script with the same repository locally with docker, and it works fine. I've also tried deploying the test app, and that seems OK apart from the issue I filed; it gets further than this though.

I'm at a bit of a dead end working out why this is happening. Any ideas?

emk commented 6 years ago

Hmm, it might be:

  1. A stale build cache on Heroku that you'll need to flush.
  2. Some kind of change in how rustup works, maybe?

If we rule out (1), then it might be worth adding some ls statements to bin/compile, to make sure that all the following directories still exist, and that they contain what we expect:

# Record our Rust build environment configuration in an export file, in
# 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"
# 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

I think RUSTUP_HOME is probably obsolete as of 1.25.0 (or maybe another version in the last several releases), because rustup has moved into .cargo:

> which rustup
/home/emk/.cargo/bin/rustup

But at the same time, we probably don't want to break support for, say, Rust 1.17.0 or whatever, in case people are still using it.

There's really no easy way to debug the weirder problems other than forking the build pack and pushing it with some extra debug statements until we discover something weird and unexpected. :-( I can check it periodically and try to answer questions, but I can't tackle this myself before the middle of next week.

Floppy commented 6 years ago

I did wonder about the build cache, after reading the code. I'll work out how to clear that first, then investigate further if that doesn't work.

Floppy commented 6 years ago

Hah, that's resolved it! Thanks! Not something I've ever had to do before (or knew was even a thing), but it's done the trick.

For future searchers, I cleared the build cache by following these instructions: https://help.heroku.com/18PI5RSY/how-do-i-clear-the-build-cache