0

Rails アプリ用のデーモンと capistrano を使用して mailman を本番環境にデプロイしようとしていますが、ローカル マシンで次のエラーが発生します。

SSHKit::Runner::ExecuteError: Exception while executing on host 173.63.11.34: Exception while executing on host 178.62.16.69: script/mailman_daemon.rb exit status: 127
script/mailman_daemon.rb stdout: Nothing written
script/mailman_daemon.rb stderr: /usr/bin/env: ruby: No such file or directory

以下は私のdeploy.rbファイルです:

server '173.63.11.34', port: 22, roles: [:web, :app, :db], primary: true

set :repo_url,        'git@github.com:ryzalyusoff/xxxx.git'
set :application,     'xxxx'
set :user,            'deploy'
set :puma_threads,    [4, 16]
set :puma_workers,    0

set :pty,             false
set :use_sudo,        false
set :stage,           :production
set :deploy_via,      :remote_cache
set :deploy_to,       "/home/#{fetch(:user)}/apps/#{fetch(:application)}"
set :puma_bind,       "unix://#{shared_path}/tmp/sockets/#{fetch(:application)}-puma.sock"
set :puma_state,      "#{shared_path}/tmp/pids/puma.state"
set :puma_pid,        "#{shared_path}/tmp/pids/puma.pid"
set :puma_access_log, "#{release_path}/log/puma.error.log"
set :puma_error_log,  "#{release_path}/log/puma.access.log"
set :ssh_options,     { forward_agent: true, user: fetch(:user), keys: %w(~/.ssh/id_rsa.pub) }
set :puma_preload_app, true
set :puma_worker_timeout, nil
set :puma_init_active_record, true  # Change to false when not using ActiveRecord


set :whenever_identifier, ->{ "myapp_#{fetch(:stage)}" }

namespace :puma do
  desc 'Create Directories for Puma Pids and Socket'
  task :make_dirs do
    on roles(:app) do
      execute "mkdir #{shared_path}/tmp/sockets -p"
      execute "mkdir #{shared_path}/tmp/pids -p"
    end
  end

  before :start, :make_dirs
end

namespace :deploy do
  desc "Make sure local git is in sync with remote."
  task :check_revision do
    on roles(:app) do
      unless `git rev-parse HEAD` == `git rev-parse origin/master`
        puts "WARNING: HEAD is not the same as origin/master"
        puts "Run `git push` to sync changes."
        exit
      end
    end
  end

  desc 'Initial Deploy'
  task :initial do
    on roles(:app) do
      before 'deploy:restart', 'puma:start'
      invoke 'deploy'
    end
  end

  desc 'Restart application'
  task :restart do
    on roles(:app), in: :sequence, wait: 5 do
      invoke 'puma:restart'
    end
  end

  before :starting,     :check_revision
  after  :finishing,    :compile_assets
  after  :finishing,    :cleanup
  after  :finishing,    :restart

end


# Mailman configuration
namespace :mailman do
  desc "Mailman::Start"
  task :start do
    on roles(:app) do
      within release_path do
        with default_env: fetch(:default_env) do
          execute "script/mailman_daemon.rb", "start"
        end
      end
    end
  end

  desc "Mailman::Stop"
  task :stop do
    on roles(:app) do
      within release_path do
        with default_env: fetch(:default_env) do
          execute "script/mailman_daemon.rb", "stop"
        end
      end
    end
  end

  desc "Mailman::Restart"
  task :restart do
    on roles(:app) do
      invoke("mailman:stop")
      invoke("mailman:start")
    end
  end
end

before "deploy:cleanup", "mailman:restart"

以下は私のgemfileです:

source 'https://rubygems.org'

ruby "2.0.0"

gem 'rails', '4.2.3'
gem 'mysql2', '~> 0.3.18'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc

group :development, :test do
  gem 'byebug'
  gem 'web-console', '~> 2.0'
  gem "rails-erd"
  gem 'capistrano',           require: false
  gem 'capistrano-rvm',       require: false
  gem 'capistrano-rails',     require: false
  gem 'capistrano-bundler',   require: false
  gem 'capistrano3-puma',     require: false
  gem 'rvm1-capistrano3', require: false
end

group :production do
  gem 'rails_12factor', '0.0.2'
  gem 'thin'
  gem 'puma', '3.1.0'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'bootstrap-sass', '~> 3.3.4.1'
gem "better_errors"
gem "devise"
gem 'rails_admin', '~> 0.6.8'
gem 'jquery-ui-rails'
gem 'execjs'
gem 'therubyracer', :platforms => :ruby
gem "compass-rails", github: "Compass/compass-rails", branch: "master"
gem 'sucker_punch', '~> 2.0', '>= 2.0.1'
gem 'carrierwave'
gem "fog-aws"

# Sending SMS
gem 'twilio-ruby'
gem 'postmark-rails', "~> 0.5.2"
# Cronjob
gem 'whenever', '~> 0.9.4'
gem 'griddler'
gem 'mailman'
gem 'email_reply_parser', '~> 0.5.8'
gem 'mail_extract', '~> 0.1.4'
gem 'daemons', '~> 1.2', '>= 1.2.3'
gem 'delayed_job_active_record'

capistrano (3.4.0) と capistrano-rvm (0.1.2) を使用しています。

そして、このスレッドで提案されているように rvm1-capistrano3 と rvm-capistrano gem を使用しようとしましたが、うまくいきませんでした。

誰か助けてくれませんか?

ありがとう!

###################### 更新 1 ####################

これは私がgit grep usr.bin.envローカルマシンで行っていることです:

bin/bundle:#!/usr/bin/env ruby.exe
bin/delayed_job:#!/usr/bin/env ruby
bin/rails:#!/usr/bin/env ruby.exe
bin/rake:#!/usr/bin/env ruby.exe
bin/setup:#!/usr/bin/env ruby.exe
script/mailman_daemon.rb:#!/usr/bin/env ruby
script/mailman_server:#!/usr/bin/env ruby

###################### 更新 2 ####################

~/.bash_profile で rvm のパスを既に設定しています。

export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
~   
4

2 に答える 2