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

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

Related

Conflict between ruby version in gemfile and local ruby

I'm having trouble running running an app because of its ruby version. But from everything I can tell, I have the right version of ruby running. What am I doing wrong?
user#computer project % rails s
Your Ruby version is 2.6.3, but your Gemfile specified 2.7.1
user#computer project % rbenv local
2.7.1
user#computer project % ruby -v
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]
user#computer project % which ruby
/Users/user/.rbenv/shims/ruby
(I've also tried switching the ruby version in the gemfile from 2.7.1 to 2.6.3, but when I do, it gives me the opposite message (that I have 2.6.3 specified but I'm running 2.7.1).
Update: Turns out this problem is specific to running in zsh. Using bash works fine.
rails invokes the global binary. You can try:
bundle exec rails instead, or
gem install rails in your Ruby 2.7.1 environment.

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.

Just installed Rails 6 and am getting an odd error

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

Ruby version is not updated in the applications enviroment

I updated ruby to 2.2.2 with rbenv
$ruby -v
$ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin13]
After I created a new rails application by rails new xxx and then rails server,
Why the ruby version is still 2.0.0. How to fix this? Thanks
You need to freeze Ruby version in two files:
.ruby-version
2.2.2
This file created automatically if you type rbenv local 2.2.2. The other file require to lock specific Ruby version is the following:
Gemfile
ruby '2.2.2'
...
Afterwards bundle install will fail in case of different Ruby version set as active.

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?

Resources