12

While executing this command to install rvm

curl -sSL https://get.rvm.io | bash -s stable

I am getting this error message:

mktemp: failed to create file via template ‘/usr/share/rvm/rvm-exec-test.XXXXXX’: Permission denied
John
  • 16,759
  • 1
  • 34
  • 43
N.Raut
  • 123
  • 1
  • 1
  • 4

5 Answers5

16

I solved it by changing the following

curl -sSL https://get.rvm.io | bash -s stable

into

curl -sSL https://get.rvm.io | sudo bash -s stable

The user needs access to the subdir. /usr/local

Anthon
  • 78,313
  • 42
  • 165
  • 222
Mr.Black
  • 161
  • 1
  • 3
  • 3
    Note - this version with "sudo" installs it as multi-user in /user/local . If you want a user-install, where the gems etc go in the user's home-directory, something else is required. Nevermind that the one that fails (reported by the OP) is what is in the horrible rvm instructions for a single-user install, which have never worked for me without hours of fiddling each and every time. – JosephK Feb 13 '18 at 07:45
15

You probably have (or had) a system-wide installation of RVM. That can be due installing it through a package system like apt-get on Ubuntu or pacman on Arch Linux (both have rvm packages).

Check your environment variables:

> env | grep rvm_path

If you have it, then unset it and try to install again:

> unset rvm_path
> curl -sSL https://get.rvm.io | bash -s stable

BEWARE! If you still have rvm installed system-wide, this can give you unpredictable results, make sure you have it uninstalled before doing that.

If you have it already uninstalled and rvm_path is still there, maybe you can log out and log in again to remove them from the environment (or just restart the computer).

Ronie
  • 251
  • 2
  • 4
  • thanks working for me, i install ruby previously and also recommend do this unset GEM_HOME – jonathan May 07 '18 at 14:54
  • This solved the problem for me! – Korayem Nov 13 '18 at 17:14
  • This was helpful, though I also had to run `sudo apt-get purge rvm` per @martincito's answer. I had installed rvm in multiple ways (apt and manually as multi-user) so i had to manually uninstall too `rvm impolode` (and follow resulting instructions for dirs/files to manually delete). Only then could I unset some env vars and reinstall as single user – hamx0r Feb 01 '23 at 19:25
1

Probably you had install another version of RVM in your computer. Check, if you have Ubuntu, maybe you installed the exclusive Ubuntu version https://github.com/rvm/ubuntu_rvm You can uninstall it with command

sudo apt-get purge rvm

I resolve it like this. And then install rvm with

\curl -sSL https://get.rvm.io | bash -s stable

And then configuring the source from

source ~/.rvm/scripts/rvm

You then need yo add the source of rvm to your .bashrc and .profile files in your home

martincito
  • 111
  • 1
1

I followed these steps and it works for me:

  1. Purge all system packages related with ruby or rvm:
sudo apt purge ruby rvm
  1. Make sure that there is not /etc/rvmrc
sudo rm -f /etc/rvmrc
  1. Create .rvm folder on $HOME and install rvm passing some additional arguments like "--ignore-dotfiles" and "--user-install":
mkdir -p $HOME/.rvm

curl -sSL https://get.rvm.io | bash -s -- --ignore-dotfiles --user-install

Additional arguments:

--ignore-dotfiles: Avoid the execution of any previous .rvmrc file.

--user-install: The installation will be done in the path $HOME/.rvm

  1. Put the following on your ~/.bashrc or ~/.zshrc file:
source $HOME/.rvm/scripts/rvm
  1. Restart your terminal.
FarKorE
  • 11
  • 2
  • Welcome to U&L. What "additional arguments" exactly should OP pass to the installer and why exactly? Please [edit](https://unix.stackexchange.com/posts/741632/edit) your question to clarify instead of commenting. – Peregrino69 Apr 01 '23 at 08:17
-1

The $ suggests you are attempting this install as a regular (i.e. non-root) user. If so, that is likely your problem, as the /usr/share/ tree on most Linux operating systems is writable only by root. The software you are trying to install likely wants you to have root permissions to perform the install.

John
  • 16,759
  • 1
  • 34
  • 43