1

I am learning to code and trying to make the move for a Rails project from a cloud dev environment to a local one on my Mac with OS Sierra. However, I am having trouble setting up my ruby version and installing rails.

I have installed Homebrew which I used to install rbenv. Using rbenv I have installed ruby 2.4.0 and set it to local and global. I can see it in .rbenv/versions, however when I check my ruby version I still get 2.0.0

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

When I try and install Rails I get the following;

$ gem install rails ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory. 

I am not sure how I utilize the rbenv ruby version in my system to then install rails.

2
  • Did you use sudo at some point? Installing rbenv? ruby 2.4.0? You should NEVER use sudo for that. It looks gem install is trying to install in your system ruby, which you don't want to touch. I can see it in .rbenv/versions,--That isn't a path. What's the part before .rbenv? Commented Jun 3, 2017 at 3:01
  • you can install rbenv and ruby-build using the Homebrew package. -- Did you install ruby-build? Did you do this: rbenv init. In other words, did you follow the instructions exactly? Pasting your whole terminal session into your question would allow people to see where you made a mistake. Commented Jun 3, 2017 at 3:08

1 Answer 1

1

You probably need to add rbenv to your ~/.bash_profile:

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile echo 'eval "$(rbenv init -)"' >> ~/.bash_profile 

Then source it:

source ~/.bash_profile 

Then you can use the rbenv command:

# install a Ruby version: $ rbenv install <version> # show versions currently installed and indicate current version $ rbenv versions # set ruby version for a specific dir $ rbenv local <version> # set ruby version globally $ rbenv global <version> # list all available versions: $ rbenv install -l 

The rbenv command is used to install, switch between versions, etc.

Sign up to request clarification or add additional context in comments.

3 Comments

Did the rbenv install instructions for Mac OSX really leave all that out?
@7stud: Which part of the instructions are you not finding? It's all right here: github.com/rbenv/rbenv
Thanks, I don't think I entered the second echo command and then sourced it. After running both of those it seems to be working.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.