1

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

Paweł Madej
  • 1,229
  • 23
  • 42
  • 1
    "I have read to not use rvm and rbenv and only brew version" Why? Can you provide a link? `rbenv` usually works fine for me. – Thomas Koppensteiner Dec 23 '19 at 11:17
  • 1
    I had issues with using rbenv and rvm on unpriviledged user. Gems unaccessible or unable to install them because of lack of write permissions. – Paweł Madej Dec 23 '19 at 14:53
  • 1
    My recommendation for OSX, and my experience, is that [RVM](https://rvm.io/) will give us the better experience by far. You won't have any gems install issues as it all happens on your `$HOME` context. For example: _/Users//.rvm/gems/ruby-2.5.3/gems/statsd-ruby-1.4.0/lib/statsd-ruby.rb_ location is perfectly safe and it works trouble free. – Rui Marques Jan 02 '20 at 16:28
  • 1
    so I will need $HOME duplicates for my user and for Jenkins user? @RuiMarques – Paweł Madej Jan 03 '20 at 11:55
  • 1
    @PawełMadej you can install global gems or user level gems but I recommend to use simply RVM or rbenv, I favour the fist. Installing RVM is so easy to use. See https://stackoverflow.com/questions/2119064/sudo-gem-install-or-gem-install-and-gem-locations. I'm not agains using `sudo` but is something I would avoid. If you need the Jenkins user on your OSX I would reconsider the way you're trying to use Jenkins and run it via Docker instead. I need to better understand what you're trying todo. – Rui Marques Jan 03 '20 at 15:33
  • I use Jenkins as my local CI for testing iOS apps I develop, so I need macOS specific packages like xcodebuild etc so I installed Jenkins on bare macOS and it created for itself Jenkins user. I will try to use RVM on this user and write if it works – Paweł Madej Jan 03 '20 at 22:58

0 Answers0