Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
506 views
in Technique[技术] by (71.8m points)

ruby - how to install gems without sudo

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...