2014-07-18 45 views
1

我寫了我的第一個gem(ruby noob alert!)。將其部署到我當地的寶石目錄我跑:自定義Gem執行失敗,出現NoMethodError

bundle install 
bundle exec rake install 

在這一點上,我嘗試從命令行運行我的寶石。我得到一個神祕的錯誤:

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>' 

,當我跑捆綁安裝更換斌/ my_gem的內容與它自己的代碼。我沒有添加修改這個文件稍微嘗試調試。失敗似乎發生在Gem.bin_path中。這裏有斌/ 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') 

我在爲下一步做什麼其他的損失比新鮮的寶石開始。有任何想法嗎?

回答

1

它看起來像你遇到這個問題,https://github.com/bundler/bundler/issues/2838

因爲捆紮機記得傳給install標誌,如果你跑了過去bundle install --binstubs,它將重新產生對後續的bundle install運行的binstubs。您可以運行bundle config --delete bin刪除該設置,然後恢復原始的可執行文件。

+0

很酷。我會在星期一嘗試。奇怪它記得以前的命令。 –

+0

我還有其他問題,但你的答案肯定讓我再次前進。謝謝! –

相關問題