'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
Solution 1:[1]
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
Solution 2:[2]
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.
Solution 3:[3]
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
Solution 4:[4]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Greg Burghardt |
Solution 2 | Ray Oei |
Solution 3 | techbrownbags |
Solution 4 | James Trickey |