heroku-buildpack-rust
heroku-buildpack-rust copied to clipboard
Cannot find diesel during Heroku release step
Hi, I think I have followed all the steps to run Diesel migrations on release with Heroku correctly but I keep getting this error in Heroku deploys:
/bin/sh: 1: ./target/release/diesel: not found
It seems the step which is supposed to install the diesel-cli
does not seem to run. These are my RustConfig
and Procfile
:
VERSION=nightly
RUST_INSTALL_DIESEL=1
release: ./target/release/diesel migration run
Is there something I missed in the setup?
After trying more, if I set the buildpack to the current GitHub repo with heroku buildpacks:set https://github.com/emk/heroku-buildpack-rust
the setup above seems to work fine. Presumably this means the buildpack version in the Heroku registry does not contain the diesel-cli setup? In that case it may help to indicate that in the documentation here - although I'm not sure if that is the cause.
There's documentation here on setting the build pack correctly: https://github.com/emk/heroku-buildpack-rust#using-this-buildpack
Is this insufficient? I'd be happy to fix the instructions if we can figure out what's going wrong here!
I had the same issue. I ran the first build without RUST_INSTALL_DIESEL
set to 1. Then the ./target/release/diesel
executable wasn't available even after I fixed the RustConfig
. My workaround was to use heroku buildpacks:set https://github.com/emk/heroku-buildpack-rust
with DIESEL_FLAGS="--force --no-default-features --features postgres"
set in RustConfig
.
I read the documentation you are referring to but it didn't help me.
@emk I followed the directions in the README but also had an issue with the first build. I had RUST_INSTALL_DIESEL=1
but diesel_cli was not installed. Then I ran heroku buildpacks:set https://github.com/emk/heroku-buildpack-rust
and it built correctly the next time
I ran into the same issue.
Switching from emk/rust
to https://github.com/emk/heroku-buildpack-rust
appears to have moved me on but now I have the following issue
remote: error: linking with `cc` failed: exit code: 1
remote: |
remote: = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m64" "-L" "/app/tmp/cache/multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "/app/tmp/cache/target/release/deps/diesel-f7e83459b409f10a.diesel.2cm30g51-cgu.0.rcgu.o" "/app/tmp/cache/target/release/deps/diesel-f7e83459b409f10a.diesel.2cm30g51-cgu.1.rcgu.o" "/app/tmp/cache/target/release/deps/diesel-f7e83459b409f10a.diesel.2cm30g51-cgu.10.rcgu.o" "/app/tmp/cache/target/release/deps/diesel-f7e83459b409f10a.diesel.2cm30g51-cgu.11.rcgu.o" "/app/tmp/cache/target/release/deps/diesel-f7e83459b409f10a.diesel.2cm30g51-cgu.12.rcgu.o" "/app/tmp/cache/target/release/deps/diesel-f7e83459b409f10a.diesel.2cm30g51-cgu.13.rcgu.o" "/app/tmp/cache/target/release/deps/diesel-f7e83459b409f10a.diesel.2cm30g51-cgu.14.rcgu.o" "/app/tmp/cache/target/release/deps/diesel-f7e83459b409f10a.diesel.2cm30g51-cgu.15.rcgu.o" "/app/tmp/cache/target/release/deps/diesel-f7e83459b409f10a.diesel.2cm30g51-cgu.2.rcgu.o" "/app/tmp/cache/target/release/deps/diesel-f7e83459b409f10a.diesel.2cm30g51-cgu.3.rcgu.o" "/app/tmp/cache/target/release/deps/diesel-f7e83459b409f10a.diesel.2cm30g51-cgu.4.rcgu.o" "/app/tmp/cache/target/release/deps/diesel-f7e83459b409f10a.diesel.2cm30g51-cgu.5.rcgu.o" "/app/tmp/cache/target/release/deps/diesel-f7e83459b409f10a.diesel.2cm30g51-cgu.6.rcgu.o" "/app/tmp/cache/target/release/deps/diesel-f7e83459b409f10a.diesel.2cm30g51-cgu.7.rcgu.o" "/app/tmp/cache/target/release/deps/diesel-f7e83459b409f10a.diesel.2cm30g51-cgu.8.rcgu.o" "/app/tmp/cache/target/release/deps/diesel-f7e83459b409f10a.diesel.2cm30g51-cgu.9.rcgu.o" "-o" "/app/tmp/cache/target/release/deps/diesel-f7e83459b409f10a" "/app/tmp/cache/target/release/deps/diesel-f7e83459b409f10a.223s0gbspih82e7u.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-Wl,-O1" "-nodefaultlibs" "-L" "/app/tmp/cache/target/release/deps" "-L" "/usr/lib/x86_64-linux-gnu" "-L" "/usr/lib/x86_64-linux-gnu" "-L" "/app/tmp/cache/target/release/build/backtrace-sys-cd7519f0140ff725/out" "-L" "/app/tmp/cache/multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/app/tmp/cache/target/release/deps/libtoml-812b9f8d234f904b.rlib" "/app/tmp/cache/target/release/deps/libtempfile-ea622a08d383a78d.rlib" "/app/tmp/cache/target/release/deps/libremove_dir_all-72d4438afc12eeb9.rlib" "/app/tmp/cache/target/release/deps/librand-6cf5c5b2a5c02a2c.rlib" "/app/tmp/cache/target/release/deps/librand_xorshift-4f5181338e30020e.rlib" "/app/tmp/cache/target/release/deps/librand_pcg-f2d145c630aca600.rlib" "/app/tmp/cache/target/release/deps/librand_hc-c9fed1d6e14a915d.rlib" "/app/tmp/cache/target/release/deps/librand_chacha-4a964f2388cfffb0.rlib" "/app/tmp/cache/target/release/deps/librand_isaac-88c1852cde1f7dfa.rlib" "/app/tmp/cache/target/release/deps/librand_core-9ffd50312567e497.rlib" "/app/tmp/cache/target/release/deps/librand_os-a81cbb71f3549dae.rlib" "/app/tmp/cache/target/release/deps/librand_jitter-2c4493a741160d7d.rlib" "/app/tmp/cache/target/release/deps/librand_core-5f7035685f592f41.rlib" "/app/tmp/cache/target/release/deps/libserde-586a22ad030dc558.rlib" "/app/tmp/cache/target/release/deps/libmigrations_internals-e815cf0fbc811490.rlib" "/app/tmp/cache/target/release/deps/libdotenv-86fab59fdf3ac4a2.rlib" "/app/tmp/cache/target/release/deps/libregex-fdb76bdd5d883359.rlib" "/app/tmp/cache/target/release/deps/libutf8_ranges-3b7c015e99492e01.rlib" "/app/tmp/cache/target/release/deps/libregex_syntax-bb6c5f5fe68c2fbc.rlib" "/app/tmp/cache/target/release/deps/libucd_util-b8eca55e8b6306ed.rlib" "/app/tmp/cache/target/release/deps/libthread_local-7dee4e52ee32dd91.rlib" "/app/tmp/cache/target/release/deps/liblazy_static-9c39e92c390c7b81.rlib" "/app/tmp/cache/target/release/deps/libaho_corasick-a1bfa9d770f0b404.rlib" "/app/tmp/cache/target/release/deps/libmemchr-3028c6333c9896d9.rlib" "/app/tmp/cache/target/release/deps/liberror_chain-2cd742a5eb72be20.rlib" "/app/tmp/cache/target/release/deps/libbacktrace-942da656ae852160.rlib" "/app/tmp/cache/target/release/deps/libbacktrace_sys-7b754aa1e0ca53a1.rlib" "/app/tmp/cache/target/release/deps/librustc_demangle-d83b8d53a5d87021.rlib" "/app/tmp/cache/target/release/deps/libcfg_if-c68be2aaab055294.rlib" "/app/tmp/cache/target/release/deps/libdiesel-daf4b147790a0a95.rlib" "/app/tmp/cache/target/release/deps/liblibsqlite3_sys-8aeb9f98bb7fb9ce.rlib" "/app/tmp/cache/target/release/deps/libpq_sys-b273219623d74766.rlib" "/app/tmp/cache/target/release/deps/liburl-8a4d2dc8acb40ba8.rlib" "/app/tmp/cache/target/release/deps/libpercent_encoding-dd8b632505e681d0.rlib" "/app/tmp/cache/target/release/deps/libidna-9f55aae63d0a98c2.rlib" "/app/tmp/cache/target/release/deps/libunicode_normalization-088171504010bbc2.rlib" "/app/tmp/cache/target/release/deps/libsmallvec-b57123e9e2f6c1ea.rlib" "/app/tmp/cache/target/release/deps/libunicode_bidi-bdd153174254528f.rlib" "/app/tmp/cache/target/release/deps/libmatches-7a6746856c56fab3.rlib" "/app/tmp/cache/target/release/deps/libmysqlclient_sys-80f05ab0e12cdceb.rlib" "/app/tmp/cache/target/release/deps/libbyteorder-9466b0bc769203d3.rlib" "/app/tmp/cache/target/release/deps/libclap-79e7ea6527297f80.rlib" "/app/tmp/cache/target/release/deps/libvec_map-e6e9f33b7cc5c420.rlib" "/app/tmp/cache/target/release/deps/libtextwrap-4ea70646f8027b1f.rlib" "/app/tmp/cache/target/release/deps/libunicode_width-c439b418bacb8b9e.rlib" "/app/tmp/cache/target/release/deps/libstrsim-d9ec05196a0688f1.rlib" "/app/tmp/cache/target/release/deps/libbitflags-bc82542864e9356a.rlib" "/app/tmp/cache/target/release/deps/libatty-366255e298d4f444.rlib" "/app/tmp/cache/target/release/deps/libansi_term-76220da304782c8f.rlib" "/app/tmp/cache/target/release/deps/libchrono-c90590bad6e61942.rlib" "/app/tmp/cache/target/release/deps/libnum_integer-0e40275889cf0052.rlib" "/app/tmp/cache/target/release/deps/libnum_traits-4680b2908e85ecea.rlib" "/app/tmp/cache/target/release/deps/libtime-aa08001c920525c4.rlib" "/app/tmp/cache/target/release/deps/liblibc-fe27ded951782e2d.rlib" "-Wl,--start-group" "/app/tmp/cache/multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-bbd8cb236ab3b537.rlib" "/app/tmp/cache/multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-334e405e4bdf1791.rlib" "/app/tmp/cache/multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libbacktrace_sys-1e14a089a9f63178.rlib" "/app/tmp/cache/multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-f1aae4818bd13556.rlib" "/app/tmp/cache/multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-a32c94e7da1105b4.rlib" "/app/tmp/cache/multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-e214e2acd110aec9.rlib" "/app/tmp/cache/multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-fbf429991e30afee.rlib" "/app/tmp/cache/multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-1734308ff05fb551.rlib" "/app/tmp/cache/multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-b349c8b817f959a5.rlib" "-Wl,--end-group" "/app/tmp/cache/multirust/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-c4b4b16c70e666d9.rlib" "-Wl,-Bdynamic" "-lsqlite3" "-lpq" "-lmysqlclient" "-lutil" "-lutil" "-ldl" "-lrt" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lutil"
remote: = note: /usr/bin/ld: cannot find -lsqlite3
remote: collect2: error: ld returned 1 exit status
remote:
remote:
remote: error: aborting due to previous error
remote:
remote: error: failed to compile `diesel_cli v1.4.0`, intermediate artifacts can be found at `/app/tmp/cache/target`
remote:
remote: Caused by:
remote: Could not compile `diesel_cli`.
remote:
remote: To learn more, run the command again with --verbose.
remote: already installed
remote: cp: missing destination file operand after 'target/release/'
remote: Try 'cp --help' for more information.
remote: ! Push rejected, failed to compile Rust app.
remote:
remote: ! Push failed
remote: Verifying deploy...
`
Hmm, that's odd.
I'm not sure why you'd be trying to link diesel_cli
into your executable. The regular diesel
library is what you should be linking, I would think. I would recommend running diesel
's CLI tools separately, and checking the generated tables, etc., into the repository.
@emk your comment confuses me, if you didn't intend for the diesel cli to be installed then what is this section for? https://github.com/emk/heroku-buildpack-rust#running-diesel-migrations-during-the-release-phase
I check the generated schema.rs
into my source control, what I use diesel_cli
for is running the migrations on my heroku postgres db, which I can't do at build time. One could say that we should be embedding the migrations into our applications, which I don't think is a bad idea, but then what is the purpose of RUST_INSTALL_DIESEL
and the README section I linked to?
Oh, I'm so sorry! I misunderstood. Your error was caused by the diesel
CLI tools that get built into the image for migrations, not by a copy of the CLI crate linked into your application. If that's failing, it's pretty bad.
@msehnout's advice to set the following in RustConfig
is probably your best bet:
DIESEL_FLAGS="--force --no-default-features --features postgres"
It looks like diesel
is trying to build with sqlite3
support by default, and the necessary libraries aren't present on Heroku.
If somebody can confirm that this works, I can change the default setup. Thank you for any information you can provide!
I tried just
DIESEL_FLAGS="--force --no-default-features --features postgres"
and it didn't work. What worked was setting
heroku buildpacks:set https://github.com/emk/heroku-buildpack-rust
and then also with
DIESEL_FLAGS="--force --no-default-features --features postgres"
Same here, I took the following steps:
-
Using the build pack from elements - I can't see attempts to install diesel cli in the log
-
Configure the build pack to point to the GitHub repository instead of the version from elements (
heroku buildpacks:set https://github.com/emk/heroku-buildpack-rust
) seems to allow the diesel cli installation, but it fails with a link errornote: /usr/bin/ld: cannot find -lsqlite3
-
Update
RustConfig
with the flags described aboveDIESEL_FLAGS="--force --no-default-features --features postgres"
✅ success!
I ran into a similar issue, setting heroku buildpacks:set https://github.com/emk/heroku-buildpack-rust
, but instead my build now silently produces this line, and then fails the release step (/bin/sh: 1: ./target/release/diesel: not found
):
-----> Building application using Cargo
Finished release [optimized] target(s) in 0.13s
/app/tmp/buildpacks/7fe9460f39057c0084dfe7973bc78d198489fa5a6700b2bffefff899f2e5498c259f6f44375b9966446f36bee606465d63bd3b0d05bf805d6c6265ccf555a305/bin/compile: line 148: [: 1
As an aside, is there any reason the Elements package emk/rust
cannot be updated? Seems like a lot of confusion could be spared.
Hmm, do I need to take any special steps to update the Elements package, or does it just automatically use master
from this repo?
Not sure about the buildpack publishing, as I've never done it, but it doesn't seem to be automatic going by this notice on the docs: https://devcenter.heroku.com/articles/buildpack-registry#publishing-a-buildpack-version Seems that the convention might be to tag a commit with a version, and then you can select that for wider use.
Ah, thank you! I'll take a look.
Is the documentation still incomplete? Please help :)
I starting with an application that does not use database using 'emk/heroku-buildpack-rust', everything works fine. Next I need Diesel CLI
.
- I created a
RustConfig
file (next toProcfile
)
RUST_INSTALL_DIESEL=1
DIESEL_FLAGS="--no-default-features --features postgres"
- My
Procfile
web: ./target/release/******bot
release: ./target/release/diesel migration run
- Execute
git push heroku master
and get fromheroku logs
2020-05-22T00:19:18.000000+00:00 app[api]: Build started by user *****@yahoo.com
2020-05-22T00:32:37.522142+00:00 app[api]: Running release v15 commands by user *****@yahoo.com
2020-05-22T00:32:38.586525+00:00 heroku[release.9654]: Starting process with command `/bin/sh -c 'if curl https://heroku-release-output.s3.amazonaws.com/log-stream?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AK*****SVQ%2F20200522%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20200522T003237Z&X-Amz-Expires=900&X-Amz-SignedHeaders=host&X-Amz-Signature=846b944*****75c1efa --silent --connect-timeout 10 --retry 3 --retry-delay 1 >/tmp/log-stream; then
2020-05-22T00:32:37.522142+00:00 app[api]: Deploy 1f32b442 by user *****@yahoo.com
2020-05-22T00:32:38.274719+00:00 app[api]: Starting process with command `/bin/sh -c 'if curl $HEROKU_RELEASE_LOG_STREAM --silent --connect-timeout 10 --retry 3 --retry-delay 1 >/tmp/log-stream; then
2020-05-22T00:32:38.274719+00:00 app[api]: chmod u+x /tmp/log-stream
2020-05-22T00:32:38.274719+00:00 app[api]: /tmp/log-stream /bin/sh -c '"'"'./target/release/diesel migration run'"'"'
2020-05-22T00:32:38.274719+00:00 app[api]: else
2020-05-22T00:32:38.274719+00:00 app[api]: ./target/release/diesel migration run
2020-05-22T00:32:38.274719+00:00 app[api]: fi'` by user *****@yahoo.com
2020-05-22T00:32:39.252865+00:00 heroku[release.9654]: State changed from starting to up
2020-05-22T00:32:41.866847+00:00 app[release.9654]: /bin/sh: 1: ./target/release/diesel: not found
2020-05-22T00:32:42.405327+00:00 heroku[release.9654]: Process exited with status 127
2020-05-22T00:32:42.438950+00:00 heroku[release.9654]: State changed from up to complete
2020-05-22T00:32:44.113352+00:00 app[api]: Release v15 command failed by user *****@yahoo.com
2020-05-22T00:34:38.000000+00:00 app[api]: Build succeeded
Is the documentation still incomplete? Please help :)
Hmm, I ran the command to reinstall the buildpack and instead of saying that it was already installed I received:
>heroku buildpacks:set https://github.com/emk/heroku-buildpack-rust
Buildpack set. Next release on vzmuinebot will use https://github.com/emk/heroku-buildpack-rust.
Thanks to all and please add to the documentation a mention that after editing 'RustConfig' you need to run 'heroku buildpacks: set' again.
Now I have a different error (Unable to find migrations directory in this directory or any parent directories.
), but I think that they are not connected :)
still unable to make it work any idea ?
This fixed it for me as well heroku buildpacks:set https://github.com/emk/heroku-buildpack-rust
. It might be worth trying to update the registry or adding it to the documentation. Either way, this buildpack has been very helpful, thank you!
Ditto — looks like the command heroku buildpacks:set emk/rust
, as shown in the README, is not up to date.