At the top of my Gemfile, I have the following two lines:
source 'https://rubygems.org'
ruby '2.5.0'
However, run I run git push heroku master, I get the following message:
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.3.4
remote: -----> Installing dependencies using bundler 1.15.2
Heroku doesn't let me specify ruby 2.5.0.
How can I go about telling Heroku that I want to use ruby 2.5.0?
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'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.
I'm trying to run a Rails app on Ruby 2.7.1 on Heroku. Everything worked fine, then I changed something in my Gemfile to use Ruby 2.7's numbered parameters, and now the deploy fails with this error message:
remote: -----> Build succeeded!
remote: -----> Ruby app detected
remote: -----> Installing bundler 2.0.2
remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
remote: -----> Compiling Ruby/Rails
remote:
remote: !
remote: ! There was an error parsing your Gemfile, we cannot continue
remote: !
remote: ! [!] There was an error parsing `Gemfile`: Undefined local variable or method `_1' for Gemfile. Bundler cannot continue.
remote: !
remote: ! # from /tmp/build_6681cf5c/Gemfile:22
remote: ! # -------------------------------------------
remote: ! # dependencies.any? { _1.name == gem_name }
remote: ! # -------------------------------------------
remote: ! . Bundler cannot continue.
It works fine locally and I've been using the same code in a few other Rails apps and deployment was never a problem.
Due to the error Undefined local variable or method '_1' for Gemfile. I assume a Ruby version < 2.7 is used when running bundle install.
The app itself runs fine on Ruby 2.7.1 though:
$ heroku run "ruby -v"
Running ruby -v on ⬢ myapp... up, run.7979 (Free)
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
There are a few other similar questions here on SO, but they all deal with Heroku not respecting the Ruby version set in Gemfile or .ruby-version, which is not the problem for me, just during bundle install it seems to use a different Ruby version for some reason...
Is there any way to debug this further, or force Ruby 2.7 even during bundle install on deployment?
I am trying to push a rails 5 app to Heroku and I believe that I followed the instructions on the Heroku page:
https://devcenter.heroku.com/articles/ruby-versions
$ ruby --version
ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]
$ cat Gemfile
.....
ruby "2.3.1"
$ heroku run bash
$ env | grep PATH
PATH=/app/bin:/usr/local/bin:/usr/bin:/bin
$ git push heroku master
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.2.4
which terminates with the error:
remote: -----> Preparing app for Rails asset pipeline
remote: Running: rake assets:precompile
remote: rake aborted!
remote: NoMethodError: undefined method `symbolize_keys' for # <String:0x007fac0655feb0>
remote: /tmp/build_39bfaebc9acd5a6bcb91a69f2b13c171/vendor/bundle/ruby/2.2.0/gems /railties-5.0.0.1/lib/rails/application.rb:393:in `secrets'
Which I guess it is because it is using 2.2 and not 2.3.
The version in /bin is 1.9.3 so in case it would not find any, it should use 1.9.3 and not 2.2.4.
The error message above was fixed with the help of spickermann. Removing the secret.yml file from git tracking allowed the app to be deployed without errors.
Still, the wrong Ruby version persists and Heroku even returns a warning at the end:
remote: ###### WARNING:
remote: You have not declared a Ruby version in your Gemfile.
remote: To set your Ruby version add this line to your Gemfile:
remote: ruby '2.2.4'
remote: # See https://devcenter.heroku.com/articles/ruby- versions for more information.
Any advice about what else can be done?
Thank you!
Your deployment fails because your config/secret.yml is not in the expected format. It expects a nested hash like this in production environment:
production:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
Your config/secrets.yml returns a string for the key production. Therefore the deployment fails and you were never able to deploy you new version.
I have added Ruby 2.1.5 to my gem file, and after that failed, also added e ruby version to the config vars.
But when deploying, it continues to show that we are using 2.0.0
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.0.0
remote: -----> Installing dependencies using 1.7.12
Then it fails because of modware:
remote: Gem::InstallError: modware requires Ruby version >= 2.1.0.
Here is my Gemfile:
Gemfile
source 'https://rubygems.org'
ruby "2.1.5"
Type this in your terminal :
heroku config -s | grep PATH
Then, if you get something like
PATH=vendor/bundle/ruby/2.1.5/bin:/usr/local/bin:/usr/bin:/bin
You need to add "bin:" before "vendor" in the PATH, with this command line :
heroku config:set PATH=bin:vendor/bundle/ruby/2.1.5/bin:/usr/local/bin:/usr/bin:/bin
Source : https://devcenter.heroku.com/articles/ruby-versions#troubleshooting