On all my gem installs I have to do sudo ? So
sudo gem install rails
will work, while only
gem install rails
will not work. How do I remedy it ?
I have rvm installed -
murtaza@murtaza-dev:~$ which rvm /home/murtaza/.rvm/bin/rvm murtaza@murtaza-dev:~$ which gem /home/murtaza/.rvm/rubies/ruby-1.9.3-p194/bin/gem
However I am also getting this warning when I do any operations with gem -
murtaza@murtaza-dev:~$ gem /home/murtaza/.rvm/rubies/ruby-1.9.3-p194/bin/gem:4: warning: Insecure world writable dir /opt in PATH, mode 040777
EDIT
I have reinstalled rvm using curl -L get.rvm.io | bash -s stable --auto
(without sudo).
However still when I try installing gem it gives me the following error -
murtaza@murtaza-dev:~$ gem install rails /home/murtaza/.rvm/rubies/ruby-1.9.3-p194/bin/gem:4: warning: Insecure world writable dir /opt in PATH, mode 040777 ERROR: While executing gem ... (Errno::EACCES) Permission denied - /home/murtaza/.gem/specs
EDIT
I did chown on the whole thing but still getting the error -
murtaza@murtaza-dev:~$ sudo chown murtaza.murtaza -R ~/.rvm/* murtaza@murtaza-dev:~$ gem install rails /home/murtaza/.rvm/rubies/ruby-1.9.3-p194/bin/gem:4: warning: Insecure world writable dir /opt in PATH, mode 040777 ERROR: While executing gem ... (Errno::EACCES) Permission denied - /home/murtaza/.gem/specs
With the --local ( -l ) option, you would perform a local search through your installed gems. To install a gem, use gem install [gem] . Browsing installed gems is done with gem list . For more information about the gem command, see below or head to RubyGems' docs.
The install command installs local or remote gem into a gem repository. For gems with executables ruby installs a wrapper file into the executable directory by default. This can be overridden with the –no-wrappers option.
Use chown
on the whole .rvm
and .gem
directories back to your user. You probably used sudo
before and it screwed up permissions.
sudo chown -R username:group ~/.rvm sudo chown -R username:group ~/.gem
Of course, change username to your username and group to your group
When you install them without sudo, Ruby doesn't know where they get installed to. I can't remember where it installs them by default, probably somewhere like ~/.gems or something. Anyway, you can tell Ruby that's where they're installed by setting the GEM_HOME environment variable.
$ # assuming your gems are stored in ~/.gems $ GEM_HOME="$HOME/.gems" ruby my_program.rb
If that works, then you might put it in your ~/.bashrc (there are a number of possible files this could go in, depending on your system)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With