The following steps given by purplespline that I found in this Reddit thread worked for me:
asdf exec gem install rails
then you should be able to run other rails commands.
If Ruby 2.7.2 is already in your .tool-versions
file, you can fix this by simply running
$ bundle
This will install the correct version of the Rails gem and everything should work again.
Try looking at the output of shim-versions
first and you will most likely see that Ruby 2.7.2 is there, but Rails 2.7.2 is not:
$ asdf shim-versions railsruby 2.7.0$ asdf shim-versions rubyruby 2.7.2ruby 2.7.0
You should install bundle gem first
gem install bundle
then you can run bundle
or bundle install
On my end I did not export or add this on my zshrc
. /opt/homebrew/opt/asdf/libexec/asdf.sh
And resource
source ~/.zshrc
I had a similar issue and I just reinstalled rails.
gem install rails
for diagnostics, please check out outputs of
which ruby
and
ruby --version
in the working directory of your project. If it indeed shows you ruby version 2.7.2, then run "gem install rails" or ("bundle install" if gemfile.lock is present) from this working directory again.
One common mistake is not to open new shell after modification of shell config files. Also zsh requires to run "rehash" command if some program is installed at different path, but reopening shell will solve that.
One more tip: check if you have updated .bashrc
or .zshrc
as in the installation guide.
This is what worked for me. I had forgotten to bundle
after updating.
asdf plugin-update rubyasdf install ruby 3.1.4bundle