I put the ruby version 2.3.1 in my gemfile, but Heroku keeps using 2.4.4. How do I make it so Heroku recognizes the version specified in the gemfile?
try to use the heroku console by typing heroku run "ruby -v" and give command to use which version of ruby you want him to
You are probably on the heroku-18 stack which it the current default. Please note that Ruby 2.3.x is not available on this stack.
You have two options:
Update your Ruby version to a more recent version or
Downgrade Heroku to use an older stack.
Given that the maintenance phase for Ruby 2.3.x has ended anyway I would suggest updating our application to use at least Ruby 2.4.4.
Related
The Ruby on Rails Tutorial by Michael Hartl uses a Gemfile without specifying a Ruby version: the ruby keyword is missing in all the applications.
When I deploy to Heroku I receive the following warning:
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.
The tutorial says that "the costs associated with including such an explicit Ruby version number outweigh the (negligible) benefits, so you should ignore this warning for now. The main issue is that keeping your sample app and system in sync with the latest Ruby version can be a huge inconvenience".
I am wondering whether the alternative is to keep the pace with the Ruby version at Heroku (presumably 2.2.4 at present), as the book seems to suggest, or also to specify any Ruby version it suits me. In other words, since I am using Ruby 2.2.1p85 for my application, adding ruby "2.2.1", :patchlevel => "85" would work and make Heroku adjust to this version or rather I am supposed to adjust to Heroku and add as suggested ruby '2.2.4'?
I am using rvm and a specific gemset with a specific Ruby version, for no other reason than trying to use an environment as much close to the tutorial as possible. What is the best practice in a real context? Would you suggest to use the last Ruby version and include it in the Gemfile? Can the Gemfile leave out the Ruby version with no worries?
Please follow the steps to solve
You can check which ruby version is associate with your app by command
heroku run "ruby -v"
It is good to have default version of ruby which is 2.2.4 in order to solve your problem. If your ruby version is older than 2.2.4 then please upgrade it.
after checking/upgrading version You can use the ruby keyword in your app’s Gemfile to specify a particular version of Ruby.
source "https://rubygems.org"
ruby "2.2.4"
You will need to install and update bundler again
$ gem install bundler
$ bundle update
This command:
heroku run rake db:migrate
solved same problem
I have a rails 3 app that was made with 2.0.0-p0 ruby.
Now i would like to update just the ruby to 2.2.2
I changed already the local and global ruby on rbenv to 2.2.2.
There is a way or i have to keep using the 2.0.0-p0 on this app?
You have switched to another version of Ruby and you are probably using a different gemset (probably an empty one). Try running:
bundle install
Note that after switching to a newer version of Ruby, some of your old code might not be compatible, i.e. need debugging.
Hope this help!
after I deploy with capistrano to a new server I see:
/shared/bundle/ruby/1.9.1/gems/
I don't even have ruby 1.9.1 installed on the server. and if i run: ruby -v
it returns 1.9.3
but in all of capisrtano actions i keep seeing 1.9.1
why is that? and how can i stop it?
thanks
Don't worry. Ruby 1.9.1 to 1.9.3 is using that path by default. It doesn't necessarily mean you are using the wrong Ruby.
I just finished a project with rails 2.3.8. Client won't pay for the migration, so I want to keep it as is.
I want to start a new project, which is to build my own homepage. Want to use similar tools but want to go to rails 3.0.
Can these versions co-exist on the same machine? If yes, what do I need to do? Found few pages online, but not sure they are up-to-date (e.g. about rails 3 beta and rvm).
I'm using rvm and running 2.3.9 on ruby 1.8.7 and 3.0.1 on ruby 1.9.2 and it works quite well. I followed http://rvm.beginrescueend.com/rvm/install/ to get rvm installed and then switched to it with:
rvm use 1.9.2
Then you can install Rails 3 on that rvm, set up your new project and switch back to your system ruby and older rails when you need to with:
rvm use system
It's been a really great way of switching back/forth for me.
Make R3 the default for your system. Then freeze rake rails:freeze:edge RELEASE=2.3.8 applications if you need to develop with old versions
With rvm you can also use different gemsets with the same ruby installation:
http://rvm.io/gemsets/basics/
I use Ruby 1.9.x syntax in my Rails 3 app, but after pushing it to Heroku it crashes due to older Ruby version (1.8). How can I control it?
Heroku's current stack, Cedar, uses 1.9.2 by default. Cedar also supports specifying the Ruby version in your Gemfile. Currently, 1.9.2 and 1.9.3 are valid options.
# Gemfile
source "https://rubygems.org"
ruby "1.9.3"
...
More details are available in the Ruby support article: https://devcenter.heroku.com/articles/ruby-support
If you are currently using Aspen or Bamboo, you can switch to 1.9.2 by using the stack:migrate command:
$ heroku stack:migrate bamboo-mri-1.9.2
You cannot automatically migrate to the Cedar stack at this time, but there is a guide on how to do so: https://devcenter.heroku.com/articles/cedar-migration
You can now explicitly specify a Ruby version on Heroku.
Simply setup your Gemfile as so
# Gemfile
source "https://rubygems.org"
ruby "1.9.3"
# Gems go here
I wanted to use the version I already had defined in the .ruby-version file so I ended up creating a buildpack that can be used before heroku-buildpack-ruby that injects the version from the .ruby-version into the Gemfile. It also support versions without patch or aliases.
https://github.com/platanus/heroku-buildpack-ruby-version
This way you can have your version defined only in one place.