Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rbenv installation permission denied

Hi all I'm trying to set up a dev environment and I've been following a tutorial via; Link to tutorial

I'm not doing very well and have no real experience of terminal commands other than the most basic version control stuff. I followed the first link and when trying to run

source ~/.bash_profile

I got the error; mkdir: /usr/local/rbenv/shims: Permission denied mkdir: /usr/local/rbenv/versions: Permission denied

Now every time I load terminal the error appears.

Contents of bash_profile;

export PATH=/usr/local/rbenv/bin:$PATH
export RBENV_ROOT=/usr/local/rbenv
eval "$(rbenv init -)"

Any guidance would be greatly appreciated

like image 993
Meeps Avatar asked Jul 23 '15 13:07

Meeps


4 Answers

It looks like the rbenv setup puts a line of shell scripting in your .bash_profile that attempts to create that directory. You could either give yourself permissions to create directories in /usr/local/rbenv, or sudo mkdir /directories/that/need/to/be/created once.

sudo mkdir -p /usr/local/rbenv/shims
sudo mkdir -p /usr/local/rbenv/versions
like image 81
Greg Burghardt Avatar answered Nov 19 '22 02:11

Greg Burghardt


The actual solution ;-) (without the need of changing permissions or creating directories) is to change your bash_profile (or other like .zshrc as in my case) and remove the two exports:

export PATH=/usr/local/rbenv/bin:$PATH
export RBENV_ROOT=/usr/local/rbenv

Start a new shell, to be sure, and execute your rbenv install <your_version_of_choice> and it will install without any issues.

Running eval "$(rbenv init -)" should be enough for your environment. See rbenv init explained. I also think this is safer as you rely on the install to do it's work properly.

Gems are installed without the need of root/sudo.

like image 24
Ray Oei Avatar answered Nov 19 '22 03:11

Ray Oei


This was pretty useful System Wide Install With rbenv Specifically changing the permissions of rbenv directory to a group the users are in:

chgrp -R staff /usr/local/rbenv chmod -R g+rwxXs /usr/local/rbenv

like image 33
techbrownbags Avatar answered Nov 19 '22 01:11

techbrownbags


I was getting a permissions error when trying to install a ruby version.

It also was complaining that it couldn't complete the mkdir

In short set LDFLAGS to a blank string.

export LDFLAGS= 

Was found here: https://github.com/rbenv/rbenv/issues/766

like image 4
James Trickey Avatar answered Nov 19 '22 03:11

James Trickey