-1

I recently moved to a new iMac and did a clean install. Consequently not everything works like it did on my MBP. I made several changes suggested by @awsmsce and have incorporated that into the following. Still have the problem.

A ruby script that uses the gem mini_exiftool throws an error when run from TextMate (same error when run from command line). Here's the beginning of the script.

#!/usr/bin/env ruby
require 'rubygems'
require 'fileutils'
include FileUtils
require 'find'
require 'yaml'
require "time"
require 'shellwords'
require 'mini_exiftool'

TextMate reports LoadError: cannot load such file — mini_exiftool and

method require in kernel_require.rb at line 55

Path to kernel_require.rb is /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb which possibly shows a problem. Not running the same ruby as where the gems are. But with changes recommended by @awsmsce now in /Users/gscar/.rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb so that's not the issue

Terminal chruby >> * ruby-2.5.1

ruby -v >> ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]

gem list >> mini_exiftool (2.9.0)

exiftool -ver >> 11.17

TextMate PATH variable is $PATH:$HOME/.rubies/ruby-2.5.1/bin:$HOME/.rubies/ruby-2.5.1/shims:/usr/local/bin:/usr/texbin:/opt/local/bin

system('gem env'):

RubyGems Environment:
  - RUBYGEMS VERSION: 2.5.2.3
  - RUBY VERSION: 2.3.7 (2018-03-28 patchlevel 456) [universal.x86_64-darwin17]
  - INSTALLATION DIRECTORY: /Users/gscar/.gem/ruby/2.5.1/gems
  - USER INSTALLATION DIRECTORY: /Users/gscar/.gem/ruby/2.3.0
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /Users/gscar/.gem/ruby/2.5.1/gems/bin
  - SPEC CACHE DIRECTORY: /Users/gscar/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /Library/Ruby/Site
  - RUBYGEMS PLATFORMS:
    - ruby
    - universal-darwin-17
  - GEM PATHS:
     - /Users/gscar/.gem/ruby/2.5.1/gems
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - 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
     - /Users/gscar/.rubies/ruby-2.5.1/bin
     - /Users/gscar/.rubies/ruby-2.5.1/shims
     - /usr/local/bin
     - /usr/texbin
     - /opt/local/bin

Gem.path: ["/Users/gscar/.gem/ruby/2.5.1/gems"]

I'm updating this after having been on a trip for a month and still need this script. I changed the order of the gems, shows that some download but not others. gem list shows mini_exiftool (2.9.0) among others. If I hard code to require '/Users/gscar/.gem/ruby/2.5.1/gems/mini_exiftool-2.9.0/lib/mini_exiftool.rb' then the script fails similarly on another gem.

Greg
  • 2,359
  • 5
  • 22
  • 35
  • really don't want this to be it... but did you notice there is no closing single quote on that require statement? – awsmsce Nov 08 '18 at 06:20
  • 1
    can you do `system('gem env')` from inside the file, without the second require statement and post the results – awsmsce Nov 08 '18 at 06:23
  • interesting. is `.rubies/ruby-2.5.1/bin/ruby` supposed to be prefaced with `~/` ? Is that in your home directory? or is that suppose to be literally in the directory you are running the script from? – awsmsce Nov 08 '18 at 06:39
  • `.rubies` is in my home directory. I'm running the script from `~/Documents/Ruby/Photo handling/`. Look at the new addition at the bottom of my posting. Thanks for hanging in. – Greg Nov 08 '18 at 06:43
  • 1
    okay, sounds like that is it. Where are you setting your path? maybe like ~/.bash_profile or something?, You mentioned you `TextMate PATH variable is $PATH:.rubies/ruby-2.5.1/bin/ruby:/usr/local/bin:/usr/texbin:/opt/local/bin` .... if you know where to adjust this, just put ~/ in front of `.rubies/ruby-2.5.1/bin/ruby` – awsmsce Nov 08 '18 at 06:49
  • Changed `PATH` to `$PATH:~/.rubies/ruby-2.5.1/bin/ruby:/usr/local/bin:/usr/texbin:/opt/local/bin` which is set in TextMate preferences and it didn't help. I relaunched TextMate to be sure. – Greg Nov 08 '18 at 06:52
  • Changed `PATH` to `/usr/bin:/bin:/usr/sbin:/sbin:/Users/gscar/Library/Application Support/TextMate/Managed/Bundles/Bundle Support.tmbundle/Support/shared/bin:~/.rubies/ruby-2.5.1/bin/ruby:/usr/local/bin:/usr/texbin:/opt/local/bin:~/.gem/ruby/2.5.1/gems` and updated OP. Shows as SHELL PATH, but not a GEM PATH ! – Greg Nov 08 '18 at 07:18

