I'm trying to deploy my Rails6 app to Heroku and Heroku is using a different Ruby version than my project
peter.walker#MACSB-RJ2CLKF45C friends % heroku run rake db:migrate
Running rake db:migrate on ⬢ ptw-friends... up, run.3636 (Free)
Your Ruby version is 2.7.0, but your Gemfile specified 2.7.4
My Gemfile and Gemfile.lock both have
ruby '2.7.4'
RUBY VERSION
ruby 2.7.4p191
But when I run $ heroku run "ruby -v" I get
peter.walker#MACSB-RJ2CLKF45C friends % heroku run "ruby -v"
Running ruby -v on ⬢ ptw-friends... up, run.1142 (Free)
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux-gnu]
Any advise on how I can change the Heroku Ruby version?
After removing yarn.lock, node_modules, and Gemfile.lock and re-running yarn instal, bundle install, pushing to heroku it worked
Related
I'm trying to deploy my Rails6 app to Heroku
I'm able to successfully build after pushing my app to Heroku but the app immediately crashes.
I just added
group :production do
gem 'pg', '~> 1.2', '>= 1.2.3'
end
to my Gemfile after developing in sqlite so I figured I'd need to migrate which brings me to my error
peter.walker#MACSB-RJ2CLKF45C friends % heroku run rake db:migrate
Running rake db:migrate on ⬢ ptw-friends... up, run.5761 (Free)
Your Ruby version is 2.7.0, but your Gemfile specified 2.6.10
I'm not sure why I'm being told my Ruby version is 2.7.0.
My Gemfile has ruby '2.6.10',
my Gemfile.lock has RUBY VERSION ruby 2.6.10p210,
and my $ ruby -v returns ruby 2.6.10p210 (2022-04-12 revision 67958) [arm64-darwin21]
Could it be from adding
"scripts": {
"start": "rails s"
},
to my package.json?
Could I not be specifying the Ruby version in Procfile?
The full error is here along with my repo
https://github.com/petertimwalker/friends/issues/1
Heroku doesn't support all Ruby versions. When a Ruby version reaches end-of-life and is not maintained anymore then Heroku stops supporting it.
Ruby 2.6 reached end-of-life December last year.
Therefore you need to update your application and your local environment to at least 2.7 when you still want to be able to deploy on Heroku.
Please see the list of Ruby versions supported by Heroku.
install ruby version 2.6.10 and use that version in local
if you using rvm check your current version with rvm list and
install ruby 2.6.10 with rvm install 2.6.10
then use command rvm use 2.6.10
Every time I try to run "heroku run rails db:migrate" I get this error "Your Ruby version is 2.7.0, but your Gemfile specified 2.6.6". I've changed the ruby version in the Gemfile from 2.6.6 to 2.7.0 and When I run bundle install I get the error "Your Ruby version is 2.6.6, but your Gemfile specified 2.7.0"
Checking my ruby version "ruby --version" I get ruby 2.6.6p146 (2020-03-31 revision 67876)
How can I either have Heroku recognize the 2.6.6 version or update it to 2.7.0 ?
Thank you
Try run:
heroku run rails db:drop
heroku run rails db:create
heroku run rails db:migrate
ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]
cat Gemfile.lock | grep -A 2 RUBY
RUBY VERSION
ruby 2.7.1p83
bundle platform --ruby
ruby 2.7.1p83
sudo rake db:create
Your Ruby version is 2.7.0, but your Gemfile specified 2.7.1
I can't see what is the problem here. This is a fresh installation of Ubuntu it's 20.04 and I was trying to set up a ruby on rails env for the first time.
Different users can have different versions of ruby installed.
When you run ruby -v you will see the version of ruby in your user environment.
When you run sudo rake ... (or sudo anything) you will use the version of ruby in the super user’s environment.
In short, don’t use sudo. bundle exec rake db:migrate Will ensure you’re using the same version of ruby as you see in the output of bundle platform —ruby
To help understand what’s happening when you try to check the version, try sudo ruby -v That should be where v2.7.0 comes from
I am trying to install rails, by following instructions that I found online and also instructions that I found in the book Beginning Rails 4. I thought I had installed everything, and managed to create a new Rails application. Here are my commands:
rails new blog
rake db:create
Then I get an error:
rake aborted!
LoadError: cannot load such file -- sqlite3/sqlite3_native
I've been reading for about two hours trying to figure out what this is. I think it might have something to do with multiple ruby installations and/or location of gems.
$ which ruby
/usr/bin/ruby
$ which gem
/usr/bin/gem
$ which rake
/usr/local/bin/rake
$ which sqlite3
~/anaconda/bin/sqlite3
$ echo $PATH
/home/user/anaconda/bin:/home/user/anaconda/bin:/home/user/anaconda/bin:/home/user/anaconda/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/home/user/.local/bin:/home/user/bin
Any idea how I can solve this issue?
Here is some additional info:
rails --version
Warning: You're using Rubygems 2.0.14 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better startup performance.
Rails 4.2.4
ruby --version
ruby 2.0.0p598 (2014-11-13) [x86_64-linux]
sqlite3 --version
3.8.4.1 2014-03-11 15:27:36 018d317b1257ce68a92908b05c9c7cf1494050d0
There were so many questions on this topic but none could help me to solve the issue.I am new to ROR. I am trying to run following command
rake db:create
it throws error though I have ruby 2.2.1 installed and by default it is pointed to
Your Ruby version is 1.9.3, but your Gemfile specified 2.2.1
I tried running following commands to check which ruby version is being used
ubuntu#myserver:~/workspace/railpro/appraiser-events/bin$ ruby -v
ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-linux]
ubuntu#myserver:~/workspace/railpro/appraiser-events/bin$ which ruby
/home/ubuntu/.rvm/rubies/ruby-2.2.1/bin/ruby
ubuntu#myserver:~/workspace/railpro/appraiser-events/bin$ echo $PATH
/home/ubuntu/.rvm/gems/ruby-2.2.1/bin:/home/ubuntu/.rvm/gems/ruby- 2.2.1#global/bin:/home/ubuntu/.rvm/rubies/ruby- 2.2.1/bin:/home/ubuntu/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/ usr/bin:/sbin:/bin:/usr/games:/usr/local/games
This shows that i am using ruby 2.2.1 and in my Gemfile also it points to 2.2.1 but when I use rake db:create it throws this error.
When I tried to change the Gemfile to point to 1.9.3 it said the reverse
Your Ruby version is 2.2.1, but your Gemfile specified 1.9.3
I tried putting a .ruby-version file in the top level directory and mentioned the 2.2.1 inside that but it didn't work
Run with bundle exec:
bundle exec rake db:create
This will ensure that the rake command is executed in the context of the current bundle.