OctopressをVPSにデプロイしようとしていますが、このエラーbundle: not found
が発生しますが、バンドルがインストールされています。
完全なエラー。
$ cap deploy
* 2013-07-20 18:08:55 executing `deploy'
* 2013-07-20 18:08:55 executing `deploy:update'
** transaction: start
* 2013-07-20 18:08:55 executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote [email protected]:website.git HEAD"
command finished in 8348ms
* executing "if [ -d /home/deploy/Ruby_apps/website/shared/cached-copy ]; then cd /home/deploy/Ruby_apps/website/shared/cached-copy && git fetch -q Origin && git fetch --tags -q Origin && git reset -q --hard de26553c0aa7ea583e0bfdec2c103ba83adbb793 && git clean -q -d -x -f; else git clone -q [email protected]:website.git /home/deploy/Ruby_apps/website/shared/cached-copy && cd /home/deploy/Ruby_apps/website/shared/cached-copy && git checkout -q -b deploy de26553c0aa7ea583e0bfdec2c103ba83adbb793; fi"
servers: ["mydomain.com"]
[mydomain.com] executing command
^Acssh revers command finished in 7161ms
copying the cached version to /home/deploy/Ruby_apps/website/releases/20130720123917
* executing "cp -RPp /home/deploy/Ruby_apps/website/shared/cached-copy /home/deploy/Ruby_apps/website/releases/20130720123917 && (echo de26553c0aa7ea583e0bfdec2c103ba83adbb793 > /home/deploy/Ruby_apps/website/releases/20130720123917/REVISION)"
servers: ["mydomain.com"]
[mydomain.com] executing command
command finished in 1868ms
* 2013-07-20 18:09:19 executing `deploy:finalize_update'
triggering before callbacks for `deploy:finalize_update'
* 2013-07-20 18:09:19 executing `bundle:install'
* executing "cd /home/deploy/Ruby_apps/website/releases/20130720123917 && bundle install --gemfile /home/deploy/Ruby_apps/website/releases/20130720123917/Gemfile --path /home/deploy/Ruby_apps/website/shared/bundle --deployment --quiet --without development test"
servers: ["mydomain.com"]
[mydomain.com] executing command
** [out :: mydomain.com] sh: 1:
** [out :: mydomain.com] bundle: not found
** [out :: mydomain.com]
command finished in 1431ms
*** [deploy:update_code] rolling back
* executing "rm -rf /home/deploy/Ruby_apps/website/releases/20130720123917; true"
servers: ["mydomain.com"]
[mydomain.com] executing command
command finished in 1387ms
failed: "sh -c 'cd /home/deploy/Ruby_apps/website/releases/20130720123917 && bundle install --gemfile /home/deploy/Ruby_apps/website/releases/20130720123917/Gemfile --path /home/deploy/Ruby_apps/website/shared/bundle --deployment --quiet --without development test'" on mydomain.com
私はグーグルをしてcap Shell
について知りました、そしてそれから私はPATH変数がおそらくどういうわけか設定されていないことに気づきました
$ cap Shell 1 ↵
* 2013-07-20 18:16:43 executing `Shell'
====================================================================
Welcome to the interactive Capistrano Shell! This is an experimental
feature, and is liable to change in future releases. Type 'help' for
a summary of how to use the Shell.
--------------------------------------------------------------------
cap> echo $PATH
[establishing connection(s) to mydomain.com]
** [out :: mydomain.com] /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
** [out :: mydomain.com]
cap> id
** [out :: mydomain.com] uid=1003(deploy) gid=1003(deploy) groups=1003(deploy),1005(rvm)
** [out :: mydomain.com]
cap>
しかし、deploy @ mydomain.comでsshを実行すると
deploy@mydomain:~$ id
uid=1003(deploy) gid=1003(deploy) groups=1003(deploy),1005(rvm)
deploy@mydomain:~$ echo $PATH
/usr/local/rvm/gems/Ruby-2.0.0-p247/bin:/usr/local/rvm/gems/Ruby-2.0.0-p247@global/bin:/usr/local/rvm/rubies/Ruby-2.0.0-p247/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
deploy@mydomain:~$ grep source .bashrc
# sources /etc/bash.bashrc).
source /etc/profile.d/rvm.sh
deploy@mydomain:~$ rvm list
rvm rubies
Ruby-1.9.3-p429 [ x86_64 ]
=* Ruby-2.0.0-p247 [ x86_64 ]
# => - current
# =* - current && default
# * - default
deploy@mydomain:~$ gem list bundler
*** LOCAL GEMS ***
bundler (1.3.5)
bundler-unload (1.0.1)
deploy@mydomain:~$ gem which bundler
/usr/local/rvm/gems/Ruby-2.0.0-p247@global/gems/bundler-1.3.5/lib/bundler.rb
deploy@mydomain:~$
ここで何が欠けているのか正確にはわかりません。また、source /etc/profile.d/rvm.sh
を.bash_login
に追加しようとしましたが、それでもうまくいきませんでした。
Capistranoは非対話型シェルを使用しているため、bashrcを読み取らないようです。
解決:
これをdeploy.rb
に追加しました
set :default_Shell, '/bin/bash -l'
Capistranoとrvmでbash: bundle: not found
エラーが発生したとき、Pumaを使用していて、Capfileのcapistrano-rvmの後にcapistrano-pumaを要求する必要があることに気付きました。
...
require 'capistrano/rvm'
require 'capistrano/puma'
...
rvm-capistrano を使用する必要があります-このプロジェクトでは、rvmのロードと、rvmやRubyのインストールなどのヘルパータスクを制御できます。