Code Monkey home page Code Monkey logo

Comments (22)

timriley avatar timriley commented on June 2, 2024 2

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:

  def run_assets_precompile_rake_task

    precompile = rake.task("assets:precompile")
    return true unless precompile.is_defined?

    topic "Precompiling assets"
    precompile.invoke(env: rake_env)
    if precompile.success?
      puts "Asset precompilation completed (#{"%.2f" % precompile.time}s)"
    else
      precompile_fail(precompile.output)
    end
  end

In the code above, precompile is an instance of LanguagePack::Helpers::RakeRunner::RakeTask. It's invoke method runs rake with just a plain rake shell command:

        if quiet_option
          self.output = run("rake #{task}", options)
        else
          self.output = pipe("rake #{task}", options)
        end

The fact that there is no bundle exec in front of this is why we cannot locate the hanami executable, because the command is being executed outside of the bundle.

I think we might need to update our assets:precompile task to have a require "bundler/setup" at the front of it to accomodate for this.

from hanami.

timriley avatar timriley commented on June 2, 2024 1

I think it will take a bit of time to find the specific cause for this bundle exec hanami error 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: #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 Gemfile as the only modification:

gem "hanami", github: "hanami/hanami", branch: "fix-assets-precompile-rake-task-for-heroku"

@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! ❤️

from hanami.

olivierlacan avatar olivierlacan commented on June 2, 2024 1

@timriley The branch worked great after I removed the Rakefile override! 👍

from hanami.

jodosha avatar jodosha commented on June 2, 2024

@olivierlacan Can you ssh into the dyno and run "which hanami"?

from hanami.

jodosha avatar jodosha commented on June 2, 2024

@olivierlacan Can you also please try to upgrade to rc2?

from hanami.

olivierlacan avatar olivierlacan commented on June 2, 2024

@olivierlacan Can you ssh into the dyno and run "which hanami"?

I can't since it's never successfully deployed, but I'll give RC2 a try.

from hanami.

olivierlacan avatar olivierlacan commented on June 2, 2024

Sadly same issue with RC2:

