我最近搬到了新的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 list
展示了mini_exiftool (2.9.0)
等。如果我硬编码到require '/Users/gscar/.gem/ruby/2.5.1/gems/mini_exiftool-2.9.0/lib/mini_exiftool.rb'
然后脚本在另一个宝石上失败。
好的,我想我现在有了。要走一跳:
将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]
这现在有效。不幸的是,我不太确定修复是什么,因为这个原因而称之为答案可能并不公平,而且我仍然遇到从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脚本,这是一个解决方法。