2 Answers2

1

Okay, I think I have it now. Gonna take a swing:

set your PATH to the following:

export PATH=$PATH:$HOME/.rubies/ruby-2.5.1/bin:$HOME/.rubies/ruby-2.5.1/shims:/usr/local/bin:/usr/texbin:/opt/local/bin

set your TM_RUBY variable to:

$HOME/.rubies/ruby-2.5.1/bin/ruby

I think you currently have ruby added to the path, but not the binaries or shims.

If this isn't working, try puts Gem.path, and make sure it points to the right location.

Make sure the gem you are trying to call is where you expect it gem which mini_exiftool

If they are wrong, you might need to set these

export GEM_HOME=[WHATEVER YOUR GEM DIR IS] export GEM_PATH=[WHATEVER YOUR GEM DIR IS]

awsmsce
  • 187
  • 9
  • I added to OP the new error. I tried doing what it said to no avail. I added GEM_HOME and GEM_PATH as `$PATH:$HOME/.gem/ruby/2.5.1`. `gem which mini_exiftool` is `/Users/gscar/.gem/ruby/2.5.1/gems/mini_exiftool-2.9.0/lib/mini_exiftool.Redondo Beach` – Greg Nov 08 '18 at 07:39
  • oh, no, GEM_HOME and GEM_PATH should just be `$HOME/.gem/ruby/2.5.1/gems` ( it needs to actually include the 'gems' dir, and should not have $PATH in it ) – awsmsce Nov 08 '18 at 07:45
  • Thanks. I figured that out. Got rid of `TM_PATH` and will post result in OP with changed result for gem env. Slight error. Reposting OP again in a sec. – Greg Nov 08 '18 at 07:48
  • To go along with the updates to gem paths, here's the path to the problematic gem: `/Users/gscar/.gem/ruby/2.5.1/gems/mini_exiftool-2.9.0/` – Greg Nov 08 '18 at 08:00
  • `TM_RUBY` is pointing to the right place: `/Users/gscar/.rubies/ruby-2.5.1/bin/ruby`. Path copied directly. `gem env` disagrees. But TextMate reports `ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]` in the Running window. PS: I don't have a `shims` directory. `Gem.path: ["/Users/gscar/.gem/ruby/2.5.1/gems"]` – Greg Nov 08 '18 at 08:13
  • Any progress on this? trying not to leave you hanging...just tough to debug when I'm not sure of all the pieces involved. Text mate is pretty old school though. Glad you're keeping it alive. Checkout VSCode and Sublime 3, maybe that will move some things forward for you in a different direction. – awsmsce Nov 09 '18 at 02:18
  • Thanks for asking. TextMate is still being developed. I don't do much coding and don't want to start over—I'm comfortable with TM. I'll post to the TM list to see if they know anything. This script still works on my MBP with the same OS, so a bit of a mystery. OK, I'm looking at `gem env` and the MBP is using system Ruby and the only `mini_exiftool` I can find is `/Library/Ruby Gems/2.0.0/gems/mini_exiftool-2.5.1/lib/mini_exiftool.rb`. I could probably abandon chruby since Apple may be now keeping Ruby up to date enough for my purposes. Or I need study chruby and all the paths things more. – Greg Nov 09 '18 at 02:52
  • From Sublime: `/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- mini_exiftool (LoadError)` Fresh install, didn't configure anything. – Greg Nov 09 '18 at 02:53
0

This now works. Unfortunately I'm not quite sure what the fix was and it may not be fair to call this an answer for that reason and that I still have problems running Ruby scripts from TextMate. I'm at

chruby ruby-2.6.2

TM_PATH is $HOME/.rubies/ruby-2.6.2/bin/ruby

PATH is $PATH:/usr/local/bin:/usr/texbin:/opt/local/bin

TM_RUBY is $HOME/.rubies/ruby-2.6.2/bin/ruby

Works with GEM_PATH and GEM_HOME not set. However when they are set I get this error:

/Library/Ruby/Site/2.3.0/rubygems.rb:283:in `find_spec_for_exe': can't find gem rspec-core (>= 0.a) with executable rspec (Gem::GemNotFoundException)
from /Library/Ruby/Site/2.3.0/rubygems.rb:262:in `bin_path'
from /usr/local/bin/rspec:22:in `<main>'` 

which most likely has something to do with my PATH setting. I'm posting this now as I was back revisiting the issue. I can run the Ruby scripts from the command line which is a work around.

Greg
  • 2,359
  • 5
  • 22
  • 35