Luka Vlaskalic
Luka Vlaskalic

Reputation: 465

Ruby/Rails is contradicting itself, what should I do?

I am trying to learn Ruby on Rails, I have installed Ruby, ruby -v gives ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin18] and I have installed rails using gem install rails however when I run rails -v I get the following dialogue.

Rails is not currently installed on this system. To get the latest version, simply type:

    $ sudo gem install rails

You can then rerun your "rails" command.

I then do as the prompt asks and run sudo gem install rails (inputting my pw) which gives me;

Successfully installed rails-6.0.2.2
Parsing documentation for rails-6.0.2.2
Done installing documentation for rails after 0 seconds
1 gem installed

to check that Rails has installed properly I run rails -v again, and again I get;

Rails is not currently installed on this system. To get the latest version, simply type:

    $ sudo gem install rails

You can then rerun your "rails" command.

Am I missing something very obvious?

Upvotes: 0

Views: 48

Answers (1)

Patrick C
Patrick C

Reputation: 186

The best way to manage your Ruby/Rails environment is to use a tool like rvm and never use the system Ruby/Rails. Changing Ruby/Rails versions globally for all your apps will most likely break them, so you want each app to be locked to a specific Ruby/Rails version and only upgrade each one manually.

  1. Start by installing RVM locally for your user:
\curl -sSL https://get.rvm.io | bash -s stable --ruby
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bash_profile
source $HOME/.rvm/scripts/rvm
  1. Make a directory for your app.
mkdir my_rails_app && cd my_rails_app
  1. Make a local .ruby-version and .ruby-gemset for each project:
echo 2.6.5 > .ruby-version
echo my_rails_app > .ruby-gemset
rvm reload
  1. Then install rails only for the specific gemset "my_rails_app" (I usually give each app its own gemset).
gem install rails
rails new my_rails_app .

Upvotes: 1

Related Questions