Rbenv: macOS Sierra set local is not working with gem install

Created on 27 Sep 2016  路  14Comments  路  Source: rbenv/rbenv

I have updated rbdev with

$ brew install rbenv ruby-build

and I get working, but when I do

$ rbenv versions
  system
* 2.3.1 (set by /Users/admin/Developmemt/.ruby-version)
admin@macbookproloreto:~/Developmemt$ rbenv local 2.3.1

and trying to install some gems like

I get

$ sudo gem install facebook-cli
Ignoring json-1.8.3 because its extensions are not built.  Try: gem pristine json-1.8.3
ERROR:  Error installing facebook-cli:
    facebook-cli requires Ruby version >= 2.3.

even if it seems it set

$ rbenv local
2.3.1

Most helpful comment

@mislav yes! this worked finally thanks a lot

I have added to .bash_profile the init

eval "$(rbenv init -)"

so it worked:

$ rbenv local 2.3.1
$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin16]

All 14 comments

The problem is that you used sudo. Please do just:

gem install facebook-cli

when installing gems into any rbenv version that isn't "system".

@mislav tried again

$ gem install facebook-cli
Ignoring json-1.8.3 because its extensions are not built.  Try: gem pristine json-1.8.3
Fetching: facebook-cli-1.3.7.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

but still getting the gem in the ruby 2.0 of macOS Sierra.

Before installing the gem did you do a rbenv local 2.3.1 and a rbenv rehash? I had to do this to get past errors in sierra

This is what I have done

admin@macbookproloreto:~$ rbenv versions
  system
* 2.3.1 (set by /Users/admin/.rbenv/version)
admin@macbookproloreto:~$ rbenv local 2.3.1
admin@macbookproloreto:~$ rbenv rehash
admin@macbookproloreto:~$ rbenv local
2.3.1
admin@macbookproloreto:~$ gem install facebook-cli
Ignoring json-1.8.3 because its extensions are not built.  Try: gem pristine json-1.8.3
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.

For some reason your RubyGems home dir is /Library/Ruby/Gems/2.0.0, the system Ruby dir.

What does gem env report for you?

@jeremy exactly:

$ ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]

and that is gem

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.4.2
  - RUBY VERSION: 2.0.0 (2015-12-16 patchlevel 648) [universal.x86_64-darwin16]
  - INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.0.0
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - SPEC CACHE DIRECTORY: /Users/admin/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-16
  - GEM PATHS:
     - /Library/Ruby/Gems/2.0.0
     - /Users/admin/.gem/ruby/2.0.0
     - /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /Users/admin/torch/install/bin
     - /Users/admin/bin/
     - /Users/admin/Library/Android/sdk/platform-tools/
     - /Users/admin/Library/Android/sdk/build-tools/23.0.2/
     - /Applications/MAMP/bin/php/php5.5.17/bin
     - /opt/webOS_SDK/Resources/ares-cli/bin
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /opt/X11/bin
     - /usr/local/share/dotnet
     - /usr/local/go/bin
     - /Library/Frameworks/Mono.framework/Versions/Current/Commands
     - /usr/local/mysql/bin/
     - /usr/local/cellar/mongodb/3.2.3//bin
     - /Users/admin/Software/ruby/bin
     - /Users/admin/go/bin

That's the system gem command, indeed. What does which gem report for you?

$ which gem
/Users/jeremy/.rbenv/shims/gem

Looks like you're on the system Ruby, too, for that matter. Are you in the directory where you set rbenv local 2.3.1?

@loretoparisi It looks like you haven't finished installing rbenv on your system. You need to have ~/.rbenv/shims directory prepended to your PATH. Please run rbenv init and follow the instructions to configure your .bash_profile (or similar shell initialization file).

@mislav yes! this worked finally thanks a lot

I have added to .bash_profile the init

eval "$(rbenv init -)"

so it worked:

$ rbenv local 2.3.1
$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin16]

@loretoparisi Glad you solved it! 馃憤

Updated install docs to cover this case #1009

I'm also having issues here (OS Sierra) and after I append to bash_profile nothing changes ...

Running which gem gives:

/usr/bin/gem

And I feel like I've tried many of the solutions out there... I'm stuck on Ruby 2.0.0 and also can't install Rails now...

rbenv install 2.4.2

I get this error:

rbenv: no such command `install'

Any thoughts on how I can proceed? Thank you in advance.

@loretoparisi solution works until I restart the system, then it is back to the preinstalled version as global.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ryanburnett picture ryanburnett  路  15Comments

genlighten picture genlighten  路  30Comments

meleyal picture meleyal  路  85Comments

gf3 picture gf3  路  20Comments

lkfken picture lkfken  路  14Comments