Adding gems on Sierra OS - ruby

I've tried to update, as well as run existing Ruby gems after upgrading to OS X Sierra.
> sudo gem update --system
> Password: *enters password*
> Updating rubygems-update...
> ERROR: While executing gem ... (Errno::EPERM)
> Operation not permitted - /usr/bin/update_rubygems
This happens whether I execute directly from RubyGems or clone and pull down from Github. Running the command with sudo also returns an error saying I lack permissions.
I tried sudo rubygems_update :
/usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/rubygems/dependency.rb:308:in `to_specs': Could not find 'rubygems-update' (>= 0.a) among 7 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/Angelfirenze/.gem/ruby/2.4.0:/usr/local/lib/ruby/gems/2.4.0:/usr/local/Cellar/ruby/2.4.0/lib/ruby/gems/2.4.0', execute `gem env` for more information
from /usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/rubygems/dependency.rb:320:in `to_spec'
from /usr/local/Cellar/ruby/2.4.0/lib/ruby/2.4.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
from /usr/local/bin/update_rubygems:22:in `<main>'
I have just executed gem env and my terminal returned the following:
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.8
- 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/Angelfirenze/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-16
- GEM PATHS:
- /Library/Ruby/Gems/2.0.0
- /Users/Angelfirenze/.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/Angelfirenze/.rbenv/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /usr/local/git/bin
- /usr/local/MacGPG2/bin
- /Users/Angelfirenze/.rvm/bin
- /Users/Angelfirenze/bin
- /Users/Angelfirenze/bin

Maybe installing rvm would be the best option. I usually avoid the default ruby that comes shipped with OS X.
With that said I think Sierra ships with new security that needs to be disabled you can read about it here: Disable Mac OS SIP

Related

unable to run gems using custom Ruby version on macOS Mojave

I get error when trying to run any gem installed using ruby from brew install ruby
Here is slather example but this is same for any gem I tried (Jekyll, CocoaPods, Nokogiri etc.)
/Library/Ruby/Site/2.3.0/rubygems.rb:275:in `find_spec_for_exe': can't find gem slather (>= 0.a) with executable slather (Gem::GemNotFoundException)
from /Library/Ruby/Site/2.3.0/rubygems.rb:252:in `bin_path'
from /usr/local/bin/slather:22:in `<main>'
gem is installed properly but for unknown reason ruby tries to use paths for system version.
I have read to not use rvm and rbenv and only brew version but this also do not work as above
ruby -v: ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin18]
gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 3.1.2
- RUBY VERSION: 2.6.5 (2019-10-01 patchlevel 114) [x86_64-darwin18]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.6.0
- USER INSTALLATION DIRECTORY: /Users/[user]/.gem/ruby/2.6.0
- RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /usr/local/lib/ruby/gems/2.6.0/bin
- SPEC CACHE DIRECTORY: /Users/[user]/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.6.5/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-18
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.6.0
- /Users/[user]/.gem/ruby/2.6.0
- /usr/local/Cellar/ruby/2.6.5/lib/ruby/gems/2.6.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /usr/local/opt/ruby/bin
- /Users/[user]/.fastlane/bin
- /Users/[user]/.fastlane/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /opt/X11/bin
any help appreciated

Jekyll not serving locally - 'could not find jekyll'

