zhiming jiang zhiming jiang - 5 months ago 57
Ruby Question

Cannot install ruby on MAC 10.11.5

I cannot install ruby new version. I stall the home-brew and ruby-build, both install successful. I type $ rbenv, it shows


...


install Install a Ruby version using ruby-build


...


then i stall version 2.3.1


$ rbenv install 2.3.1


it shows error

Zhimings-MacBook-Pro:~ zhimingjiang$ rbenv install 2.3.1
Downloading ruby-2.3.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.1.tar.bz2
Installing ruby-2.3.1...
mkdir: /usr/local/var/rbenv/versions/2.3.1/lib: Permission denied

BUILD FAILED (OS X 10.11.5 using ruby-build 20160426)

Inspect or clean up the working tree at /var/folders/wf/tkkf34w562q8mqb59f43lnrh0000gn/T/ruby-build.20160703231044.15035
Results logged to /var/folders/wf/tkkf34w562q8mqb59f43lnrh0000gn/T/ruby-build.20160703231044.15035.log

Last 10 log lines:
/var/folders/wf/tkkf34w562q8mqb59f43lnrh0000gn/T/ruby-build.20160703231044.15035 ~
/var/folders/wf/tkkf34w562q8mqb59f43lnrh0000gn/T/ruby-build.20160703231044.15035/ruby-2.3.1 /var/folders/wf/tkkf34w562q8mqb59f43lnrh0000gn/T/ruby-build.20160703231044.15035 ~

I does't have path /usr/local/var/rbenv, I only have path /usr/local/rbenv

Additions (here is the tutorial i have watched
https://www.youtube.com/watch?v=jx0NrIbQbzI)

Answer

You can try install ruby via rbenv following as this tutorial:

I tried it and success.

install rbenv on osx

Update:

You should do these steps as below:

brew install rbenv
brew install ruby-build
echo 'export RBENV_ROOT=/usr/local/var/rbenv' >> ~/.bash_profile
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile

Then you used rbenv to install ruby. First, find the desired version:

rbenv install -l

And rbenv install 2.3.1