rails complains that the ruby version in my gemfile and the ruby version i’m using are different even though i’ve matched them up with rvm and removed .ruby-version file I’ve read solutions like reinstalling bundler but none of those tricks helped
Execute ruby -v
in the terminal and make sure that the ruby version you think it’s using is really the correct one. If RVM is not in the path, or not being loaded in new terminals, you might be using the system version, not the one installed by RVM.
Thanks but it returned 3.1.2 and there’s no system ruby installed
Are you using an IDE like Rubymine? Those usually have an SDK option that overrides the system ruby version inside their own terminals.
I’m using atom in development and vi on the server
I would recommend keeping the .ruby-version
file. That’s how version managers know which Ruby version to switch to when you cd
into your project. To avoid having to remember to update the Ruby version in 2 places every time you need to change it, I recommend pointing to the .ruby-version
file in your Gemfile, like this:
ruby File.read(".ruby-version").strip
instead of ruby "3.1.2"
If you recently changed the version in your Gemfile, you’ll need to run bundle install
again. And sometimes you need to cd
out of your Rails app and back in for the version manager to pick up the new version in your updated .ruby-version
.
Also, to help narrow down the issue, try running all commands in the Terminal only. Are you able to run bundle install
and then bin/rails s
from the Terminal? If so, try again with your previous setup. If it fails, then that means the issue is specific to your setup.
Also, what does “vi on the server” mean? Can you post a screenshot of your setup and in which application you’re getting the Ruby version mismatch error?