rbenv installation permission denied
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
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.