2

I am literally new to Ruby. This is my first day and naturally it starts with installing it on my machine.

I am using Mac os El Capitan. It already shipped with ruby so I just updated it, installed the rvm & gem and tried to install rails using the following commands:

rvm get head
sudo gem update --system
sudo gem install rails

The last command (installing rails) is giving me the following error:

ERROR:  While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/rackup

Any idea what is it and how to fix it? I have found couple of questions on stackoverflow with similar, but not the same error, but I didn't even understand the answers. Again I am really a novice here.

Edit:

I keep getting comments that this is a duplicate question. However it is not giving me the same error as in the other questions. Please if anyone knows what is this error about, or whether it's really the same error, explain why, otherwise I don't see a reason why you should mark the question as duplicate without understanding the error message.

Lamar
  • 1,761
  • 4
  • 24
  • 50
  • Possible duplicate of [ERROR: While executing gem ... (Errno::EPERM) Operation not permitted](http://stackoverflow.com/questions/32891965/error-while-executing-gem-errnoeperm-operation-not-permitted). Please remember that Stack Overflow has search functionality. – MarsAtomic May 29 '16 at 20:36
  • I found both, but they are not the very same errors. I could't tell actually. Anyway I tried both fixes but it gave me "illegal option -- n" error. – Lamar May 29 '16 at 20:45
  • Eh? Post the full "illegal option" error. – MarsAtomic May 29 '16 at 20:46
  • Above is all that I got. – Lamar May 29 '16 at 20:48
  • I don't even see where you're using the command line, much less a `--n` option... Let me see what I can dig up. – MarsAtomic May 29 '16 at 21:28
  • I didn't include it because it's not part of the steps that produced the problem. I did use the following command: sudo install -n /usr/local/bin rails and got "install: illegal option -- n". But again this is not how the books are telling me to install it and I find it irrelevant to my question, unless someone explains to me otherwise. – Lamar May 30 '16 at 16:41

1 Answers1

1

My advice is to install rbenv. Later you can easily switch between ruby versions

brew install rbenv ruby-build

# Add rbenv to bash so that it loads every time you open a terminal
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile

# Install Ruby
rbenv install 2.3.1
rbenv global 2.3.1
ruby -v

And then install rails

gem install rails -v 4.2.6
rbenv rehash
rails -v
# Rails 4.2.6
RubyDigger19
  • 835
  • 13
  • 38
  • Great! your way works. Thanks a lot. Yet I don't know what's the difference? Is it specifying ruby and rails versions or is it the rbenv? Also what's the difference between rbenv and rvm? – Lamar May 30 '16 at 21:16
  • Well I don't know really differences but I also had this problem. Rvm not worked for me also so I installed rbenv via homebrew( which installs the stuff you need :) ) . Also rbenv is much easier for use and manage ruby versions. – RubyDigger19 May 30 '16 at 21:26
  • Thanks again. I appreciate that you positively tried to show me how to fix the problem rather than pointing to irrelevant posts, or claiming it is a duplicate question. – Lamar May 30 '16 at 21:34
  • No problem. Recently I was just like you now, so I'm glade I helped you. good luck programming RoR :) – RubyDigger19 May 30 '16 at 21:36