I'm trying to install my app to heroku. But I'm having an issue with a gem. Its a private gem and we don't have a private gem server setup, so I've cloned the gem locally as a submodule inside the app.
When I push to heroku I get this error:
! Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
Detected buildpacks: Ruby,Node.js
See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.5.1
-----> Installing dependencies using bundler 1.15.2
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.16.2). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.
The gemspecs for path gems changed
Bundler Output: Warning: the running version of Bundler (1.15.2) is older than the version that created the lockfile (1.16.2). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.
The gemspecs for path gems changed
!
! Failed to install gems via Bundler.
!
! Push rejected, failed to compile Ruby app.
! Push failed
When I removed the locally install gem it all worked fine.
So strong hunch is that bundler 1.15.2 handles local gems differently and it's causing a conflict.
In my Gemfile, not inside any group, I have gem 'portkey', path: './gems/portkey/'
At the top of my Gemfile.lock I have
PATH
remote: gems/portkey
specs:
portkey (0.1.10)
bitly
omniauth-google-oauth2 (~> 0.5.3)
rails (~> 5.2.1)
rebrandly
shortener (~> 0.8.0)
will_paginate
Heroku doesn't support bundler 1.16.2 yet afaik
I'm using rails 5/ruby-2.5 and I don't seem be able to downgrade bundler to 1.15.2 and generate an older version of the lockfile
I can't easily make this gem accessible any other way.
I'm stumped how I can make the install of this gem work, and suggestions would be greatly appreciated.
Had a similar issue, solved by upgrading to Bundler 2.0.1 (which is now supported by Heroku).
For 1.x version they still use 1.15.2 though.
Related
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
I am trying to deploy a simple Ruby on Rails web app using Heroku. When I attempt to deploy the web app, I get a bundler error saying the correct platform is not within the Gemfile.lock
Here is the build log:
-----> Building on the Heroku-20 stack
! Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
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-3.0.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
Your bundle only supports platforms ["aarch64-linux"] but your local platform is
x86_64-linux. Add the current platform to the lockfile with `bundle lock
--add-platform x86_64-linux` and try again.
Bundler Output: Your bundle only supports platforms ["aarch64-linux"] but your local platform is
x86_64-linux. Add the current platform to the lockfile with `bundle lock
--add-platform x86_64-linux` and try again.
!
! Failed to install gems via Bundler.
!
! Push rejected, failed to compile Ruby app.
! Push failed
I attempted to add the platform to the Gemfile.lock file but was hit with this dependency error:
matt#matt-desktop:~/projects/auto-bags$ bundle lock --add-platform x86_64-linux
Fetching gem metadata from https://rubygems.org/............
Resolving dependencies.........
Bundler found conflicting requirements for the Ruby version:
In Gemfile:
Ruby (~> 3.0.0.0)
capybara (>= 3.26) was resolved to 3.35.3, which depends on
nokogiri (~> 1.8) was resolved to 1.11.1, which depends on
Ruby (< 3.1.dev, >= 2.5)
I have not found a successful fix online. There were some suggestions to remove the Gemfile.lock file but that broke my local server which makes sense. I'll be happy to provide more information if necessary.
running the following command should fix your issue.
bundle lock --add-platform x86_64-linux
bundle install
git add . ; git commit -m fix
Reference
https://www.moncefbelyamani.com/understanding-the-gemfile-lock-file/#platforms
https://bundler.io/man/gemfile.5.html#PLATFORMS
https://github.com/rubygems/rubygems/issues/4269#issuecomment-758564690
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.
I'm pushing code on Heroku as usual.
But this message appear :
Warning: the running version of Bundler (1.15.2) is older than the
version that created the lockfile (1.16.1). We suggest you upgrade to
the latest version of Bundler by running gem install bundler.
So I run:
heroku run gem install bundler
Running gem install bundler on ⬢ myapp... up, run.3401
(Standard-1X)
Fetching: bundler-1.16.1.gem (100%)
Successfully installed bundler-1.16.1
Parsing documentation for bundler-1.16.1
Installing ri documentation for bundler-1.16.1
Done installing documentation for bundler after 11 seconds
1 gem installed
But when I retry to push code:
heroku run bundle install
Running bundle install on ⬢ myapp... up, run.9532 (Standard-1X)
Warning: the running version of Bundler (1.15.2) is older than the
version that created the lockfile (1.16.1). We suggest you upgrade to
the latest version of Bundler by running gem install bundler.
In the gem Gemfile.lock I got:
BUNDLED WITH
1.16.1
I don't understand why this bundler release doesn't want to be install on Heroku.
Bundler 1.15.2 is the version that is pre-installed on Heroku dynos. Changing Bundler to 1.16.1 on your machine doesn't change the version installed on Heroku.
Furthermore, you cannot update Bundler on Heroku by running bundle install. And even if that was possible it would take effect on the next run of Bundler - and usually, you only bundle once on a Heroku dyno.
My advice is: It is just a warning, just ignore it and let's hope that Heroku updates Bundler more ofter in the future.
You also want to make sure you're using a standard Heroku buildpack for this.
When I attempted to upgrade my app from Cedar to Heroku-20, it kept failing with this same bundler error. But, eventually, I remembered that I had install a custom buildback and that turned out to be the source of the incorrect bundler version.
Once I switched back to the default Heroku Ruby buildpack, I was finally able to deploy without any issues.
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