【发布时间】:2013-12-10 09:56:39
【问题描述】:
我正在尝试将我的 ruby 应用程序供应商化,这样我就不必在服务器上手动安装任何 gem,并且可以在我们的 puppet 设置中将我的应用程序部署为 rpm。
这几乎可以正常工作,除了我在 Gemfile 中添加了一个 require 'bundler' 之外,没有任何捆绑器将其添加到供应商目录的痕迹。所以,我的应用程序失败了
no such file to load -- bundler
正是在加载我们的依赖项时。
require 'bundler'
Bundler.setup
我在这里遗漏了什么明显的东西,或者捆绑器实际上不能自行销售吗?
对于它的价值,我使用的是 jruby 1.7.8,并且有问题的应用程序具有以下 Gemfile:
# run with --local to use locally cached gems
# bundle install --full-index --without testing development
# vendorized setup for production
# bundle install --full-index --without testing development --deployment
source 'https://rubygems.org'
gem 'bundler'
gem 'sinatra'
gem 'sinatra-flash'
gem 'sinatra-contrib'
gem 'rack-parser', :require => 'rack/parser'
gem 'dynamic_attributes', :github => 'joona/dynamic_attributes', :require => false
gem 'httparty'
gem 'haml'
gem 'json'
gem 'airbrake'
# gem 'rake'
#gem 'omniauth-google' # TO-DO: deprecate
gem 'bcrypt-ruby', :require => 'bcrypt'
gem 'oauth'
gem 'oauth2'
gem 'omniauth'
gem 'omniauth-dropbox'
gem 'omniauth-facebook'
gem 'omniauth-google-oauth2'
gem 'omniauth-linkedin'
gem 'omniauth-twitter'
gem 'omniauth-windowslive', :git => 'git://github.com/joona/omniauth-windowslive.git'
gem 'lumber'
gem "log4r-gelf"
gem "resque", :github => "resque/resque", :branch => '1-x-stable'
gem "resque-pool"
gem 'tux', :require => false
gem 'actionmailer'
gem 'actionpack', '4.0.1'
gem 'activesupport', '4.0.1', :require => false
gem 'activerecord', '4.0.1'
platforms :jruby do
gem 'activerecord-jdbc-adapter' #, :github => 'jruby/activerecord-jdbc-adapter'
gem 'jdbc-mysql'
gem 'activerecord-jdbcmysql-adapter'
end
platforms :ruby do
gem 'mysql2'
end
group :testing do
gem 'shoulda-matchers', :require => false
gem 'webmock', '1.8.0', :require => false
gem 'database_cleaner', '1.0.1'
gem "sequel", "~> 4.3.0", :require => false
gem 'rspec'
gem 'capybara'
#gem 'vcr'
gem 'simplecov', :require => false
gem 'launchy'
gem 'rack-test', :require => false
gem 'faker'
gem 'fabrication'
gem 'sinatra-sessionography', :require => false
platforms :ruby do
gem 'sqlite3'
end
platforms :jruby do
gem 'jdbc-sqlite3'
end
end
#
group :development do
gem 'guard', "1.8.3", :require => false
gem 'guard-sass', '1.3.2', :require => false
gem 'guard-less', '0.1.2', :require => false
gem 'guard-process', '1.0.6', :require => false
gem 'guard-rspec', '3.1.0', :require => false
gem 'juicer'
gem 'foreman', :require => false
# shotgun with logging quickfix!
#gem 'shotgun', :github => 'joona/shotgun'
gem 'guard-shotgun', :git => 'https://github.com/rchampourlier/guard-shotgun.git'
gem 'capistrano', '~> 2'
gem 'rvm-capistrano'
end
group :production do
platforms :ruby do
gem 'passenger'
end
platforms :jruby do
gem 'fishwife'
end
end
【问题讨论】:
-
您是否尝试过使用
gem 'bundler'(在依赖加载时,除了Gemfile)? -
是的,它在 require 'bundler' 上失败,找不到文件。在 vendor 目录中确实找不到 Bundler。
-
它很脏,但既然你有
vendor文件夹,你可以尝试要求./vendor/bundle/#{RUBY_ENGINE}/#{RUBY_VERSION}/gems/bundler-#{BUNDLER_VERSION}/lib/bundler.rb -
问题是它实际上并不存在,即使我需要 gem
-
最后我决定反对 --standalone,因为它基本上会生成代码并创建备用代码路径。基本上,我现在正在打包 bundler 和 gem 以及我的自定义 ruby 构建。这样就完成了工作,它允许我的供应商化 rpm 调用 Bundler.setup,这似乎是在生产环境中使用供应商化 github 依赖项的唯一方法(这就是我需要可用的捆绑器的原因)。