我写了第一个宝石(ruby noob alert!)。要将它部署到我的本地gem目录中,我运行了:
bundle install
bundle exec rake install
此时我尝试从命令行运行我的gem。我得到一个神秘的错误:
my_gem
Gem File Location:
C:/ruby193/lib/ruby/gems/1.9.1/gems/my_gem-0.0.1/Gemfile
fatal: Not a git repository (or any of the parent directories): .git
getting Gem.bin_path()
C:/ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.6.3/lib/bundler/rubygems_integration.rb:305:in `block in replace_bin_path': undefined method `name' for nil:NilClass (NoMethodError)
from C:/ruby193/lib/ruby/gems/1.9.1/gems/my_gem-0.0.1/bin/my_gem:20:in `<top (required)>'
from C:/ruby193/bin/my_gem:23:in `load'
from C:/ruby193/bin/my_gem:23:in `<main>'
当我运行bundle install时,它用自己的代码替换了bin / my_gem的内容。我确实添加了修改这个文件稍微试图调试。失败似乎发生在Gem.bin_path中。以下是bin / my_gem的内容:
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'my_gem' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
puts "Gem File Location: "
puts(ENV['BUNDLE_GEMFILE'])
require 'rubygems'
require 'bundler/setup'
puts "getting Gem.bin_path()"
path = Gem.bin_path('my_gem', 'my_gem') # this is the line that causes the error
puts "Gem.bin_path(): #{path}"
load Gem.bin_path('my_gem', 'my_gem')
除了重新开始使用新宝石之外,我不知道接下来要做什么。有什么想法吗?
答案 0 :(得分:1)
您似乎遇到了此问题https://github.com/bundler/bundler/issues/2838
因为Bundler会记住传递给install
的标志,如果您曾经运行过bundle install --binstubs
,它会在后续运行bundle install
时重新生成binstub。您可以运行bundle config --delete bin
删除该设置,然后恢复原始可执行文件。