我最近移至新的iMac并进行了全新安装。因此,并非所有操作都像我的MBP一样。我进行了@awsmsce建议的一些更改,并将其合并到以下内容中。仍然有问题。
使用gem mini_exiftool的ruby脚本从TextMate运行时会引发错误(从命令行运行时会发生相同错误)。这是脚本的开头。
#!/usr/bin/env ruby
require 'rubygems'
require 'fileutils'
include FileUtils
require 'find'
require 'yaml'
require "time"
require 'shellwords'
require 'mini_exiftool'
TextMate报告LoadError: cannot load such file — mini_exiftool
和
method require in kernel_require.rb at line 55
到kernel_require.rb
的路径是/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb
,这可能表明有问题。红宝石的运行位置与宝石所在的位置不同。但是现在{awsmsce}在/Users/gscar/.rubies/ruby-2.5.1/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb
中建议进行更改,所以这不是问题
端子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
变量为$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"]
我旅行了一个月后仍在更新此文件,但仍需要此脚本。我更改了gem的顺序,显示了一些下载,但没有下载。 gem list
显示mini_exiftool (2.9.0)
等。如果我将代码硬编码为require '/Users/gscar/.gem/ruby/2.5.1/gems/mini_exiftool-2.9.0/lib/mini_exiftool.rb'
,那么脚本在另一个gem上也会失败。
答案 0 :(得分:1)
好的,我想我现在拥有了。要摇摆:
将您的PATH设置为以下内容:
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
将您的TM_RUBY变量设置为:
$HOME/.rubies/ruby-2.5.1/bin/ruby
我认为您当前已将红宝石添加到路径中,但未添加二进制文件或垫片。
如果这不起作用,请尝试puts Gem.path
,并确保其指向正确的位置。
确保您要调用的宝石位于您期望的位置gem which mini_exiftool
如果错误,则可能需要设置这些
export GEM_HOME=[WHATEVER YOUR GEM DIR IS]
export GEM_PATH=[WHATEVER YOUR GEM DIR IS]
答案 1 :(得分:0)
现在可以使用。不幸的是,我不太确定该修复程序是什么,因此由于这个原因将其称为答案可能并不公平,而且我仍然无法从TextMate运行Ruby脚本。我在
chruby ruby-2.6.2
TM_PATH
是$HOME/.rubies/ruby-2.6.2/bin/ruby
PATH
是$PATH:/usr/local/bin:/usr/texbin:/opt/local/bin
TM_RUBY
是$HOME/.rubies/ruby-2.6.2/bin/ruby
未设置GEM_PATH
和GEM_HOME
的情况。但是,设置它们后,出现此错误:
/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>'`
最有可能与我的PATH
设置有关。我现在回过头来重新发布此问题时发布。我可以从命令行运行Ruby脚本,这可以解决。