I have little-to-no experience with ruby, but have been managing to successfully maintain a Jekyll site with github. However, for some unknown reason, when I cd into my website's directory and run jekyll serve I get the following error:
Could not find 'jekyll' (>= 0) among 7 total gem(s) (Gem::MissingSpecError)
Here is the full error message:
/usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems/dependency.rb:308:in `to_specs': Could not find 'jekyll' (>= 0) among 7 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/amin/.gem/ruby/2.4.0:/usr/local/lib/ruby/gems/2.4.0:/usr/local/Cellar/ruby/2.4.1_1/lib/ruby/gems/2.4.0', execute `gem env` for more information
from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems/dependency.rb:320:in `to_spec'
from /usr/local/Cellar/ruby/2.4.1_1/lib/ruby/2.4.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
from /usr/local/bin/jekyll:22:in `<main>'
Trying gem env gives this, which looks a little messy:
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.5
- RUBY VERSION: 2.2.2 (2015-04-13 patchlevel 95) [x86_64-darwin15]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.2.0
- RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- SPEC CACHE DIRECTORY: /Users/amin/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.2.2/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-15
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.2.0
- /Users/amin/.gem/ruby/2.2.0
- /usr/local/Cellar/ruby/2.2.2/lib/ruby/gems/2.2.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/amin/Dropbox/code/google-cloud-platform/google-cloud-sdk/bin
- //anaconda/bin
- /opt/local/bin
- /opt/local/sbin
- /opt/local/bin
- /opt/local/sbin
- /Library/Frameworks/Python.framework/Versions/3.4/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /opt/X11/bin
- /Library/TeX/texbin
My best guess is that Jekyll should be looking in usr/local/bin, and not usr/local/Cellar, but as I say, that's just a guess.
Any advice on how to get this working again would be greatly appreciated!

Gem install confusing the ruby version

I'm attempting to install vagrant-bindfs through the vagrant up, however it was failing, and the same happened with vagrant plugin install vagrant-bindfs.
So I've downloaded the gem file and attempted to install it manually, as you can see below:
------------------------------------------------------------
~/.vagrant.d/gems/gems » gem install -l ~/Downloads/vagrant-bindfs-0.4.12.gem --install-dir . --debug
NOTE: Debugging mode prints all exceptions even when rescued
Exception `LoadError' at /usr/local/Cellar/ruby/2.3.2/lib/ruby/2.3.0/resolv.rb:171 - LoadError
Exception `Errno::EEXIST' at /usr/local/Cellar/ruby/2.3.2/lib/ruby/2.3.0/fileutils.rb:253 - File exists # dir_s_mkdir - /Users/ml/.vagrant.d/gems/gems
Exception `Gem::InstallError' at /usr/local/lib/ruby/site_ruby/2.3.0/rubygems/installer.rb:611 - vagrant-bindfs requires Ruby version ~> 2.0.0.
ERROR: Error installing /Users/ml/Downloads/vagrant-bindfs-0.4.12.gem:
vagrant-bindfs requires Ruby version ~> 2.0.0.
------------------------------------------------------------
~/.vagrant.d/gems/gems » gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.6.8
- RUBY VERSION: 2.3.2 (2016-11-15 patchlevel 217) [x86_64-darwin15]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/2.3.0
- USER INSTALLATION DIRECTORY: /Users/ml/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- SPEC CACHE DIRECTORY: /Users/ml/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/2.3.2/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-15
- GEM PATHS:
- /usr/local/lib/ruby/gems/2.3.0
- /Users/ml/.gem/ruby/2.3.0
- /usr/local/Cellar/ruby/2.3.2/lib/ruby/gems/2.3.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- .
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Users/ml/.composer/vendor/bin
So as it mentions above it requires ~> 2.0.0, and the version gem is using is RUBY VERSION: 2.3.2, which should be ok.
Any idea what is happening here?

Bundler can't find gem bundler/bower