remote:        Bundle completed (23.66s)
remote:        Cleaning up the bundler cache.
remote: -----> Writing config/database.yml to read from DATABASE_URL
remote: -----> Installing node-v20.9.0-linux-x64
remote: -----> Installing yarn-v1.22.19
remote: -----> Detecting rake tasks
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_dd6d9cbf/vendor/bundle/ruby/3.1.0/gems/hanami-cli-2.1.0.rc2/lib/hanami/cli/bundler.rb:94:in `block in hanami_exec'
remote:        <internal:kernel>:90:in `tap'
remote:        /tmp/build_dd6d9cbf/vendor/bundle/ruby/3.1.0/gems/hanami-cli-2.1.0.rc2/lib/hanami/cli/bundler.rb:93:in `hanami_exec'
remote:        /tmp/build_dd6d9cbf/vendor/bundle/ruby/3.1.0/gems/hanami-2.1.0.rc2/lib/hanami/rake_tasks.rb:57:in `run_hanami_command'
remote:        /tmp/build_dd6d9cbf/vendor/bundle/ruby/3.1.0/gems/hanami-2.1.0.rc2/lib/hanami/rake_tasks.rb:47:in `block (3 levels) in <top (required)>'
remote:        /tmp/build_dd6d9cbf/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)
remote:
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote:
remote:  !     Push failed

from hanami.

olivierlacan avatar olivierlacan commented on June 2, 2024

Maybe @schneems can help shed some light on this given I can’t get a dyno to boot?

in any case I might open a support ticket. I’ll try again later with a simpler sample app just to make sure I don’t have something funky in this one.

from hanami.

timriley avatar timriley commented on June 2, 2024

Depending on what we learn here, I wonder if there's an approach we can take where the assets:precompile rake task doesn't invoke hanami as a shell executable, but rather invokes the hanami-cli command class instead, e.g.

Hanami::CLI::Commands::App::Assets::Compile.new.call

In fact, I wonder if that's an experiment you could try now, @olivierlacan? Since you've already given overriding assets:precompile a go, hopefully this would be an easy thing to try too.

Here's what I just did locally, in make Rakefile, and it seemed to work:

Rake::Task["assets:precompile"].clear
namespace :assets do
  namespace :precompile do
    Hanami::CLI::Commands::App::Assets::Compile.new.call
  end
end

from hanami.

schneems avatar schneems commented on June 2, 2024

Maybe @schneems can help shed some light on this given I can’t get a dyno to boot?

For debugging you can commit a asset manifest file https://devcenter.heroku.com/articles/rails-asset-pipeline#compiling-assets-locally

then you can

heroku run bash
which hanami
rake assets:precompile —trace

To debug in the dyno.

from hanami.

timriley avatar timriley commented on June 2, 2024

OK, I nerd-sniped myself into giving this a try 😆

Once I override the the assets:precompile task as above, I got an interesting and possibly instructive new error!

Below is the relevant part, and I'll include the full output underneath:

remote: -----> Detecting rake tasks
remote:        Could not detect rake tasks
remote:        ensure you can run `$ bundle exec rake -P` against your app
remote:        and using the production group of your Gemfile.
remote:        rake aborted!
remote:        Errno::ENOENT: No such file or directory - npm
remote:        /tmp/build_1ea9e0dc/vendor/ruby-3.1.4/lib/ruby/3.1.0/open3.rb:222:in `spawn'
remote:        /tmp/build_1ea9e0dc/vendor/ruby-3.1.4/lib/ruby/3.1.0/open3.rb:222:in `popen_run'
remote:        /tmp/build_1ea9e0dc/vendor/ruby-3.1.4/lib/ruby/3.1.0/open3.rb:103:in `popen3'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/hanami-cli-2.1.0.rc2/lib/hanami/cli/system_call.rb:94:in `block in call'
remote:        /tmp/build_1ea9e0dc/vendor/ruby-3.1.4/lib/ruby/3.1.0/bundler.rb:409:in `block in with_unbundled_env'
remote:        /tmp/build_1ea9e0dc/vendor/ruby-3.1.4/lib/ruby/3.1.0/bundler.rb:708:in `with_env'
remote:        /tmp/build_1ea9e0dc/vendor/ruby-3.1.4/lib/ruby/3.1.0/bundler.rb:409:in `with_unbundled_env'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/hanami-cli-2.1.0.rc2/lib/hanami/cli/system_call.rb:93:in `call'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/hanami-cli-2.1.0.rc2/lib/hanami/cli/commands/app/assets/command.rb:26:in `call'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/hanami-cli-2.1.0.rc2/lib/hanami/cli/commands/app/command.rb:40:in `call'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/hanami-cli-2.1.0.rc2/lib/hanami/cli/commands/app/command.rb:40:in `call'
remote:        /tmp/build_1ea9e0dc/Rakefile:9:in `block (2 levels) in <top (required)>'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/task_manager.rb:232:in `in_namespace'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/dsl_definition.rb:141:in `namespace'
remote:        /tmp/build_1ea9e0dc/Rakefile:8:in `block in <top (required)>'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/task_manager.rb:232:in `in_namespace'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/dsl_definition.rb:141:in `namespace'
remote:        /tmp/build_1ea9e0dc/Rakefile:7:in `<top (required)>'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/rake_module.rb:29:in `load'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/rake_module.rb:29:in `load_rakefile'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/application.rb:734:in `raw_load_rakefile'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/application.rb:126:in `block in load_rakefile'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/application.rb:208:in `standard_exception_handling'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/application.rb:125:in `load_rakefile'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/application.rb:82:in `block in run'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/application.rb:208:in `standard_exception_handling'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/application.rb:80:in `run'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/exe/rake:27:in `<top (required)>'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/bin/rake:27:in `load'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/bin/rake:27:in `<main>'
Full output
~/src/scratch/heroku_test on main
❯ git push heroku main
Enumerating objects: 55, done.
Counting objects: 100% (55/55), done.
Delta compression using up to 10 threads
Compressing objects: 100% (41/41), done.
Writing objects: 100% (55/55), 19.91 KiB | 6.64 MiB/s, done.
Total 55 (delta 6), reused 0 (delta 0), pack-reused 0
remote: Updated 32 paths from 508f72b
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-22 stack
remote: -----> Determining which buildpack to use for this app
remote:  !     Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
remote: 			Detected buildpacks: Ruby,Node.js
remote: 			See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
remote: -----> Ruby app detected
remote: -----> Installing bundler 2.3.25
remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
remote: -----> Compiling Ruby/Rack
remote: -----> Using Ruby version: ruby-3.1.4
remote: -----> Installing dependencies using bundler 2.3.25
remote:        Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
remote:        Fetching gem metadata from https://rubygems.org/...........
remote:        Fetching rake 13.1.0
remote:        Installing rake 13.1.0
remote:        Using bundler 2.3.26
remote:        Fetching diff-lcs 1.5.0
remote:        Fetching zeitwerk 2.6.12
remote:        Fetching concurrent-ruby 1.2.2
remote:        Fetching dry-cli 1.0.0
remote:        Installing dry-cli 1.0.0
remote:        Installing zeitwerk 2.6.12
remote:        Fetching dry-files 1.1.0
remote:        Installing diff-lcs 1.5.0
remote:        Installing dry-files 1.1.0
remote:        Installing concurrent-ruby 1.2.2
remote:        Fetching dry-inflector 1.0.0
remote:        Fetching dry-initializer 3.1.1
remote:        Fetching dry-logger 1.0.3
remote:        Installing dry-inflector 1.0.0
remote:        Installing dry-logger 1.0.3
remote:        Fetching rack 2.2.8
remote:        Using ruby2_keywords 0.0.5
remote:        Installing dry-initializer 3.1.1
remote:        Fetching hansi 0.2.1
remote:        Fetching rspec-support 3.12.1
remote:        Installing rack 2.2.8
remote:        Fetching temple 0.10.3
remote:        Installing rspec-support 3.12.1
remote:        Installing hansi 0.2.1
remote:        Fetching tilt 2.3.0
remote:        Installing temple 0.10.3
remote:        Fetching dry-transformer 1.0.1
remote:        Fetching nio4r 2.5.9
remote:        Fetching hanami-assets 2.1.0.rc2
remote:        Installing tilt 2.3.0
remote:        Installing hanami-assets 2.1.0.rc2
remote:        Installing nio4r 2.5.9 with native extensions
remote:        Fetching hanami-cli 2.1.0.rc2
remote:        Installing dry-transformer 1.0.1
remote:        Fetching mustermann 3.0.0
remote:        Fetching dry-core 1.0.1
remote:        Installing mustermann 3.0.0
remote:        Installing hanami-cli 2.1.0.rc2
remote:        Fetching rspec-core 3.12.2
remote:        Installing dry-core 1.0.1
remote:        Fetching rspec-mocks 3.12.6
remote:        Fetching rspec-expectations 3.12.3
remote:        Installing rspec-core 3.12.2
remote:        Installing rspec-mocks 3.12.6
remote:        Installing rspec-expectations 3.12.3
remote:        Fetching mustermann-contrib 3.0.0
remote:        Fetching dry-auto_inject 1.0.1
remote:        Fetching dry-configurable 1.1.0
remote:        Installing mustermann-contrib 3.0.0
remote:        Installing dry-auto_inject 1.0.1
remote:        Fetching dry-events 1.0.1
remote:        Fetching dry-logic 1.5.0
remote:        Installing dry-configurable 1.1.0
remote:        Fetching hanami-utils 2.1.0.rc2
remote:        Installing dry-events 1.0.1
remote:        Installing dry-logic 1.5.0
remote:        Fetching hanami-reloader 2.1.0.rc2
remote:        Fetching rspec 3.12.0
remote:        Installing hanami-utils 2.1.0.rc2
remote:        Installing hanami-reloader 2.1.0.rc2
remote:        Fetching dry-system 1.0.1
remote:        Fetching hanami-router 2.1.0.rc2
remote:        Installing rspec 3.12.0
remote:        Fetching hanami-view 2.1.0.rc2
remote:        Installing dry-system 1.0.1
remote:        Installing hanami-router 2.1.0.rc2
remote:        Fetching dry-monitor 1.0.1
remote:        Installing hanami-view 2.1.0.rc2
remote:        Fetching dry-types 1.7.1
remote:        Fetching hanami-controller 2.1.0.rc2
remote:        Installing dry-monitor 1.0.1
remote:        Fetching hanami-rspec 2.1.0.rc2
remote:        Installing dry-types 1.7.1
remote:        Installing hanami-controller 2.1.0.rc2
remote:        Fetching hanami 2.1.0.rc2
remote:        Fetching dry-schema 1.13.3
remote:        Installing hanami-rspec 2.1.0.rc2
remote:        Installing dry-schema 1.13.3
remote:        Installing hanami 2.1.0.rc2
remote:        Fetching dry-validation 1.10.0
remote:        Installing dry-validation 1.10.0
remote:        Fetching hanami-validations 2.1.0.rc2
remote:        Installing hanami-validations 2.1.0.rc2
remote:        Fetching puma 6.4.0
remote:        Installing puma 6.4.0 with native extensions
remote:        Bundle complete! 16 Gemfile dependencies, 45 gems now installed.
remote:        Gems in the groups 'development' and 'test' were not installed.
remote:        Bundled gems are installed into `./vendor/bundle`
remote:        Bundle completed (8.65s)
remote:        Cleaning up the bundler cache.
remote: -----> Writing config/database.yml to read from DATABASE_URL
remote:
remote: ###### WARNING:
remote:
remote:        Installing a default version (20.9.0) of Node.js.
remote:        This version is not pinned and can change over time, causing unexpected failures.
remote:
remote:        Heroku recommends placing the `heroku/nodejs` buildpack in front of
remote:        `heroku/ruby` to install a specific version of node:
remote:
remote:        https://devcenter.heroku.com/articles/ruby-support#node-js-support
remote:
remote: -----> Installing node-v20.9.0-linux-x64
remote: -----> Detecting rake tasks
remote:        Could not detect rake tasks
remote:        ensure you can run `$ bundle exec rake -P` against your app
remote:        and using the production group of your Gemfile.
remote:        rake aborted!
remote:        Errno::ENOENT: No such file or directory - npm
remote:        /tmp/build_1ea9e0dc/vendor/ruby-3.1.4/lib/ruby/3.1.0/open3.rb:222:in `spawn'
remote:        /tmp/build_1ea9e0dc/vendor/ruby-3.1.4/lib/ruby/3.1.0/open3.rb:222:in `popen_run'
remote:        /tmp/build_1ea9e0dc/vendor/ruby-3.1.4/lib/ruby/3.1.0/open3.rb:103:in `popen3'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/hanami-cli-2.1.0.rc2/lib/hanami/cli/system_call.rb:94:in `block in call'
remote:        /tmp/build_1ea9e0dc/vendor/ruby-3.1.4/lib/ruby/3.1.0/bundler.rb:409:in `block in with_unbundled_env'
remote:        /tmp/build_1ea9e0dc/vendor/ruby-3.1.4/lib/ruby/3.1.0/bundler.rb:708:in `with_env'
remote:        /tmp/build_1ea9e0dc/vendor/ruby-3.1.4/lib/ruby/3.1.0/bundler.rb:409:in `with_unbundled_env'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/hanami-cli-2.1.0.rc2/lib/hanami/cli/system_call.rb:93:in `call'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/hanami-cli-2.1.0.rc2/lib/hanami/cli/commands/app/assets/command.rb:26:in `call'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/hanami-cli-2.1.0.rc2/lib/hanami/cli/commands/app/command.rb:40:in `call'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/hanami-cli-2.1.0.rc2/lib/hanami/cli/commands/app/command.rb:40:in `call'
remote:        /tmp/build_1ea9e0dc/Rakefile:9:in `block (2 levels) in <top (required)>'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/task_manager.rb:232:in `in_namespace'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/dsl_definition.rb:141:in `namespace'
remote:        /tmp/build_1ea9e0dc/Rakefile:8:in `block in <top (required)>'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/task_manager.rb:232:in `in_namespace'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/dsl_definition.rb:141:in `namespace'
remote:        /tmp/build_1ea9e0dc/Rakefile:7:in `<top (required)>'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/rake_module.rb:29:in `load'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/rake_module.rb:29:in `load_rakefile'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/application.rb:734:in `raw_load_rakefile'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/application.rb:126:in `block in load_rakefile'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/application.rb:208:in `standard_exception_handling'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/application.rb:125:in `load_rakefile'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/application.rb:82:in `block in run'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/application.rb:208:in `standard_exception_handling'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib/rake/application.rb:80:in `run'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/exe/rake:27:in `<top (required)>'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/bin/rake:27:in `load'
remote:        /tmp/build_1ea9e0dc/vendor/bundle/bin/rake:27:in `<main>'
remote:
remote: ###### WARNING:
remote:
remote:        You have not declared a Ruby version in your Gemfile.
remote:
remote:        To declare a Ruby version add this line to your Gemfile:
remote:
remote:        ```
remote:        ruby "3.1.4"
remote:        ```
remote:
remote:        For more information see:
remote:          https://devcenter.heroku.com/articles/ruby-versions
remote:
remote: ###### WARNING:
remote:
remote:        Installing a default version (20.9.0) of Node.js.
remote:        This version is not pinned and can change over time, causing unexpected failures.
remote:
remote:        Heroku recommends placing the `heroku/nodejs` buildpack in front of
remote:        `heroku/ruby` to install a specific version of node:
remote:
remote:        https://devcenter.heroku.com/articles/ruby-support#node-js-support
remote:
remote: ###### WARNING:
remote:
remote:        No Procfile detected, using the default web server.
remote:        We recommend explicitly declaring how to boot your server process via a Procfile.
remote:        https://devcenter.heroku.com/articles/ruby-default-web-server
remote:
remote:
remote: -----> Discovering process types
remote:        Procfile declares types     -> (none)
remote:        Default types for buildpack -> console, rake, web
remote:
remote: -----> Compressing...
remote:        Done: 56.6M
remote: -----> Launching...
remote:        Released v4
remote:        https://tim-hanami-assets-test-6216939b05d6.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/tim-hanami-assets-test.git
 * [new branch]      main -> main

I think this means I might need to be more explicit in setting up the node build pack. I can give this a try later this afternoon.

from hanami.

timriley avatar timriley commented on June 2, 2024

OK, I think I have half-sorted this.

The first trick was making sure the buildpacks are in the right order:

heroku buildpacks:clear
heroku buildpacks:add heroku/nodejs
heroku buildpacks:add heroku/ruby

Which results in the following when running heroku buildpacks

=== tim-hanami-assets-test Buildpack URLs

1. heroku/nodejs
2. heroku/ruby

Then, with the assets:precompile rake task overridden in my Rakefile:

Rake::Task["assets:precompile"].clear
namespace :assets do
  namespace :precompile do
    Hanami::CLI::Commands::App::Assets::Compile.new.call
  end
end

I could run git push heroku and see everything work:

❯ git push heroku
Enumerating objects: 8, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 10 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 982 bytes | 982.00 KiB/s, done.
Total 6 (delta 4), reused 0 (delta 0), pack-reused 0
remote: Updated 32 paths from 788f07e
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-22 stack
remote: -----> Using buildpacks:
remote:        1. heroku/nodejs
remote:        2. heroku/ruby
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NODE_VERBOSE=false
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:
remote: -----> Installing binaries
remote:        engines.node (package.json):  unspecified
remote:        engines.npm (package.json):   unspecified (use default)
remote:
remote:        Resolving node version 20.x...
remote:        Downloading and installing node 20.9.0...
remote:        Using default npm version: 10.1.0
remote:
remote: -----> Restoring cache
remote:        - npm cache
remote:
remote: -----> Installing dependencies
remote:        Installing node modules
remote:
remote:        added 47 packages, and audited 48 packages in 696ms
remote:
remote:        14 packages are looking for funding
remote:          run `npm fund` for details
remote:
remote:        found 0 vulnerabilities
remote:
remote: -----> Build
remote:
remote: -----> Caching build
remote:        - npm cache
remote:
remote: -----> Pruning devDependencies
remote:
remote:        up to date, audited 48 packages in 444ms
remote:
remote:        14 packages are looking for funding
remote:          run `npm fund` for details
remote:
remote:        found 0 vulnerabilities
remote:        npm notice
remote:        npm notice New minor version of npm available! 10.1.0 -> 10.2.3
remote:        npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.2.3>
remote:        npm notice Run `npm install -g [email protected]` to update!
remote:        npm notice
remote:
remote: -----> Build succeeded!
remote:  !     This app may not specify any way to start a node process
remote:        https://devcenter.heroku.com/articles/nodejs-support#default-web-process-type
remote:
remote: -----> Ruby app detected
remote: -----> Installing bundler 2.3.25
remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
remote: -----> Compiling Ruby/Rack
remote: -----> Using Ruby version: ruby-3.1.4
remote: -----> Installing dependencies using bundler 2.3.25
remote:        Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
remote:        Using rake 13.1.0
remote:        Using bundler 2.3.26
remote:        Using concurrent-ruby 1.2.2
remote:        Using diff-lcs 1.5.0
remote:        Using zeitwerk 2.6.12
remote:        Using dry-core 1.0.1
remote:        Using dry-auto_inject 1.0.1
remote:        Using dry-cli 1.0.0
remote:        Using dry-configurable 1.1.0
remote:        Using dry-events 1.0.1
remote:        Using dry-files 1.1.0
remote:        Using dry-inflector 1.0.0
remote:        Using dry-initializer 3.1.1
remote:        Using dry-logger 1.0.3
remote:        Using dry-logic 1.5.0
remote:        Using dry-monitor 1.0.1
remote:        Using dry-types 1.7.1
remote:        Using dry-schema 1.13.3
remote:        Using dry-system 1.0.1
remote:        Using dry-transformer 1.0.1
remote:        Using dry-validation 1.10.0
remote:        Using hanami-cli 2.1.0.rc2
remote:        Using hanami-utils 2.1.0.rc2
remote:        Using hanami 2.1.0.rc2
remote:        Using hanami-assets 2.1.0.rc2
remote:        Using rack 2.2.8
remote:        Using hanami-controller 2.1.0.rc2
remote:        Using hanami-reloader 2.1.0.rc2
remote:        Using ruby2_keywords 0.0.5
remote:        Using mustermann 3.0.0
remote:        Using hansi 0.2.1
remote:        Using mustermann-contrib 3.0.0
remote:        Using hanami-router 2.1.0.rc2
remote:        Using rspec-support 3.12.1
remote:        Using rspec-core 3.12.2
remote:        Using rspec-expectations 3.12.3
remote:        Using rspec-mocks 3.12.6
remote:        Using rspec 3.12.0
remote:        Using hanami-rspec 2.1.0.rc2
remote:        Using hanami-validations 2.1.0.rc2
remote:        Using temple 0.10.3
remote:        Using tilt 2.3.0
remote:        Using hanami-view 2.1.0.rc2
remote:        Using nio4r 2.5.9
remote:        Using puma 6.4.0
remote:        Bundle complete! 16 Gemfile dependencies, 45 gems now installed.
remote:        Gems in the groups 'development' and 'test' were not installed.
remote:        Bundled gems are installed into `./vendor/bundle`
remote:        Bundle completed (0.25s)
remote:        Cleaning up the bundler cache.
remote:        Removing bundler (2.3.25)
remote: -----> Writing config/database.yml to read from DATABASE_URL
remote: -----> Detecting rake tasks
remote: -----> Precompiling assets
remote:        Running: rake assets:precompile
remote:        Asset precompilation completed (1.05s)
remote:
remote: ###### WARNING:
remote:
remote:        You have not declared a Ruby version in your Gemfile.
remote:
remote:        To declare a Ruby version add this line to your Gemfile:
remote:
remote:        ```
remote:        ruby "3.1.4"
remote:        ```
remote:
remote:        For more information see:
remote:          https://devcenter.heroku.com/articles/ruby-versions
remote:
remote: ###### WARNING:
remote:
remote:        No Procfile detected, using the default web server.
remote:        We recommend explicitly declaring how to boot your server process via a Procfile.
remote:        https://devcenter.heroku.com/articles/ruby-default-web-server
remote:
remote:
remote: -----> Discovering process types
remote:        Procfile declares types     -> (none)
remote:        Default types for buildpack -> console, rake, web
remote:
remote: -----> Compressing...
remote:        Done: 76.7M
remote: -----> Launching...
remote:        Released v7
remote:        https://tim-hanami-assets-test-6216939b05d6.herokuapp.com/ deployed to Heroku
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/tim-hanami-assets-test.git
   e9facd7..7b44a6c  main -> main
branch 'main' set up to track 'heroku/main'.

Running heroku run bash at this point shows the assets manifest:

❯ heroku run bash
Running bash on ⬢ tim-hanami-assets-test... up, run.6700 (Basic)
~ $ cat public/assets.json
{
  "app.js": {
    "url": "/assets/app-LSLFPUMX.js"
  },
  "app.css": {
    "url": "/assets/app-GVDAEYEC.css"
  },
  "favicon.ico": {
    "url": "/assets/favicon-3CB10386.ico"
  }
}

So this is good!

Where this falls down still is if I remove my override of the rake task. This results in the same error you saw before, @olivierlacan:

remote: -----> Writing config/database.yml to read from DATABASE_URL
remote: -----> Detecting rake tasks
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_9cca44d0/vendor/bundle/ruby/3.1.0/gems/hanami-cli-2.1.0.rc2/lib/hanami/cli/bundler.rb:94:in `block in hanami_exec'
remote:        <internal:kernel>:90:in `tap'
remote:        /tmp/build_9cca44d0/vendor/bundle/ruby/3.1.0/gems/hanami-cli-2.1.0.rc2/lib/hanami/cli/bundler.rb:93:in `hanami_exec'
remote:        /tmp/build_9cca44d0/vendor/bundle/ruby/3.1.0/gems/hanami-2.1.0.rc2/lib/hanami/rake_tasks.rb:57:in `run_hanami_command'
remote:        /tmp/build_9cca44d0/vendor/bundle/ruby/3.1.0/gems/hanami-2.1.0.rc2/lib/hanami/rake_tasks.rb:47:in `block (3 levels) in <top (required)>'
remote:        /tmp/build_9cca44d0/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)
remote:
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !	Push rejected to tim-hanami-assets-test.
remote:
To https://git.heroku.com/tim-hanami-assets-test.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/tim-hanami-assets-test.git'

