如何更改 Capistrano 3 中调用的捆绑器?
How do I change the bundler called in Capistrano 3?
我正在多用户、多服务器环境 (Site5) 中进行部署。
我正在部署 rails 4 应用程序。默认环境是ruby1.8.7,rails3.0.
可以访问ruby的本地版本,
在调用捆绑器之前一切正常。
这是错误片段:
INFO [4439d586] Running /usr/bin/env bundle install --path /home/username/apps/todos/shared/bundle --without development test --deployment --quiet as username@dirktaylor.ca
DEBUG [4439d586] Command: cd /home/username/apps/todos/releases/20160121174533 && ( export RUBY_BIN_PATH="/usr/local/ruby20/bin" PATH="/usr/local/ruby20/bin:/usr/username/ruby/gems/gems/bundler-1.11.2/exe:$PATH" ; /usr/bin/env bundle install --path /home/username/apps/todos/shared/bundle --without development test --deployment --quiet )
DEBUG [4439d586] Gem::InstallError: i18n requires Ruby version >= 1.9.3.
DEBUG [4439d586] An error occurred while installing i18n (0.7.0), and Bundler cannot continue.
Make sure that `gem install i18n -v '0.7.0'` succeeds before bundling.
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as username@dirktaylor.ca: bundle exit status: 5
bundle stdout: Gem::InstallError: i18n requires Ruby version >= 1.9.3.
An error occurred while installing i18n (0.7.0), and Bundler cannot continue.
Make sure that `gem install i18n -v '0.7.0'` succeeds before bundling.
bundle stderr: Nothing written
如您所见,我在调用 bundle 命令之前设置了环境变量。
所以,这就是我的想法...
因为 Capistrano 3 正在执行所有 /usr/bin/env
和 /usr/bin/env bundle install ...
特别是,它没有找到要使用的正确版本的捆绑器。
username@dirktaylor.ca [~2]# /usr/bin/env bundle -v;whereis bundle
Bundler version 1.2.1
bundle: /usr/bin/bundle
(注意:/usr/bin/env 链接到 /bin/env )
我已经安装了 bundler (gem install bundler
) 的当前用户,它现在位于 ~/ruby/gems/gems/bundler-1.11.2 中,可执行脚本位于 ~/ruby/gems/gems/bundler-1.11.2/exe/bundle
所以呢?现在怎么办?
1) 我怎样才能让这个版本的 bundler 执行?
2) 此外,在脚本中它调用 #!/usr/bin/env ruby
。我应该将其更改为正确的 ruby 路径吗?
3) 我在其他地方看到了第 2 章的这个解决方案:
set :bundle_cmd, "/usr/username/ruby/gems/gems/bundler-1.11.2/exe/bundle"
set :bundle_dir, "/usr/username/ruby/gems/gems/bundler-1.11.2"
所以问题仍然存在:如何更改 Capistrano 3 中调用的捆绑程序?
(最后:不用rvm也能解决吗?)
在 Capistrano 3 中有一个 "command map" 的概念,它允许您覆盖用于任意命令的字符串。如果您想将 bundle
映射到 /usr/username/ruby/gems/gems/bundler-1.11.2/exe/bundle
,假设。
你这样做:
# Put this in deploy.rb or production.rb, etc.
SSHKit.config.command_map[:bundle] = "/usr/username/ruby/gems/gems/bundler-1.11.2/exe/bundle"
我正在多用户、多服务器环境 (Site5) 中进行部署。
我正在部署 rails 4 应用程序。默认环境是ruby1.8.7,rails3.0.
可以访问ruby的本地版本,
在调用捆绑器之前一切正常。
这是错误片段:
INFO [4439d586] Running /usr/bin/env bundle install --path /home/username/apps/todos/shared/bundle --without development test --deployment --quiet as username@dirktaylor.ca
DEBUG [4439d586] Command: cd /home/username/apps/todos/releases/20160121174533 && ( export RUBY_BIN_PATH="/usr/local/ruby20/bin" PATH="/usr/local/ruby20/bin:/usr/username/ruby/gems/gems/bundler-1.11.2/exe:$PATH" ; /usr/bin/env bundle install --path /home/username/apps/todos/shared/bundle --without development test --deployment --quiet )
DEBUG [4439d586] Gem::InstallError: i18n requires Ruby version >= 1.9.3.
DEBUG [4439d586] An error occurred while installing i18n (0.7.0), and Bundler cannot continue.
Make sure that `gem install i18n -v '0.7.0'` succeeds before bundling.
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as username@dirktaylor.ca: bundle exit status: 5
bundle stdout: Gem::InstallError: i18n requires Ruby version >= 1.9.3.
An error occurred while installing i18n (0.7.0), and Bundler cannot continue.
Make sure that `gem install i18n -v '0.7.0'` succeeds before bundling.
bundle stderr: Nothing written
如您所见,我在调用 bundle 命令之前设置了环境变量。
所以,这就是我的想法...
因为 Capistrano 3 正在执行所有 /usr/bin/env
和 /usr/bin/env bundle install ...
特别是,它没有找到要使用的正确版本的捆绑器。
username@dirktaylor.ca [~2]# /usr/bin/env bundle -v;whereis bundle
Bundler version 1.2.1
bundle: /usr/bin/bundle
(注意:/usr/bin/env 链接到 /bin/env )
我已经安装了 bundler (gem install bundler
) 的当前用户,它现在位于 ~/ruby/gems/gems/bundler-1.11.2 中,可执行脚本位于 ~/ruby/gems/gems/bundler-1.11.2/exe/bundle
所以呢?现在怎么办?
1) 我怎样才能让这个版本的 bundler 执行?
2) 此外,在脚本中它调用 #!/usr/bin/env ruby
。我应该将其更改为正确的 ruby 路径吗?
3) 我在其他地方看到了第 2 章的这个解决方案:
set :bundle_cmd, "/usr/username/ruby/gems/gems/bundler-1.11.2/exe/bundle"
set :bundle_dir, "/usr/username/ruby/gems/gems/bundler-1.11.2"
所以问题仍然存在:如何更改 Capistrano 3 中调用的捆绑程序?
(最后:不用rvm也能解决吗?)
在 Capistrano 3 中有一个 "command map" 的概念,它允许您覆盖用于任意命令的字符串。如果您想将 bundle
映射到 /usr/username/ruby/gems/gems/bundler-1.11.2/exe/bundle
,假设。
你这样做:
# Put this in deploy.rb or production.rb, etc.
SSHKit.config.command_map[:bundle] = "/usr/username/ruby/gems/gems/bundler-1.11.2/exe/bundle"