Environment:
Mac OS X 10.11.3 (El Capitan)
Homebrew 0.9.5
rvm 1.26.11 (same problem occurs with rbenv)
Bundler 1.11.2
Gemfile (excerpt):
source 'https://rubygems.org'
require 'bundler/bower'
asset "jquery", "~2.1.4"`
I get this error:
bundle install
[!] There was an error parsing `Gemfile`:
cannot load such file -- bundler/bower. Bundler cannot continue.
# from /Users/nobby/becompany/website/src/website-static/Gemfile:5
# -------------------------------------------
#
> require 'bundler/bower'
#
# -------------------------------------------
My RubyGems environment is:
- RUBYGEMS VERSION: 2.5.1
- RUBY VERSION: 2.3.0 (2015-12-25 patchlevel 0) [x86_64-darwin15]
- INSTALLATION DIRECTORY: /Users/nobby/.rvm/gems/ruby-2.3.0
- USER INSTALLATION DIRECTORY: /Users/nobby/.gem/ruby/2.3.0
- RUBY EXECUTABLE: /Users/nobby/.rvm/rubies/ruby-2.3.0/bin/ruby
- EXECUTABLE DIRECTORY: /Users/nobby/.rvm/gems/ruby-2.3.0/bin
- SPEC CACHE DIRECTORY: /Users/nobby/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/nobby/.rvm/rubies/ruby-2.3.0/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-15
- GEM PATHS:
- /Users/nobby/.rvm/gems/ruby-2.3.0
- /Users/nobby/.rvm/gems/ruby-2.3.0#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/nobby/.rvm/gems/ruby-2.3.0/bin
- /Users/nobby/.rvm/gems/ruby-2.3.0#global/bin
- /Users/nobby/.rvm/rubies/ruby-2.3.0/bin
- /Users/nobby/.rvm/bin
- /Users/nobby/src/apache/ant/apache-ant-1.9.6/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
Maybe bundler is looking in the wrong gem paths? Is there a way to see which paths it is using?
It works when I manually add the dependencies to LOAD_PATH in Gemfile; maybe this helps to point me to the cause of the problem:
[ 'bundler-bower-0.0.3', 'bower-rails-0.10.0'].each do |dep|
$LOAD_PATH.unshift "/Users/nobby/.rvm/gems/ruby-2.3.0/gems/#{dep}/lib"
end
https://github.com/LTe/bundler-bower
You need to
gem install 'bundler-bower'
before you can require modules from it. Potentially (hopefully) bundler is clever enough to resolve dependency order if you add
gem 'bundler-bower'
to your gemfile and then install it with
bundle install
instead

Rails 4.2 and gem config broken

My OS X ruby dev environment is broken, I don't know why.
I undesrtood that the gem path is wrong, but I don't know how to fix it.
/Users/muqaddar/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:315:in `to_specs': Could not find 'rails' (>= 0) among 14 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/Users/muqaddar/.rvm/gems/ruby-2.0.0-p598:/Users/muqaddar/.rvm/gems/ruby-2.0.0-p598#global', execute `gem env` for more information
from /Users/muqaddar/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:324:in `to_spec'
from /Users/muqaddar/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:64:in `gem'
from /usr/bin/rails:22:in `<main>'
Here is my config with gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.6
- RUBY VERSION: 2.0.0 (2014-11-13 patchlevel 598) [x86_64-darwin14.1.0]
- INSTALLATION DIRECTORY: /Users/muqaddar/.rvm/gems/ruby-2.0.0-p598
- RUBY EXECUTABLE: /Users/muqaddar/.rvm/rubies/ruby-2.0.0-p598/bin/ruby
- EXECUTABLE DIRECTORY: /Users/muqaddar/.rvm/gems/ruby-2.0.0-p598/bin
- SPEC CACHE DIRECTORY: /Users/muqaddar/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/muqaddar/.rvm/rubies/ruby-2.0.0-p598/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-14
- GEM PATHS:
- /Users/muqaddar/.rvm/gems/ruby-2.0.0-p598
- /Users/muqaddar/.rvm/gems/ruby-2.0.0-p598#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/muqaddar/.rvm/gems/ruby-2.0.0-p598/bin
- /Users/muqaddar/.rvm/gems/ruby-2.0.0-p598#global/bin
- /Users/muqaddar/.rvm/rubies/ruby-2.0.0-p598/bin
- /usr/local/mysql/bin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /opt/X11/bin
- /Users/muqaddar/.rvm/bin
I tried many things, reading lots of threads.
- reinstall rvm
- remove .vendor/bundle
- bundle install
...etc
I think the gems are not installed in the right directory. How to change that depending my rvm config ?
You should try and follow these steps if you are using a mac: http://www.installrails.com/
Note that when installing a new gem, you first have to add it to the Gemfile inside your editor. For example: gem 'bootstrap-sass', '~> 3.3.3'
After doing this navigate to your folder using terminal and type: "bundle install". This will install your added gems.

Resources