from hanami.

timriley avatar timriley commented on June 2, 2024

I think we might need to update our assets:precompile task to have a require "bundler/setup" at the front of it to accomodate for this.

Turns out, not quite. I experimented with this Rakefile:

# frozen_string_literal: true

require "hanami/rake_tasks"

task :environment do
  puts "LOADING ENVIRONMENT"
  require "bundler/setup"
  require "hanami/setup"
end
Rake::Task["assets:precompile"].enhance ["environment"]

And it didn't work. Not so simple, unfortunately.

Might need some work inside Hanami::CLI::Bundler to somehow make sure it's invoking shell commands within the bundled environment.

from hanami.

olivierlacan avatar olivierlacan commented on June 2, 2024

@timriley Oh damn it, I did remember seeing someone here or on Discuss saying they had to put the Node buildpack first in the list, which made absolutely zero sense to me.

So I tried the following after following all the (very helpful) experiments you made above @timriley, although it seems the Heroku docs encourage this --index flag to guarantee order (without needing to clear):

$ heroku buildpacks:add --index 1 heroku/nodejs
$ heroku buildpacks:add --index 2 heroku/ruby

$ heroku buildpacks
=== Buildpack URLs

1. heroku/nodejs
2. heroku/ruby

Now for the surprising part:

remote: -----> Installing dependencies
remote:        Installing node modules (yarn.lock)
remote:        yarn install v1.22.19
remote:        [1/4] Resolving packages...
remote:        warning Lockfile has incorrect entry for "hanami-assets@^2.1.0-rc1". Ignoring it.
remote:        error Couldn't find any versions for "hanami-assets" that matches "^2.1.0-rc1"
remote:        info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
remote:
remote: -----> Build failed

