stderr /usr/local/bin/bundle: 安装包时参数列表太长

stderr /usr/local/bin/bundle: argument list too long while bundle install

我正在使用 ansible 为我的 rails 应用程序进行部署。问题是当添加新的 gem 和 ansible 运行s bundle install 时,会出现以下错误:

stderr /usr/local/bin/bundle: argument list too long
/usr/local/bin/bundle: line 7: /usr/local/bin/bundle: success

捆绑安装的可靠任务是

- name: Bundle install
  command: 'bundle install --deployment --without development test'
  register: bundler
  args:
    chdir: '/home/ubuntu/myproject'

我正在使用 rvm 来管理 ruby 版本。使用 ruby-2.2.1 并且我已将 rvm 设置为使用 gem 组 myproject 即 rvm use ruby-2.2.1@myproject.

.rvm/gems/目录有ruby-2.2.1/ruby-2.2.1@global/ruby-2.2.1@myproject/

我指定了passenger_ruby /home/ubuntu/.rvm/wrappers/ruby-2.2.1@myproject/ruby

只有在 Gemfile 中添加新 gem 时才会发生这种情况,当只有代码更新时,一切正常。如果我 运行 bundle install 明确地对相应的实例执行 ssh,它工作正常并安装 gem。 对此有何帮助和建议?

我知道了。问题与脚本使用的包路径有关 /usr/local/bin/bundle 但它应该来自 /home/ubuntu/.rvm/gems/ruby-2.2.1@myproject/bin/bundle

ansible的正确任务是

- name: Bundle install
  command: bundle install --without development test
  args:
    chdir: /home/ubuntu/myproject
    executable: /home/ubuntu/.rvm/gems/ruby-2.2.1@myproject/bin/bundle
  environment:
    GEM_HOME:  /home/ubuntu/.rvm/gems/ruby-2.2.1@myproject
    GEM_PATH:  /home/ubuntu/.rvm/gems/ruby-2.2.1@myproject:/home/ubuntu/.rvm/gems/ruby-2.2.1@global