2
我正在嘗試爲Rails 3.1創建自定義生成器。而我寫這篇:爲什麼'bundle install'在Rails生成器中失敗?
module SomeGem
module Generators
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path('../templates', __FILE__)
desc "This adds devise"
def install
gem "devise"
run "bundle install"
end
end
end
end
但是當我運行這個生成器(軌道摹somegem:安裝,在新鮮生成的Rails應用程序),我已經收到此錯誤:
gemfile devise
run bundle install
Could not find gem 'devise (>= 0)' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.
我發生器增加正確設計Gemfile,但在從生成器運行「bundle install」命令時失敗。當我從控制檯運行「捆綁安裝」時,它會安裝所有gem而不會出現任何錯誤。
這是怎麼發生的?
這是我的Gemfile我跑後 '軌道摹somegem:安裝'(我刪除了自上市註釋):
source 'http://rubygems.org'
source 'http://gemcutter.org'
source "http://gems.github.com"
gem 'rails', '3.1.0'
gem 'mysql2'
group :assets do
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> 3.1.0"
gem 'uglifier'
end
gem 'jquery-rails'
group :test do
# Pretty printed test output
gem 'turn', :require => false
end
gem 'therubyracer'
gem "devise"
請確保您在運行'bundle install'命令時連接到網絡 –