Deployment failed on heroku - Ruby on Rails - ruby-on-rails

Im having a problem to deploy a new version of my Ruby on Rails app on heroku.
Heroku build log:
-----> 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.6
Ruby version change detected. Clearing bundler cache.
Old: ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]
New:
-----> Installing dependencies using bundler 2.0.2
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
/usr/bin/env: ‘bash’: Argument list too long
Bundler Output: /usr/bin/env: ‘bash’: Argument list too long
!
! Failed to install gems via Bundler.
!
! Push rejected, failed to compile Ruby app.
! Push failed
Important notes:
I haven't changed the Ruby version;
I've tryed to deploy another Ruby on Rails app, and realize that i'm not able to deploy any Ruby on Rails app.
Anyone with the same problem or any idea to help?

Apparently, the problem is related to a buildpack version released at July, 13. I solved the issue removing this update and specifying the version of Ruby buildpack
$ heroku buildpacks:remove heroku/ruby
and then
$ heroku buildpacks:set https://github.com/heroku/heroku-buildpack-ruby#v217

Related

Deploy to dokku fails because of ruby-buildpack + bundler?

I'm deploying a rails app to dokku. The Versions are:
ruby 3.1.2
bundler 2.3.26 (on my development machine)
gem 3.3.22 (on my development machine)
when i try to deploy to dokku, the heroku ruby buildpack is used, and I get
the following output:
-----> Ruby app detected
-----> Installing bundler 2.2.21
-----> Removing BUNDLED WITH version in the Gemfile.lock
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-3.1.2
-----> Installing dependencies using bundler 2.2.21
Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
[330, #<Thread:0x00007fc0e8b43c90 run>, #<NameError: uninitialized constant Gem::Source
(defined?(#source) && #source) || Gem::Source::Installed.new
^
The crazy thing: I have another app with the same configuration where it works:
-----> Ruby app detected
-----> Installing bundler 2.2.21
-----> Removing BUNDLED WITH version in the Gemfile.lock
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-3.1.2
-----> Installing dependencies using bundler 2.2.21
Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
Fetching gem metadata from https://rubygems.org/.........
My research so far:
This seems to be the problem described here as an issue with bundler 2.3.7 first described in February 2022. But my buildpack uses bundler 2.2.21, so it should not be affected?
The newest ruby-buildpack from heroku seems to have been released in 2021?
Can this be right?
This fixed the problem for one app:
upgrade to ruby 3.1.3 (by editing ruby version in Gemfile and in .ruby-version)
bundle install
bundle lock --add-platform x86_64-linux
After one successfull install I could also roll back to the old ruby version, before upgrade, and successfully install that.
How? Why? What is going on here?
Now another app that used to work stopped working.
Purging the dokku build cache fixed the problem:
dokku repo:purge-cache
correction: this helped for some applications, not for all

Heroku rails deployment issues

I'm trying to push my rails app to deployment via Heroku and whenever i do, i'm getting thrown this error:
Detected buildpacks: Ruby,Node.js
See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
-----> Ruby app detected
-----> Installing bundler 2.1.4
-----> Removing BUNDLED WITH version in the Gemfile.lock
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.7.0
-----> Installing dependencies using bundler 2.1.4
Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
/usr/bin/env: ‘jruby’: No such file or directory
Bundler Output: /usr/bin/env: ‘jruby’: No such file or directory
!
! Failed to install gems via Bundler.
!
! Push rejected, failed to compile Ruby app.
! Push failed
Jruby seems to be playing into this somewhere but i just can't figure it out. Any help would be appreciated.
Answer has been solved as of today. The problem was that somewhere along the line, jruby got included in the list of gem dependencies and snowballed into everything else. In order to fix the problem, I needed to remove all instances of jruby from all folders within the app and it was able to compile properly and deploy.

Ruby 2.6.1 and Bundler 2.0.1 to Heroku : should I write a Procfile?

I'm facing errors I can't handle while trying to deploy an app to Heroku (it's my first time).
# ERROR when I try to `git push heroku master`
remote: -----> Detecting rake tasks
remote:
remote: !
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: ! Activating bundler (2.0.1) failed:
remote: ! Could not find 'bundler' (2.0.1) required by your /tmp/build_e569680f858939ef8f1f8ef3e8902eff/Gemfile.lock.
remote: ! To update to the latest version installed on your system, run `bundle update --bundler`.
remote: ! To install the missing version, run `gem install bundler:2.0.1`
remote: ! Checked in 'GEM_PATH=/tmp/build_e569680f858939ef8f1f8ef3e8902eff/vendor/bundle/ruby/2.6.0', execute `gem env` for more information
remote: !
remote: ! To install the version of bundler this project requires, run `gem install bundler -v '2.0.1'
# heroku buildpacks
=== staging-det-music Buildpack URLs
1. heroku/nodejs
2. heroku/ruby
# Gemfile.lock
RUBY VERSION
ruby 2.6.1p33
BUNDLED WITH
2.0.1
I've tried several solutions, like:
running RAILS_ENV=production bundle exec rake assets:precompile (see here)
adding the RAILS_SERVE_STATIC_FILES key (same)
upgrade Ruby to 2.6.3 (see here, can't find 2.6.3 with rbenv nor rvm)
I believe it might be due to this issue. Am I concerned by this point ?
2) When using binstubs to run a command instead of bundle exec the wrong
version of Bundler can get activated when using Ruby 2.6.x. This bug
is reported to Ruby Core and will be fixed when Ruby 2.6.3 is
released.
In the short term, the workaround is to ensure all commands in the
Procfile and app.json are prefaced with bundle exec. For example:
web: bundle exec bin/rails server -p $PORT -e $RAILS_ENV
worker: bundle exec sidekiq -C config/sidekiq.yml
As a newbie I feel really lost, could anyone help me on this ?
Thanks for your time
SOLUTION: found here removing BUNDLED WITH and the following line in Gemfile.lock
There are known issues with Bundler 2 on Heroku, including this one:
A Gemfile.lock that specifies bundler 2.0.2 does not work with bundler 2.0.1
If you attempt to deploy an app that uses bundler 2.0.2 onto the Heroku platform with bundler 2.0.1 you may get this error:
`find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)
This is due to a bug in the Rubygems bundler version checking code. To avoid this issue, upgrade your Ruby version. It is fixed in 2.5.5+ and 2.6.3+. If you do not update, your Ruby version then every new release of Bundler 2.x will trigger this issue.
Upgrade Ruby to at least version 2.6.3 locally, update the ruby version in your Gemfile, bundle install, commit the changes, and redeploy.

Downgrade/Revert Ruby Version on Heroku

I recently updated my Heroku app from Ruby 2.3.1 to 2.4.0, but I now need to revert back to version 2.3.1.
To Update:
I changed the version in the Gemfile from 2.3.1 to 2.4.0. Everything went fine, but I need to go back to 2.3.1 because of problems specific to me with 2.4.0
To Revert:
I've tried changing the version back to 2.3.1 in my Gemfile (as ruby "2.3.1") but it just throws the bundler error Your Ruby version is 2.4.0, but your Gemfile specified 2.3.1
How do I change my Ruby version back to 2.3.1 on Heroku?
Here is the error on deployment:
ID yupp
-----> heroku-buildpack-rgeo-prep app detected
-----> Removing cached .bundle/config
Writing new .bundle/config
-----> VendorBinaries app detected
-----> Found a .vendor_urls file
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.4.0
###### WARNING:
You have the `.bundle/config` file checked into your repository
It contains local state like the location of the installed bundle
as well as configured git local gems, and other settings that should
not be shared between multiple checkouts of a single repo. Please
remove the `.bundle/` folder from your repo and add it to your `.gitignore` file.
https://devcenter.heroku.com/articles/bundler-configuration
-----> Installing dependencies using bundler 1.13.7
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
Warning: the running version of Bundler (1.13.7) is older than the version that created the lockfile (1.14.3). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
Your Ruby version is 2.4.0, but your Gemfile specified 2.3.1
Bundler Output: Warning: the running version of Bundler (1.13.7) is older than the version that created the lockfile (1.14.3). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
Your Ruby version is 2.4.0, but your Gemfile specified 2.3.1
!
! Failed to install gems via Bundler.
! Detected a mismatch between your Ruby version installed and
! Ruby version specified in Gemfile or Gemfile.lock:
! https://devcenter.heroku.com/articles/ruby-versions#your-ruby-version-is-x-but-your-gemfile-specified-y
!
! Push rejected, failed to compile Ruby app.
! Push failed
I figured it out. Here are the steps
Locally:
Change the Ruby version from 2.4.0 to 2.3.1
Verify the version is 2.3.1 with ruby -v
Run gem install bundler && gem install rails
Run bundle install
Commit the Gemfile and Gemfile.lock and push to Heroku

Impossible to deploy app in heroku - it searches ruby 2.0.0p195

I've deploying our app with rails 3.2.13 and ruby 2.0.0p0 without problems in heroku. However, today suddenly I couldn't deploy it. This is the log, it seems the only difference in our project is the version of ruby 2.0.0, which is trying to be installed:
Counting objects: 42, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (24/24), done.
Writing objects: 100% (25/25), 3.17 KiB, done.
Total 25 (delta 19), reused 0 (delta 0)
-----> Ruby/Rails app detected
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using Bundler version 1.3.2
Ruby version change detected. Clearing bundler cache.
Old: ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-linux]
New: ruby 2.0.0p195 (2013-05-14 revision 40734) [x86_64-linux]
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
Fetching gem metadata from https://rubygems.org/........
Fetching gem metadata from https://rubygems.org/..
Could not find money-rails-0.8.0 in any of the sources
!
! Failed to install gems via Bundler.
!
! Heroku push rejected, failed to compile Ruby/rails app
It seems that it cannot find the money-rails gem (version 0.8.0), but in localhost is working perfectly, and also until yesterday in heroku. I think it's has to be with the new ruby version as it's the only visible change regarding the gems...
Anyone with the same problem?
Thanks in advance!!
You may not have changed anything but it appears the author of money-rails has yanked 0.8.0 and replaced it with 0.8.1. See http://rubygems.org/gems/money-rails for details.
You would have to do a bundle update and commit Gemfile.lock and redeploy and all should be good.

Resources