Danny Cox
Danny Cox

Reputation: 253

rbenv: no such command "install" even though ruby-build is installed

I'm trying to get ruby 2.1.4 installed via rbenv for a client project.

Though previously I've been able to install ruby versions through rbenv, after upgrading to Yosemite, I keep getting the following error:

rbenv: no such command 'install'

After digging around, I saw lots of tips about how "install" comes from the ruby-build plugin, which is installed via homebrew:

which ruby-build
/usr/local/bin/ruby-build

I installed rbenv via Homebrew, but when I try use which rbenv, I get:

rbenv () {
typeset command
command="$1" 
if [ "$#" -gt 0 ]
then
    shift
fi
case "$command" in
    (rehash|shell) eval `rbenv "sh-$command" "$@"` ;;
    (*) command rbenv "$command" "$@" ;;
esac
}

I have run brew update and brew upgrade rbenv ruby-builder, and it tells me everything is up to date.

Below is my full $PATH:

zsh: no such file or directory: /usr/local/var/rbenv/shims:/usr/local/var/rbenv/shims:/usr/local/bin:/usr/local/sbin:/Users/dannycox/.rbenv/shims:/Users/dannycox/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/go/bin:/Users/dannycox/.rbenv/shims:/Users/dannycox/.rbenv/bin

UPDATE: Found another answer with a little deeper digging on github that showed signs of promise, but failed to solve the issue with rbenv. https://github.com/sstephenson/rbenv/issues/610#issuecomment-56240018

I believe 2.1.4 is now installed on my machine, but it installed here: Successfully installed ruby 2.1.4 into /Users/dannycox/.rubies/ruby-2.1.4

As a result, my bundler won't work with the new ruby 2.0 version and I get the following error when I try to gem install bundle:

Fetching: bundler-1.7.6.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory

Still need help to identify why ruby-build isn't playing nice with rbenv...

Upvotes: 25

Views: 16536

Answers (3)

Coding Owl
Coding Owl

Reputation: 41

I had similar problem, and trace the problem to ruby-build. So i updated the homebrew and reinstall the ruby-build

> brew update
> brew reinstall ruby-build

Find the ruby version

> brew ls -v ruby-build | grep 2.1.4

then install intended version ruby again

> rbenv install 2.1.4

Upvotes: 1

Alberto Artasanchez
Alberto Artasanchez

Reputation: 641

Make sure to install optional step 5 in the instructions:

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

Install ruby-build, which provides the rbenv install command that simplifies the process of installing new Ruby versions.

Upvotes: 51

Andy D
Andy D

Reputation: 916

From your perms error I think you are trying to install to the system ruby, which is the one that comes with Apple OSX. You want to use rbenv to install your own ruby and install gems into that.

Read - https://github.com/rbenv/ruby-build#readme

And use the

rbenv versions

command to show what instance of ruby you are about to install the gems into. If it's system then you need to install your own ruby instance and then use that ruby for gems.

Upvotes: 0

Related Questions