bundle install
作为vagrant up
配置我的虚拟机的一部分,我在处理我的 Rails 应用程序依赖项时遇到了一些麻烦。
我遇到的问题是让捆绑安装以具有正确 rvm 的正确用户(vagrant)身份运行。
所以我的 rvm 是通过 Berkshelf 设置的,配置如下:
rvm: {
rubies: ['2.0.0'],
default_ruby: '2.0.0',
global_gems: [{ name: 'bundler' },
{ name: 'rake' }],
vagrant: { system_chef_solo: '/usr/bin/chef-solo' }
}
我正在使用以下 RVM 配方:
chef.run_list = [
'recipe[apt]',
'recipe[rvm]',
'recipe[rvm::vagrant]',
'recipe[rvm::system]',
'recipe[rvm::gem_package]',
'recipe[mongodb::10gen_repo]',
'recipe[mongodb]',
'recipe[nodejs]',
'recipe[phantomjs]',
'recipe[lasso-plan]'
]
(注意套索计划是我自己的本地计划)
现在如果我尝试:
execute 'bundle install' do
cwd node['lasso_plan']['path']
user 'vagrant'
end
或者
rvm_shell "bundle the gems" do
cwd node['lasso_plan']['path']
code 'bundle install'
user 'vagrant'
end
我明白了
STDERR: /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/dependency.rb:296:in `to_specs': Could not find 'bundler' (>= 0) among 74 total gem(s) (Gem::LoadError)`
而没有用户声明,它似乎可以很好地安装 gem,但它们不能作为 vagrant 用户访问。
我假设这是因为 rvm 并且它以不同的方式对待用户,如果有人能阐明如何推进这一点,那就太好了。
谢谢
更新
因此,经过一些帮助(谢谢),我在这方面取得了一些进展,我发现以前报告过类似的问题:http: //lists.opscode.com/sympa/arc/chef/2012-05/msg00153.html
目前我有一些工作可以通过运行:
rvm_shell 'bundle the gems' do
ruby_string ruby_version
cwd node['lasso_plan']['path']
code 'bundle install --path .bundle'
user 'vagrant'
end
这允许将捆绑包安装在我的应用程序的目录中,它的缺点是垃圾箱不在路径中,但这可以通过bundle exec
如果我运行:
rvm_shell 'bundle the gems' do
ruby_string ruby_version
cwd node['lasso_plan']['path']
code 'bundle install'
user 'vagrant'
end
我收到以下错误:
STDERR: /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/fileutils.rb:245:in `mkdir': Permission denied - /root/.bundler (Errno::EACCES)
from /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/fileutils.rb:245:in `fu_mkdir'
from /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/fileutils.rb:219:in `block (2 levels) in mkdir_p'
from /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/fileutils.rb:217:in `reverse_each'
from /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/fileutils.rb:217:in `block in mkdir_p'
from /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/fileutils.rb:203:in `each'
from /usr/local/rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/fileutils.rb:203:in `mkdir_p'
from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/source/git/git_proxy.rb:46:in `checkout'
from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/source/git.rb:144:in `specs'
from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/lazy_specification.rb:52:in `__materialize__'
from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:88:in `block in materialize'
from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `map!'
from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `materialize'
from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/definition.rb:114:in `specs'
from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/definition.rb:109:in `resolve_remotely!'
from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/installer.rb:83:in `run'
from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/installer.rb:14:in `install'
from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/cli.rb:247:in `install'
from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/vendor/thor/task.rb:27:in `run'
from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/vendor/thor/invocation.rb:120:in `invoke_task'
from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/vendor/thor.rb:344:in `dispatch'
from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/vendor/thor/base.rb:434:in `start'
from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/bin/bundle:20:in `block in <top (required)>'
from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler/friendly_errors.rb:3:in `with_friendly_errors'
from /usr/local/rvm/gems/ruby-2.0.0-p247@global/gems/bundler-1.3.5/bin/bundle:20:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.0.0-p247@global/bin/bundle:23:in `load'
from /usr/local/rvm/gems/ruby-2.0.0-p247@global/bin/bundle:23:in `<main>'
from /usr/local/rvm/gems/ruby-2.0.0-p247@global/bin/ruby_noexec_wrapper:14:in `eval'
from /usr/local/rvm/gems/ruby-2.0.0-p247@global/bin/ruby_noexec_wrapper:14:in `<main>'
---- End output of "bash" "/tmp/chef-script20130711-23336-uqohfl" ----
我认为这可能与此处概述的 sudo 问题有关:https ://github.com/bundler/bundler/blob/master/man/bundle-install.ronn因为我假设厨师使用 sudo 作为流浪者运行用户,它可能认为主目录是/root/
然后如果我不指定用户并以root身份运行它:
rvm_shell 'bundle the gems' do
ruby_string ruby_version
cwd node['lasso_plan']['path']
code 'bundle install'
end
它安装了其中的大多数,但没有安装我引用 git 存储库的那些,以及关于缺失的不存在的错误,如下所示:
Gems included by the bundle:
git://github.com/bkeepers/dotenv.git (at master) is not checked out. Please run
`bundle install`
bundle install
如果我想再次运行,我不确定由 root 而不是 vagrant 用户安装捆绑包是否会有其他影响
所以理想情况下,我想以用户身份安装到 gem 路径而不是应用程序中的 .bundle (或者如果我至少不明白为什么)。谢谢您的帮助