hanami: 2.1 RC1 - bundler: command not found: hanami on Heroku deploy
Not sure whether this lies in hanami/cli or elsewhere but I’m opening this here for visibility.
No matter how I try, I can’t get Hanami 2.1 RC1 to skip or ignore the bundle exec hanami assets compile task.
Context
I initially did not set any environment variables: no HANAMI_ENV or SERVE_STATIC_ASSETS. But I later tried these to no avail.
I didn’t set the buildpack order either, Heroku is running with this:
Detected buildpacks: Ruby,Node.js
My Gemfile does include gem "hanami-cli", "2.1.0rc1", not just in the :development group.
Error
Here’s the error I keep getting on deploy, for reference:
remote: -----> Precompiling assets
remote: Running: rake assets:precompile
remote: rake aborted!
remote: Hanami::CLI::HanamiExecError: `bundle exec hanami assets compile' failed
remote:
remote:
remote: "bundler: command not found: hanami\nInstall missing gem executables with `bundle install`"
remote: /tmp/build_f036228f/vendor/bundle/ruby/3.1.0/gems/hanami-cli-2.1.0.rc1/lib/hanami/cli/bundler.rb:94:in `block in hanami_exec'
remote: <internal:kernel>:90:in `tap'
remote: /tmp/build_f036228f/vendor/bundle/ruby/3.1.0/gems/hanami-cli-2.1.0.rc1/lib/hanami/cli/bundler.rb:93:in `hanami_exec'
remote: /tmp/build_f036228f/vendor/bundle/ruby/3.1.0/gems/hanami-2.1.0.rc1/lib/hanami/rake_tasks.rb:57:in `run_hanami_command'
remote: /tmp/build_f036228f/vendor/bundle/ruby/3.1.0/gems/hanami-2.1.0.rc1/lib/hanami/rake_tasks.rb:47:in `block (3 levels) in <top (required)>'
remote: /tmp/build_f036228f/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/exe/rake:27:in `<top (required)>'
remote: Tasks: TOP => assets:precompile
remote: (See full trace by running task with --trace)
Here are my successive attempts:
- Pushed a brand new Hanami 2.1 RC1 app to Heroku
- Repeat with
SERVE_STATIC_ASSETSset to true, same error. - Repeat with
HANAMI_ENVset toproduction, same error. - Repeat with an override of
task "assets:precompile"in myRakefilewhich works fine locally, but is ignored on Heroku, perhaps due the buildpack, leading the same error once again. - I even tried to
config.assets.serve = falseinapp.rbas a last resort, same deal.
Since I ran out of ideas, I’m posting this here hoping this is useful RC1 feedback. I can definitely move this to hanami/cli or the Heroku Ruby buildpack repo if that makes more sense. Thanks y’all. 🤗
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 22 (21 by maintainers)
And I think I might’ve hit why it was failing with our standard rake task.
Heroku’s Buildpack runs the assets:precompile task like so:
In the code above,
precompileis an instance of LanguagePack::Helpers::RakeRunner::RakeTask. It’s invoke method runs rake with just a plainrakeshell command:The fact that there is no
bundle execin front of this is why we cannot locate thehanamiexecutable, because the command is being executed outside of the bundle.I think we might need to update our
assets:precompiletask to have arequire "bundler/setup"at the front of it to accomodate for this.@timriley The branch worked great after I removed the
Rakefileoverride! 👍I think it will take a bit of time to find the specific cause for this
bundle exec hanamierror that we’re seeing during the Heroku Ruby buildpack build phase.I also think we really do want fully working Heroku deploys to be available for new users trying out 2.1.0 along with our new assets support (half the reason for this release!).
As such, I’ve just pushed a PR for the approach I used earlier to achieve a successful Heroku deploy: https://github.com/hanami/hanami/pull/1368
@jodosha I think we should merge this and include it in 2.1.0. This will unblock our users and buy us the time to do a deeper Heroku investigation later on.
I’ve tested this with a brand new Hanami 2.1.0 app with this line in its
Gemfileas the only modification:@olivierlacan Maybe you’d like to try that branch too? If it works for you, then I think we can be confident with bringing this change into the 2.1.0 release. Thanks again for your help bringing this issue to the fore! ❤️