How to Install Rvm System Requirements Without Giving Sudo Access for Rvm User

How to install RVM system requirements without giving sudo access for RVM user

This is indeed a new feature of RVM called autolibs, which automatically installs dependencies.

If you have already installed RVM, and it is asking you for your sudo password, you can disable autolibs:

$ rvm autolibs disable
$ rvm requirements # manually install these
$ rvm install ruby

Otherwise, you can install RVM without autolibs with this command:

$ \curl -L https://get.rvm.io | bash -s -- --autolibs=read-fail

I understand the motivation, but find it rather annoying. I do not want to put my sudo password into RVM, nor for that matter Bundle! Please community, stop doing this.

How do I install rvm without root access?

TL;DR

You're missing package dependencies needed to build Ruby.

Packages and Autolibs

The issue your facing is that recent(ish) versions of RVM use a feature called autolibs that attempt to install package dependencies. Of course, you need sudo access to install system packages. You could try installing a Ruby interpreter with:

  • --autolibs=read-only - to avoid the sudo error, but this is unlikely to result in a working binary.
  • --autolibs=rvm_pkg - will use the old rvm pkg install ... to install missing dependencies if they can be provided by RVM, this will take long time and is not guaranteed to work.
  • --autolibs=read-fail - to avoid the sudo error, it will produce list of dependencies to install for the next section.

Ask Root to Install Package Dependencies

In general, the easiest solution is to ask root to install the packages that RVM expects. This should really be your first stop before doing anything else. There may be legitimate reasons to use static binaries or hand-build all your dependencies, but why not do things the easy way if you can?

Try Pre-Built, Static Binaries

If you can't get the necessary packages installed, you can try the rvm list remote command to see if there are any pre-built binaries for your system that can be installed by RVM. If you're missing packages, then you might want to look for a static binary that you can use with the rvm mount command. You might even build the interpreter on another system, and mount it using the appropriate remote URL; see rvm help mount for details.

Impossible to install single-user version of RVM

Indeed, I solved this by uninstalling old versions of RVM: sudo rvm implode and then deleting the file /etc/rvmrc. Once done, I could install the single-user version and everything worked fine!

Sorry Remear, I wanted to edit your answer or complete it via my comment but I could not (comment can only be edited within 5 minutes...at least I upvoted...).

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

RVM is easy to install, but you are making it harder by trying to mix and match installation types. You do NOT need to create a new user. When run, RVM will create a directory in your home directory: ~/.rvm, and install everything inside it. That means you will have all the correct permissions. You do NOT need to be running as root, you do NOT need to use sudo. I'd recommend closing all your command-lines and open one fresh and start at your home directory. If you are running as root, log out, and log back in to your normal account. For a single-user install you do NOT need to be root.

For a single user, using RVM as their Ruby sandbox, use the single-user installation docs. Follow ALL the instructions on that page, INCLUDING the "Post Install" section.

Close your terminal window, and reopen it. If you have correctly followed the instructions above, typing rvm info should spit out a template of what is to come once you install a Ruby instance. If you see nothing output, or get an error, then retrace your steps in the "Post Install" section, and go through the "Troubleshooting" section. Most of the problems people have occur because they didn't bother to read the directions.

Once RVM is installed, type rvm notes and read what dependencies you need to install. If you do not add those files your Rubies installed will be missing functionality. They will work, but some of the creature comforts you'll hear about won't work and you will wonder why.

After installing the dependencies you should be in good shape to install Rubies. Type rvm list known for all the Rubies RVM can install. If you want 1.8.7 type rvm install 1.8.7, and, similarly, rvm install 1.9.2 for Ruby 1.9.2. If you want a particular revision you can add that, based on the ones in the list.

It's important to periodically update RVM using rvm get head. That will add features, fix bugs, and tell RVM about new versions of Ruby it can install if you request.

After installing a Ruby, type rvm list and it should show up in the list, looking something like this:


rvm rubies

ruby-1.8.7-p334 [ x86_64 ]
ruby-1.9.2-p180 [ x86_64 ]

Type rvm use 1.9.2 --default to set a default Ruby that will be sticky between logins. Use the version of whatever Ruby you want to default to if 1.9.2 doesn't float your boat. Once you've defined a default it should look something like:


rvm rubies

ruby-1.8.7-p334 [ x86_64 ]
=> ruby-1.9.2-p180 [ x86_64 ]

Before you begin installing gems into a RVM-managed Ruby, read "RVM and RubyGems ", in particular the part that says "DO NOT use sudo... ". I repeat. Do NOT use sudo to install any gems, in spite of what some blog or web page says. RVM's author knows better when it comes to working with RVM controlled Rubies. That is another mistake people use with RVM, again as a result of not reading the directions.

On Mac OS, you'll need the latest version of XCode for your OS. Do NOT use the XCode that came with Snow Leopard on the DVD. It is buggy. Download and install a new version from Apple's Developer site. It's a free download requiring a free registration. It's a big file, approximately 8GB, so you'll want to start it and walk away. Install XCode, and you should be ready to have RVM install Rubies.

Finally, RVM installs easily, as will the Rubies you ask it to install. I have it on about four or five different machines and VMs on Mac OS, Ubuntu and CentOS. It takes me about a minute to install it and another minute to configure it and start installing a new Ruby. It really is that easy.

rvm requirements not working

Bypassing the standard warnings about abusing sudo, the bash hack

sudo `which rvm`

worked for me.

Rvm ruby Permission denied

You have a multiuser installation of rvm - this is not recommended because of the troubles you can get with it (like yours).

Since you are already there this should fix it:

rvmsudo rvm get stable --auto-dotfiles
rvm fix-permissions system

Also make sure you are in rvm group - if not add yourself:

rvm group add rvm $USER

and log in to a new shell (log out and log back in).



Related Topics



Leave a reply



Submit