Search code examples
ruby-on-railsrubymacosrvmmacos-sierra

Having trouble setting up a local environment on Mac for Ruby/Rail development


I'm following a tutorial to set up my local development environment on OSX 10.12.4 (Sierra).

I've installed rvm and when I type 'rvm list' it shows that ruby-2.4.1 is the current and default version:

=* ruby-2.4.1 [ x86_64 ]

However, when I type 'ruby -v' it shows:

ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]

I think this is preventing me from doing the rest of what I need to do. Because when I type 'gem update', I get this message:

ERROR:  Error installing nokogiri:
nokogiri requires Ruby version >= 2.1.0.

On the RVM site, it recommends switching versions with this command:

rvm --default use <version number>

It give me this:

RVM is not a function, selecting rubies with 'rvm use ...' will not work.

In case it helps, this is my complete .bash_profile:

source ~/.profile
export PS1="$ "
export PATH=/usr/local/bin:$PATH
export PATH=/usr/local/php5/bin:$PATH
export PATH=$HOME/.composer/vendor/bin:$PATH

Any idea what I need to do to fix this? Thanks!


Solution

  • Looks like it is picking up the Ruby version that comes preloaded with an Apple computer (i.e., version 2.0) and not the ruby version you are using with RVM. My .bash_profile contains this line and it works for me.

    [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"