3

VMbundle installの構成の一環として、Rails アプリの依存関係を実行するのに問題があります。vagrant up

私が抱えている問題は、正しい 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を使用してvagrantとして実行すると仮定しているためユーザーであり、ホームディレクトリが/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もう一度実行したい場合、vagrant ユーザーではなく root によってバンドルをインストールすることに他の影響があるかどうかはわかりません。

したがって、理想的には、ユーザーとしてアプリの .bundle ではなく、gem パスにインストールしたいと考えています (または、少なくともその理由を理解できない場合)。助けてくれてありがとう

4

4 に答える 4