7

I am trying to install Ruby on a remote server using rbenv.

However, when I run the command rbenv install 2.7.2, I get the error below:

ruby-build: TMPDIR=/tmp cannot hold executables (partition possibly mounted with noexec)

I have rbenv and other dependencies for the Ruby programming language properly installed.

Promise Preston
  • 24,334
  • 12
  • 145
  • 143

2 Answers2

11

After a few research and trials, I was able to solve it.

Here's how I solved it:

The issue was that the rbenv installer needed a directory to store temporary files while it is downloading and installing ruby, however, the /tmp directory which is the default directory for storing temporary files wasn't accessible by my current user.

I tried to change permissions for the /tmp directory to allow it become accessible to my current user, however, I was unsuccessful.

All I had to do was to create a new tmp directory in the home directory of my user:

mkdir ~/tmp

Next, I opened the .bashrc file in the home directory of my user:

sudo nano ~/.bashrc

Next, I added the line below to the bottom of the file and saved:

export TMPDIR="$HOME/tmp"

Finally, I restarted my terminal or ran the command below to load the newly added paths into my current shell/terminal session:

exec "$SHELL"

Now, I could run the command rbenv install 2.7.2 and it worked fine.

Resources: TMPDIR=/tmp cannot hold executables (partition possibly mounted with noexec)

cigien
  • 57,834
  • 11
  • 73
  • 112
Promise Preston
  • 24,334
  • 12
  • 145
  • 143
  • 2
    `~tmp` is the *home directory of user `tmp`* but `~/tmp` is `tmp` in your home directory. – tadman Feb 04 '21 at 01:36
  • 1
    You might also create a `~/tmp` dir and then try using `env TMPDIR="$HOME/tmp" rbenv install 2.7.2` and you wouldn't need to change any shell start up files. – ian Feb 04 '21 at 05:08
2

Adding to the OP's answer, you don't need to create a new tmp folder. Only adding to the path should work as well.

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57