How to Install Rvm Without Root Access

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.

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.

rvm doesn't install in centos without root privileges

I was trying to install rvm in folder mounted with noexec option.

Mounting partition without this option works!

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...).

How to use rvm (ruby version manager) with root account?

I found the solution:

rvmsudo does the trick.

rvm is not a function with root user on ubuntu desktop

Add this to your .bashrc

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

If rvm is not in your home folder, you can use the absolute path

[[ -f "<path-to-rvm>/scripts/rvm" ]] && source "<path-to-rvm>/scripts/rvm"

How do I install rails and create a new application without root access?

Yes and no.

A typical development environment is set up with RVM (or rbenv, never tried it) and is contained entirely in your home folder: Ruby interpreter (possibly more than one!), its gems and configuration. For that you don't need root access.

When installing Ruby via RVM, you might get a prompt for installing dependencies required to compile Ruby from sources. That's one case. (And, as it turns out, this may fail if sudo is not available, and it might be, so see this question for possible alternatives)

You might occasionally need root access for installing development libraries needed to compile native extensions for certain gems. For instance, for gem pg you'll need libpq-dev on Debian and derivatives (Ubuntu, Mint, etc.). While you could try downloading the sources to your home folder and point the compiler in that direction, that takes time. So that's two cases.


But given no RVM...

In your specific case rails has done the job just fine: it generated the template, it just failed to bundle install the template's dependencies. It uses whatever gem directory is default for RubyGems. Seeing that it's /var/lib/gems/2.1.0, I'm guessing you're using system-wide Ruby. This isn't ideal for development as you might want to switch back and forth between different interpreter versions (or even implementations, such as Rubinius), use a version manager constrained to your home folder.

Not that you can do nothing else. Try cding into the generated folder and running:

bundle --help install

There are many options, you see. --path or even --standalone can probably save you here, it overrides gem installation path and remembers the fact that it's overridden, so it knows where to look for gems.


Anyway, once the application is set up and dependencies are resolved and installed, you won't need root access for neither running it (on non-privileged ports, of course) or setting up another application, since any necessary system-wide dependencies will already be installed by then.



Related Topics



Leave a reply



Submit