Shopify / bootboot

Dualboot your Ruby app made easy
MIT License
413 stars 35 forks source link

Issues with Heroku deployment #37

Open PhilCoggins opened 4 years ago

PhilCoggins commented 4 years ago

Hello, and thank you for this Bundler plugin.

I am trying to deploy a review app to Heroku with this plugin. It seems to install perfectly fine:

-----> Ruby app detected
-----> Installing bundler 2.0.2
-----> Removing BUNDLED WITH version in the Gemfile.lock
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.6.5
-----> Installing dependencies using bundler 2.0.2
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
       Fetching gem metadata from http://rubygems.org/.
       Resolving dependencies...
       Fetching bootboot 0.1.2
       Installing bootboot 0.1.2
       Using bundler 2.0.2
       Installed plugin bootboot
...
       Bundle complete! 180 Gemfile dependencies, 312 gems now installed.
       Gems in the groups development and test were not installed.
       Bundled gems are installed into `./vendor/bundle`
       Post-install message from i18n:

However, my postdeploy script invokes a rake task and raises the following.

bundler: failed to load command: rake (/app/vendor/bundle/ruby/2.6.0/bin/rake)
Bundler::Dsl::DSLError: 
[!] There was an error parsing `Gemfile`: cannot load such file -- /tmp/build_716f2567b68141f1bd17fe9cd59ff266/.bundle/plugin/gems/bootboot-0.1.2/plugins.rb. Bundler cannot continue.
 #  from /app/Gemfile:275
 #  -------------------------------------------
 #  gem "sassc-rails", "2.1.1"
 >  Plugin.send(:load_plugin, "bootboot") if Plugin.installed?("bootboot")
 #  
 #  -------------------------------------------
  /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.2/lib/bundler/plugin.rb:273:in `load'
  /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.2/lib/bundler/plugin.rb:273:in `load_plugin'
  /app/Gemfile:275:in `eval_gemfile'
  /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.2/lib/bundler/dsl.rb:47:in `instance_eval'
  /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.2/lib/bundler/dsl.rb:47:in `eval_gemfile'
  /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.2/lib/bundler/dsl.rb:12:in `evaluate'
  /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.2/lib/bundler/definition.rb:34:in `build'
  /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.2/lib/bundler.rb:135:in `definition'
  /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.2/lib/bundler.rb:101:in `setup'
  /app/vendor/bundle/ruby/2.6.0/gems/bundler-2.0.2/lib/bundler/setup.rb:20:in `<top (required)>'
  /app/vendor/ruby-2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
  /app/vendor/ruby-2.6.5/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'

I'm still researching a solution on my end but was hoping someone else has experienced this? Happy to provide any info necessary.

Thanks!

PhilCoggins commented 4 years ago

Literally just found https://github.com/rubygems/rubygems/issues/3304

Feel free to close unless there's any suggestions 😊.

systemist commented 4 years ago

We ran into this and added a script to rename the index paths:

sed -i “s|$(pwd)|/app|“ .bundle/plugin/index
systemist commented 4 years ago

By the way, we run that as part of the build process using https://github.com/weibeld/heroku-buildpack-run so that the paths are modified prior to the slug being built.

conarro commented 4 years ago

We ran into this and added a script to rename the index paths:

sed -i “s|$(pwd)|/app|“ .bundle/plugin/index

☝️ worked like a charm! Reposting code snippet without smart quotes:

sed -i "s|$(pwd)|/app|" .bundle/plugin/index

By the way, the heroku-buildpack-run buildpack can be after the Ruby buildpack. Just FYI for future readers.

ashkulz commented 3 years ago

This hit us when using Elastic Beanstalk as well, and added this to ebextensions:

files:
  # Runs before `99_reload_app_server.sh`:
  "/opt/elasticbeanstalk/hooks/appdeploy/enact/98_reconfigure_bundle.sh":
    mode: "000775"
    owner: root
    group: users
    content: |
      #!/usr/bin/env bash

      EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
      EB_SUPPORT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k support_dir)
      EB_APP_USER=$(/opt/elasticbeanstalk/bin/get-config container -k app_user)
      EB_APP_CURRENT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir)

      # Setting up correct environment and ruby version so that bundle can load all gems
      . $EB_SUPPORT_DIR/envvars
      . $EB_SCRIPT_DIR/use-app-ruby.sh

      # Make sure that the .bundle directory is recreated
      if [ -n "$DEPENDENCIES_NEXT" ]; then
        rm -fr $EB_APP_CURRENT_DIR/.bundle
        cd $EB_APP_CURRENT_DIR
        su -s /bin/bash -c "bin/bundle install" $EB_APP_USER
      fi
iamrahulroy commented 3 years ago

By the way, the heroku-buildpack-run buildpack can be after the Ruby buildpack. Just FYI for future readers.

@conarro worked like a charm. Thanks for the tip.

rsanheim commented 2 years ago

Note that the root issue here will break Capistrano deployments using bootboot if you are cleaning up old releases, as the plugin dir will point at a release directory that will eventually get cleaned up.