-1

I recently switched from using the native MacOS version of Ruby to downloading a new version of 3.0.2, as a result on When I Run Rails S command on old projects I get this message:

Please install a version by running one of the following:

asdf install ruby 2.6.3

When I run this command it says that ruby 2.6.3 is already installed. What is going on here? How do I get my Rails project up and running again?

Flux
  • 9,805
  • 5
  • 46
  • 92
CJG
  • 457
  • 2
  • 17
  • I installed 3.0.2 with asdf. – CJG Sep 20 '21 at 13:46
  • Have you tried adding a `.ruby_version` to the root of the directory? The documentation seems to suggest that this would be preferable for "asdf" so that it can automatically switch your ruby version – engineersmnky Sep 20 '21 at 13:50
  • I have not tried that, I'm not sure what you mean however. – CJG Sep 20 '21 at 14:32
  • 1
    Create a file in the root of the rails project called ".ruby_version" with content of "2.6.3". When you navigate to this directory asdf should switch to that ruby version based on the content of that file – engineersmnky Sep 20 '21 at 15:07

1 Answers1

2

You can set up it as your default with

asdf local ruby 3.0.2

(or the version you want).

Once the version is active (check with ruby --version) you should also install bundler:

gem install bundler

for that specific version of ruby.

Also, because you use a local version of ruby, you need to bundle exec it:

bundle exec rails s
rewritten
  • 16,280
  • 2
  • 47
  • 50