Search code examples
rubymacosrubygemstextmatechruby

gem locations in macOS with chruby and TextMate preferences


I having trouble getting Ruby gems to work right with TextMate (TM) and chruby on macOS.

Clean install of Mojave (now v10.14.4) on a 2017 iMac about six months ago.

Trying to use Ruby-2.6.2, although earlier versions have been installed. System Ruby is v2.3.7

I have ended up with gems in at least three locations:

~/.rubies/ruby-2.6.2/lib/ruby/gems/2.6.0/gems/
~/.gem/ruby/2.6.2/gems/
/Library/Ruby/Gems/2.3.0/gems/

TextMate relies on its Preferences for gem and Ruby locations. As a start I have the following: enter image description here GEM_HOME is unset because I don't see why it's needed, although I've frequently read to set it as shown or similar. GEM_HOME and GEM_PATH are defined as

GEM_PATH provides the locations (there may be several) where gems can be found.

GEM_HOME is where gems will be installed (by default).

The problem is that when I run this script (after the error not included) in TM

#!/usr/bin/env ruby
system ('gem env') # for debugging
puts "\nGem.path: #{Gem.path}"
puts "\ngem list:"
system ('gem list') # for debugging 
require 'fileutils'
include FileUtils
require 'find'
require 'yaml'
require "time"
require 'irb'
require 'mini_exiftool'

The result is:

Running “PhotoName-GPScoord.rb”…
ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-darwin18]
Theme:  
RubyGems Environment:
  - RUBYGEMS VERSION: 3.0.3
  - RUBY VERSION: 2.3.7 (2018-03-28 patchlevel 456) [universal.x86_64-darwin18]
  - INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.3.0
  - USER INSTALLATION DIRECTORY: /Users/gscar/.gem/ruby/2.3.0
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /usr/bin
  - SPEC CACHE DIRECTORY: /Users/gscar/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-18
  - GEM PATHS:
     - /Library/Ruby/Gems/2.3.0
     - /Users/gscar
     - /.rubies/ruby-2.6.2/lib/ruby/gems/2.6.0
     - /.gem/ruby/2.6.2/gems/
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--no-document"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /Users/gscar/Library/Application Support/TextMate/Managed/Bundles/Bundle Support.tmbundle/Support/shared/bin
     - /usr/local/bin
     - /usr/texbin
     - /opt/local/bin

Gem.path: ["/Users/gscar", "/.rubies/ruby-2.6.2/lib/ruby/gems/2.6.0", "/.gem/ruby/2.6.2/gems/", "/Users/gscar/.rubies/ruby-2.6.2/lib/ruby/gems/2.6.0"]

gem list:
<about 100 gems>
mimemagic (0.3.3)
mini_exiftool (2.9.0)
mini_magick (4.6.1)
<about 20 gems>

LoadError: cannot load such file — mini_exiftool

method require  in kernel_require.rb at line 54
method require  in kernel_require.rb at line 54
method <main>   in PhotoName-GPScoord.rb at line 19
  copy output 

TextMate puts this in the top right of the output enter image description here

Line 19 is require 'mini_exiftool'

mini_exiftool is in the gem list, but why the error?

If I run the script using the system Ruby (taking defaults, nothing set in TM) System Ruby

The script runs with the following output:

Running “PhotoName-GPScoord.rb”…
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
Theme:  
RubyGems Environment:
  - RUBYGEMS VERSION: 3.0.3
  - RUBY VERSION: 2.3.7 (2018-03-28 patchlevel 456) [universal.x86_64-darwin18]
  - INSTALLATION DIRECTORY: /Library/Ruby/Gems/2.3.0
  - USER INSTALLATION DIRECTORY: /Users/gscar/.gem/ruby/2.3.0
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /usr/bin
  - SPEC CACHE DIRECTORY: /Users/gscar/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-18
  - GEM PATHS:
     - /Library/Ruby/Gems/2.3.0
     - /Users/gscar/.gem/ruby/2.3.0
     - /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
     - "gem" => "--no-document"
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /Users/gscar/Library/Application Support/TextMate/Managed/Bundles/Bundle Support.tmbundle/Support/shared/bin

Gem.path: ["/Users/gscar/.gem/ruby/2.3.0", "/Library/Ruby/Gems/2.3.0", "/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.0"]

gem list:

<long list of gems including mini_exiftool (2.9.0)>

This particular script is OK with 2.3.7, but others may not be.

Thanks for any help.

This posting is a simplification of an earlier posting from me. I think I've boiled the problem down.


Solution

  • Changed GEM_HOME and GEM_PATH to $HOME/.gem/ruby/2.6.2:$HOME/.rubies/ruby-2.6.2/lib/ruby/gems/2.6.0 based on copying the those variables from what showing up when running from the terminal. Lu's comment made me look a little harder at what was being reported. Basically I was missing $HOME/ in the second path (after the colon). I have been fiddling with this for months