I completely forgot I had to update my package.json... whoops:

  "dependencies": {
    "hanami-assets": "^2.1.0-rc1"
  }
}

You might not catch this easily but this version is totally wrong and I have... no idea how that got in there. The proper version on NPM is [2.1.0-rc.1](https://www.npmjs.com/package/hanami-assets/v/2.1.0-rc.1) (emphasis on the . between rc and 1).

And after bumping that to a correct "^2.1.0-rc.2" at least the NodeJS part of the build goes flawlessly... but this still crashes in Ruby land, not very surprising based on your research:

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_86774ee8/vendor/bundle/ruby/3.1.0/gems/hanami-cli-2.1.0.rc2/lib/hanami/cli/bundler.rb:94:in `block in hanami_exec'
remote:        <internal:kernel>:90:in `tap'
remote:        /tmp/build_86774ee8/vendor/bundle/ruby/3.1.0/gems/hanami-cli-2.1.0.rc2/lib/hanami/cli/bundler.rb:93:in `hanami_exec'
remote:        /tmp/build_86774ee8/vendor/bundle/ruby/3.1.0/gems/hanami-2.1.0.rc2/lib/hanami/rake_tasks.rb:57:in `run_hanami_command'
remote:        /tmp/build_86774ee8/vendor/bundle/ruby/3.1.0/gems/hanami-2.1.0.rc2/lib/hanami/rake_tasks.rb:47:in `block (3 levels) in <top (required)>'
remote:        /tmp/build_86774ee8/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)

I have a strong suspicion that the culprit is this invoke call in the Heroku Ruby buildpack:

  def run_assets_precompile_rake_task
    precompile = rake.task("assets:precompile")
    return true unless precompile.is_defined?

    topic "Precompiling assets"
    precompile.invoke(env: rake_env)
    if precompile.success?
      puts "Asset precompilation completed (#{"%.2f" % precompile.time}s)"
    else
      precompile_fail(precompile.output)
    end
  end

from hanami.

timriley avatar timriley commented on June 2, 2024

I have a strong suspicion that the culprit is this invoke call in the Heroku Ruby buildpack

@olivierlacan, yep, agreed! See my comment just above 😉

If possible, it would be good if we could find a way to work with this Buildpack behaviour before 2.1.0, even if it is just a small tactical fix.

from hanami.

jodosha avatar jodosha commented on June 2, 2024

@schneems Hey, do you know why rake is invoked w/o bundle exec? Thanks 🙂

from hanami.

jodosha avatar jodosha commented on June 2, 2024

@timriley

Might need some work inside Hanami::CLI::Bundler to somehow make sure it's invoking shell commands within the bundled environment.

We already prefix the shell invocations with /path/to/bundler.

Maybe the bundler exec is missing?

from hanami.

timriley avatar timriley commented on June 2, 2024

Maybe this is part of the issue...

When I run heroku run bash, getting me into the last successful deploy I did (where I bypassed us calling bundle exec hanami), here where the hanami executable is located:

❯ heroku run bash
Running bash on ⬢ tim-hanami-assets-test... up, run.2688 (Basic)
~ $ which hanami
/app/vendor/bundle/bin/hanami

But then when I update my Rakefile to contain the following:

task :environment do
  output = `ls /app/vendor/bundle/bin`
  puts output
end
Rake::Task["assets:precompile"].enhance ["environment"]

When I deploy this change, I see this error from the ls command:

remote:        Running: rake assets:precompile
remote:        ls: cannot access '/app/vendor/bundle/bin': No such file or directory

Is it possible that rake assets:precompile is being executed before all the gem executables have been properly installed?

This is very strange, because the gems themselves are installed, which is why this in the Rakefile worked for me:

Rake::Task["assets:precompile"].clear
namespace :assets do
  namespace :precompile do
    Hanami::CLI::Commands::App::Assets::Compile.new.call
  end
end

So how could it be that the gems' Ruby files are loaded, but their executables are not around?

from hanami.

timriley avatar timriley commented on June 2, 2024

If I capture the output of ls -laR /app in my assets:precompile enhancement, there's not a whole lot there at all:

remote:        /app:
remote:        total 16
remote:        drwx------  4 u56454 dyno 4096 Nov  9 10:28 .
remote:        drwxr-xr-x 11 root   root 4096 Nov  6 09:25 ..
remote:        drwx------  2 u56454 dyno 4096 Nov  9 10:28 bin
remote:        drwx------  3 u56454 dyno 4096 Nov  9 10:28 .npm
remote:        -rw-------  1 u56454 dyno    0 Nov  9 10:28 ___sentinel___
remote:
remote:        /app/bin:
remote:        total 8
remote:        drwx------ 2 u56454 dyno 4096 Nov  9 10:28 .
remote:        drwx------ 4 u56454 dyno 4096 Nov  9 10:28 ..
remote:
remote:        /app/.npm:
remote:        total 12
remote:        drwx------ 3 u56454 dyno 4096 Nov  9 10:28 .
remote:        drwx------ 4 u56454 dyno 4096 Nov  9 10:28 ..
remote:        drwx------ 2 u56454 dyno 4096 Nov  9 10:28 _logs
remote:
remote:        /app/.npm/_logs:
remote:        total 12
remote:        drwx------ 2 u56454 dyno 4096 Nov  9 10:28 .
remote:        drwx------ 3 u56454 dyno 4096 Nov  9 10:28 ..
remote:        -rw------- 1 u56454 dyno 1666 Nov  9 10:28 2023-11-09T10_28_33_632Z-debug-0.log

No /app/vendor directory at all, for example, which means no bundler-findable gem executables.

from hanami.

timriley avatar timriley commented on June 2, 2024

Now if I pp $LOAD_PATH, I see that we're inside a tmp build directory at this stage:

remote:        ["/tmp/build_b6159e5a/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/puma-6.4.0/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0/puma-6.4.0",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/nio4r-2.5.9/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/extensions/x86_64-linux/3.1.0/nio4r-2.5.9",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/hanami-view-2.1.0.rc2/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/tilt-2.3.0/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/temple-0.10.3/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/hanami-validations-2.1.0.rc2/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/hanami-rspec-2.1.0.rc2/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/rspec-3.12.0/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/rspec-mocks-3.12.6/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/rspec-expectations-3.12.3/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.2/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/rspec-support-3.12.1/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/hanami-router-2.1.0.rc2/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/mustermann-contrib-3.0.0/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/hansi-0.2.1/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/mustermann-3.0.0/lib",
remote:         "/tmp/build_b6159e5a/vendor/ruby-3.1.4/lib/ruby/gems/3.1.0/gems/ruby2_keywords-0.0.5/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/hanami-reloader-2.1.0.rc2/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/hanami-controller-2.1.0.rc2/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/rack-2.2.8/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/hanami-assets-2.1.0.rc2/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/hanami-2.1.0.rc2/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/hanami-utils-2.1.0.rc2/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/hanami-cli-2.1.0.rc2/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/dry-validation-1.10.0/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/dry-transformer-1.0.1/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/dry-system-1.0.1/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/dry-schema-1.13.3/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/dry-types-1.7.1/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/dry-monitor-1.0.1/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/dry-logic-1.5.0/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/dry-logger-1.0.3/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/dry-initializer-3.1.1/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/dry-inflector-1.0.0/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/dry-files-1.1.0/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/dry-events-1.0.1/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/dry-configurable-1.1.0/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/dry-cli-1.0.0/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/dry-auto_inject-1.0.1/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/dry-core-1.0.1/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/zeitwerk-2.6.12/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/diff-lcs-1.5.0/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/concurrent-ruby-1.2.2/lib/concurrent-ruby",
remote:         "/tmp/build_b6159e5a/vendor/ruby-3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.3.26/lib",
remote:         "/tmp/build_b6159e5a/vendor/bundle/ruby/3.1.0/gems/rake-13.1.0/lib",
remote:         "/tmp/build_b6159e5a/vendor/ruby-3.1.4/lib/ruby/site_ruby/3.1.0",
remote:         "/tmp/build_b6159e5a/vendor/ruby-3.1.4/lib/ruby/site_ruby/3.1.0/x86_64-linux",
remote:         "/tmp/build_b6159e5a/vendor/ruby-3.1.4/lib/ruby/site_ruby",
remote:         "/tmp/build_b6159e5a/vendor/ruby-3.1.4/lib/ruby/vendor_ruby/3.1.0",
remote:         "/tmp/build_b6159e5a/vendor/ruby-3.1.4/lib/ruby/vendor_ruby/3.1.0/x86_64-linux",
remote:         "/tmp/build_b6159e5a/vendor/ruby-3.1.4/lib/ruby/vendor_ruby",
remote:         "/tmp/build_b6159e5a/vendor/ruby-3.1.4/lib/ruby/3.1.0",
remote:         "/tmp/build_b6159e5a/vendor/ruby-3.1.4/lib/ruby/3.1.0/x86_64-linux"]

Dir.pwd reports /tmp/build_b6159e5a too.

If I add a ls -laR . I see that our gem executables are in ./vendor/bundle/bin, underneath our /tmp/build_b6159e5a pwd:

remote:        ./vendor/bundle/bin:
remote:        total 52
remote:        drwx------ 2 u10166 dyno 4096 Nov  9 01:05 .
remote:        drwx------ 4 u10166 dyno 4096 Nov  9 01:05 ..
remote:        -rwx------ 1 u10166 dyno 2967 Nov  9 10:35 bundle
remote:        -rwx------ 1 u10166 dyno  751 Nov  9 10:35 hanami
remote:        -rwx------ 1 u10166 dyno  768 Nov  9 10:35 hanami-assets
remote:        -rwx------ 1 u10166 dyno  753 Nov  9 10:35 htmldiff
remote:        -rwx------ 1 u10166 dyno  747 Nov  9 10:35 ldiff
remote:        -rwx------ 1 u10166 dyno  741 Nov  9 10:35 puma
remote:        -rwx------ 1 u10166 dyno  747 Nov  9 10:35 pumactl
remote:        -rwx------ 1 u10166 dyno  745 Nov  9 10:35 rackup
remote:        -rwx------ 1 u10166 dyno  741 Nov  9 10:35 rake
remote:        -rwx------ 1 u10166 dyno  749 Nov  9 10:35 rspec
remote:        -rwx------ 1 u10166 dyno  741 Nov  9 10:35 tilt

Now if I do an ENV["PATH"], I see (newlines added by me, for clarity):

/tmp/build_c5e5adc0/vendor/bundle/ruby/3.1.0/bin:
/tmp/build_c5e5adc0/bin:
/tmp/build_c5e5adc0/vendor/bundle/bin:
/tmp/build_c5e5adc0/vendor/ruby-3.1.4/bin:
/tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/vendor/ruby/heroku-22/bin/:
/tmp/build_c5e5adc0/.heroku/node/bin:
/tmp/build_c5e5adc0/.heroku/yarn/bin:
/usr/local/bin:
/usr/bin:
/bin:
/tmp/build_c5e5adc0/node_modules/.bin

So the vendor/bundle/bin subdirectory is in the `$PATH, and should be findable...

Lastly, if I capture which hanami as part of this step, I get back:

/tmp/build_4368f694/vendor/bundle/ruby/3.1.0/bin/hanami

Which looks good!

So to conclude, I really don't know why this isn't working 😬

from hanami.

jodosha avatar jodosha commented on June 2, 2024

@timriley, can you tell which bundle bin Hanami CLI finds?

https://github.com/hanami/cli/blob/ca0e692ca1d7b4fb1afd8f24f82dce382ac05f47/lib/hanami/cli/bundler.rb#L136

Maybe Hanami CLI doesn't match the right Heroku executable:

/tmp/build_4368f694/vendor/bundle/ruby/3.1.0/bin/hanami

from hanami.

timriley avatar timriley commented on June 2, 2024

@jodosha Looks like it's consistent:

remote:        hanami: /tmp/build_74a332f0/vendor/bundle/ruby/3.1.0/bin/hanami
remote:        bundle: /tmp/build_74a332f0/vendor/bundle/ruby/3.1.0/bin/bundle

from hanami.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.