LoginSignup
0
1

More than 5 years have passed since last update.

capistranoでbundleがないと言われ、コケまくるとき

Posted at

AmazonLinuxでruby24が入るようになった。
それを使ってrailsアプリをあげようとcapistranoでデプロイしようとしたら

00:08 bundler:install
      01 bundle install --path /home/ec2-user/rails_app/shared/bundle --without development test --quiet
      01 /usr/bin/env:
      01 bundle
      01 : そのようなファイルやディレクトリはありません
      01

で、エラーになり進まない。
いろいろと調べるとconfigを変えたり、sshのconfigを変えたり、と出てくるが
ここでcapistrano実行中での環境変数を調べた。

deploy.rb
# deploy tasks
namespace :deploy do
  desc 'bundle update exec'
  task :see_env do
    on roles(:app) do |host|
      execute "cd #{fetch :deploy_to}/releases/20180********; echo $PATH"
    end
  end
end

を見ると、which bundleのパスが含まれていない。

さらにgem environmentも確認

RubyGems Environment:
  - RUBYGEMS VERSION: 2.7.7
  - RUBY VERSION: 2.4.4 (2018-03-28 patchlevel 296) [x86_64-linux-gnu]
  - INSTALLATION DIRECTORY: /home/ec2-user/.gem/ruby/2.4
  - USER INSTALLATION DIRECTORY: /home/ec2-user/.gem/ruby/2.4
  - RUBY EXECUTABLE: /usr/bin/ruby2.4
  - EXECUTABLE DIRECTORY: /home/ec2-user/bin
  - SPEC CACHE DIRECTORY: /home/ec2-user/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /etc
(以下略)

ということで、bundleは/home/ec2-user/binに入っている。

なので、capistrano実行時にpathを追加する。

config/deploy.rb
# Default value for default_env is {}
set :default_env, { path: "/home/ec2-user/bin:$PATH" }

を、追加して再度実行すると無事にbundleが動いた。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1