Just installed Rails 6 and am getting an odd error - ruby-on-rails

installed ruby 2.6.4 and rails 6.0.0 using rbenv on a mac running Mojave 10.14.6 to evaluate upgrading a legacy app. rails -v returns `
Rails 6 requires Ruby 2.5.0 or newer.
You're running
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
Please upgrade to Ruby 2.5.0 or newer to continue.`
however ruby -v returns ruby 2.6.4p104 (2019-08-28 revision 67798) [x86_64-darwin18]
I currently have the following versions of ruby installed
ruby-2.2.6
ruby-2.3.8
* ruby-2.6.4
which ruby returns
/Users/jerryzornes/.rubies/ruby-2.6.4/bin/ruby
and my bundler version is 2.0.2
So I have no idea as to what's going on.

In the root folder of your Rails app make sure you have a file named .ruby-version that contains the text ruby-2.6.4. This is used by rbenv to make sure the right version of ruby is used.
You can also run which ruby to see where it is loading ruby from. If this isn't running from /Users/jerryzornes/.rubies/..., then the issue is with your rbenv install. I would check you path variable to make sure it has the rbenv shims in place, ie looks like ~/.rbenv/shims:/usr/local/bin:/usr/bin:/bin

Related

Project selected ruby version does not match ruby -v using asdf-ruby

I switched to a new computer and set up a whole development environment from start. One of the changes was trying to use asdf instead of rvm. Sadly when trying to run rails s or rails c on one of the projects I have im running into:
Your Ruby version is 2.7.1, but your Gemfile specified 2.6.3
2.6.3 is the version specified by Gemfile indeed, the same is in .tool-versions file and .ruby-version.
My lack of understanding comes from me not having ruby 2.7.1.
asdf list =>
ruby
2.6.3
ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-linux]
which ruby
/home/kkp/.asdf/shims/ruby
Any help would be appreciated.
Just as I posted I suddenly remembered to run
gem install bundler
and off we go

Trying to install Rails 6 using RVM

I have installed RVM successfully on my Mac and using it I have installed Ruby 2.6.3. I have set my current and default version of Ruby to be 2.6.3. Everything seems to be fine because when I enter ruby -v into the terminal it tells me I'm using ruby 2.6.3.
My problem comes when I try to install Rails 6, I'm entering:
gem install rails --version=6.0.0 -no-ri -no-rdoc
It seems to install correctly however when I try to confirm with:
rails -v
I get:
Rails 6 requires Ruby 2.5.0 or newer.
You're running
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64- darwin18]
Please upgrade to Ruby 2.5.0 or newer to continue.
Why am I getting this message when my ruby -v command is telling me that I am using ruby 2.6.3
Any help would be very welcome.
You're running ruby 2.3.7p456. You need to set your local ruby version to 2.6.3.
Try which ruby to see which ruby version is loaded.
rvm install 2.6.3
rvm use 2.6.3
You can then see which ruby is running with which ruby.
See the basics on the rvm docs
As an aside, I also recommend recommend rbenv over rvm; however, you can only have one installed. If you have both installed, you're going to have a bad time.
To make sure you do not have both installed try which rbenv, and that should return rbenv not found
Please edit your original question with the output of the following commands:
which -a ruby
echo $PATH (That will help debug if your $PATH is set up incorrectly.)
which rbenv
ls (in your project directory)
i also had the similar problem which i resolved by uninstalling rvm completely and then installing rbenv.

Rails using a different version of Ruby from the rest of the sytem?

My installation of Rails seems to be using a different version of Ruby from the version of Ruby on the rest of my system:
$ rails --version
Rails 5 requires Ruby 2.2.2 or newer.
You're running
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]
Please upgrade to Ruby 2.2.2 or newer to continue.
$ ruby --version
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
Why is this? I installed Rails with sudo gem install rails. I'm on OSX and don't remember how I installed Ruby.
Mac OSX comes ruby installed as default. If you need more late versions of ruby, you need to follow this guide: http://railsapps.github.io/installrubyonrails-mac.html

Rails app didn't see ruby version that was chosen by rbenv(Mac OS 10.9.5).

I installed Homebrew, and after that installed Rbenv control ruby versions. Like in this site: http://misheska.com/blog/2013/06/15/using-rbenv-to-manage-multiple-versions-of-ruby/#install-ruby-200---mac-os-x.
And installed needed ruby version(1.9.3p547), and set as global. When I type in terminal ruby -v and get:
ruby 1.9.3p547 (2014-05-14 revision 45962) [x86_64-darwin13.4.0]
When I go in Terminal to specific rails project, that I cloned before. And type bundle install and I get:
Your Ruby version is 2.0.0, but your Gemfile specified 1.9.3
And I just was shoked, and think maybe i do something wrong! And type in terminal again ruby -v and get:
ruby 1.9.3p547 (2014-05-14 revision 45962) [x86_64-darwin13.4.0]
Can someone explain what I'm doing wrong?

In RubyMine: "Your Ruby version is 2.0.0, but your Gemfile specified 1.9.3 (Bundler::RubyVersionMismatch)"

I've created a ruby on rails project with rails composer. I can run the project from terminal, but when I open it in RubyMine, it's showing this error
Your Ruby version is 2.0.0, but your Gemfile specified 1.9.3 (Bundler::RubyVersionMismatch)
I have checked my ruby version using 'ruby -v' and it says
ruby 1.9.3p0 (2011-10-30 revision 33570) [i686-linux]
My rails version using 'rails -v'
Rails 3.2.13
However, when I open the project in RubyMine(version: 5.4.1) it says
/path/to/my/.rvm/gems/ruby-2.0.0-p195#global/gems/bundler-1.3.5/lib/bundler/definition.rb:361:in `validate_ruby!': Your Ruby version is 2.0.0, but your Gemfile specified 1.9.3 (Bundler::RubyVersionMismatch)
The SDK version in RubyMine is showing 'RVM: ruby-2.0.0-p195' and the language level is 1.9
I have checked other threads on this error, but none of them was working in terminal and showing error in RubyMine. How can I solve this?
In RubyMine you can manage multiple SDKs, meaning ruby version and gemset.
Obviously you selected a SDK with ruby-2.0.0-p195.
The language level only defines the syntax higliting and command completion help etc. say the support of the IDE, but not the ruby version used for the project.
So you should select a different SDK (or create it first, but as you use rmv and RubyMine knows rmv, you should see all your SDKs)
If ruby-1.9.3 is your system default, you might install the same version again with rvm to make it available for RubyMine
rvm install ruby-1.9.3
and then select it in RubyMine.

Resources