0

I am trying to make my sass work, it was working fine but its has been a while since i worked on it, so today i wanted sass to watch my folder but that watch command didn't work. So i tired to check ruby version by ruby -version and i got reply

ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16] -e:1:in <main>': undefined local variable or methodrsion' for main:Object (NameError)

But when i do gem install sass it gives me error

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

If i am not wrong, its telling of permission but i am the admin and i tried same command with sudo

localhost
  • 822
  • 2
  • 20
  • 51

1 Answers1

2

The first error you're seeing:

ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16] -e:1:in ': undefined local variable or methodrsion' for main:Object (NameError)

is because you are running the wrong command. If you run ruby -v or ruby --version (note the two hyphens), you will see:

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

The error message you were seeing is because ruby can take the command line flag -e to run code directly from the command line:

$ ruby -e 'puts "Hello world"'
Hello world

So by running ruby -version (note the one hyphen), the ruby interpreter tries to evaluate a variable/method named rsion and throws an error.

As for your actual error of installing gems, this is caused by having enabled rootless system integrity protection (on Max OSx). You can either disable the protection, as outlined in this post, or install ruby via RVM/RBenv to avoid needing sudo permissions for gem installation.

Community
  • 1
  • 1
Tom Lord
  • 27,404
  • 4
  • 50
  • 77
  • Thanks for detailed answer but i still get the error `While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory` – localhost Apr 24 '17 at 10:49
  • What did you try? Did you disable rootless system integrity protection? Did you install ruby via `brew`, or `rvm`, or `rbenv`? Are you running commands with/without `sudo`? – Tom Lord Apr 24 '17 at 11:22
  • I followed the link u [mentioned](http://stackoverflow.com/questions/33015875/operation-not-permitted-usr-bin-update-rubygems) and then tried running `brew install ruby` but it said to unlink sylink, and gave me a command which i did and after that i could run `bew install ruby` nd after that i tried running `gem install sass`. Don't know what is `rvm` or `rbenv` – localhost Apr 24 '17 at 11:42
  • You will need to properly explain your environment, steps taken so far and error messages. What do you mean by "unlink syslink"? I still don't know if you're using `sudo`. What is the output of `which ruby` and `which gem`? Could you [do a little research](https://github.com/rbenv/rbenv#homebrew-on-mac-os-x) and try installing a non-system ruby to avoid this issue? If you're still stuck after having attempted the aforementioned solution thoroughly, please open a new SO question with more information. – Tom Lord Apr 24 '17 at 16:33