Cannot install RVM . Permission denied in /usr/local/rvm

前端 未结 12 2731
旧时难觅i
旧时难觅i 2020-12-25 13:20

Based on my previous thread : RVM installed by Ruby not working? where i had installed RVM using the root user, I then had to entirely remove the RVM install and now i am in

12条回答
  •  悲&欢浪女
    2020-12-25 14:04

    I had the original issue reported in this question, "mkdir: cannot create directory `/usr/local/rvm': Permission denied" when trying to install rvm.

    This is my scenario and how I solved it - maybe this will help others with this same issue.

    I have Ubuntu 11.04 installed on a laptop, I only have 1 user, the one I created at install time, named nathan. When I would try to install rvm as nathan, the rvm installer saw me as root and kept trying to install rvm globally, but since I wasn't really root, it couldn't get access to create directories in /usr/local/rvm.

    I'm far from an expert with Ubuntu, so I'm sure there are easier/better ways to accomplish the things I did (and I would love to learn about them), but this worked for me:

    1. I created a new user called rubydev
    2. I logged in as rubydev, opened a terminal and typed:

      rubydev~$ bash < <(curl -B http://rvm.beginrescueend.com/install/rvm)
      
    3. rvm installed correctly and I logged out of rubydev

    4. Signed back in as nathan, opened a terminal and typed "su" (you could do all this with sudo, I am lazy)
    5. After successfully getting root, I typed the following commands:

      root: /home/nathan# cp -R /home/rubydev/.rvm .
      
      root: /home/nathan# chown -R nathan .rvm
      
      root: /home/nathan# chgrp -R nathan .rvm
      
      root: /home/nathan# exit
      
      nathan~$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
      
      nathan~$ echo 'export rvm_path="/home/nathan/.rvm"' > ~/.rvmrc
      
      nathan~$ source .bash_profile
      
    6. At this point, rvm was correctly installed under my home directory. To verify I typed:

      nathan~$ type rvm | head -1
      rvm is a function (if you don't get this response, something else is wrong)
      
    7. Read the notes and installed any dependencies

      nathan~$ rvm notes
      
    8. I installed some rubies

      nathan~$ rvm install 1.8.7-head
      nathan~$ rvm install 1.9.2-head
      
    9. Verified install

          nathan~$ rvm list
      
          rvm rubies
              ruby-1.8.7-head [x86_64]
              ruby-1.9.2-head [x86_64]
      
          nathan~$ rvm use 1.9.2
          using /home/nathan/.rvm/gems/ruby-1.9.2-head
      
          nathan~$ rvm list
      
          rvm rubies
             ruby-1.8.7-head [x86_x64]
          => ruby-1.9.2-head [x86_x64]
      
    10. Finally, I edited the preferences on the terminal itself to ensure the "Run command as as login shell" under the "Title and Command" tab was checked. It seems .bash_profile isn't otherwise processed.

    11. I removed the rubydev user I created in step 1.

    With all of that, I have a working rvm under Ubuntu 11.04 using my preferred username.

提交回复
热议问题