我无法通过 mina deploy 部署我的 rails 应用程序

I can't deploy my rails app via mina deploy

我正在尝试通过 mina 部署将 Rails 应用程序(5.2.0 和 Ruby 2.4.0)部署到服务器(Ubuntu 16.04.2 LTS)。我已经配置了要部署的文件,但是当我尝试 运行 mina deploy 时,我收到错误:bash: line 145: bundle: command not found。像这样:

mina deploy
-----> Creating a temporary build path
-----> Using RVM environment "ruby-2.4.0@marconPortfolio"
       Using /usr/local/rvm/gems/ruby-2.4.0 with gemset marconPortfolio
-----> Deploying marconPortfolio to 165.227.63.110:/home/rails/marcon
-----> Fetching new git commits
       remote: Counting objects: 8, done.
remote: Compressing objects: 100% (8/8), done.
       remote: Total 8 (delta 6), reused 0 (delta 0)
Unpacking objects: 100% (8/8), done.   
       From bitbucket.org:felipeemarcon/marcon-portfolio
          6113173..1f02042  master     -> master
-----> Using git branch 'master'
       Cloning into '.'...
       done.
-----> Using this git commit
       Felipe Marcon (1f02042):
       > Rvm path in deploy
-----> Symlinking shared paths
-----> Installing gem dependencies using Bundler
       bash: line 145: bundle: command not found
 !     ERROR: Deploy failed.
-----> Cleaning up build
       Unlinking current
       OK
       Connection to 165.227.63.110 closed.

 !     Run Error

我已经搜索了很多地方如何解决这个问题,但没有任何帮助。我该如何解决这个问题?

我已经 运行 "gem install bundle" 在我的服务器中,当我 运行 "bundle --version" 它 returns 捆绑程序的版本时,它已安装。我服务器中的 ruby 版本与本地版本相同 (ruby 2.4.0)。我不知道该怎么做才能解决这个问题。谁能帮帮我?

哦,如果相关的话,我正在使用 Puma 作为应用程序服务器。

deploy.rb

require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rvm'
require 'mina/puma'

set :domain, '165.227.63.110'

set :deploy_to, '/home/rails/marcon'

set :repository, 'git@bitbucket.org:felipeemarcon/marcon-portfolio.git'

set :branch, 'master'

set :shared_dirs, fetch(:shared_dirs, []).push('log', 'tmp/pids', 'tmp/sockets', 'public/uploads')
set :shared_files, fetch(:shared_files, []).push('config/database.yml', 'config/secrets.yml', 'config/puma.rb')

set :user, 'root'

set :application_name, 'marconPortfolio'
set :ssh_flags, '-l root'
set :rvm_use_path, '/usr/local/rvm/scripts/rvm'


task :remote_environment do
  invoke :'rvm:use', 'ruby-2.4.0@marconPortfolio'
end

task :setup do
  command %[touch "#{fetch(:shared_path)}/config/database.yml"]
  command %[touch "#{fetch(:shared_path)}/config/secrets.yml"]
  command %[touch "#{fetch(:shared_path)}/config/puma.rb"]
  comment "Be sure to edit '#{fetch(:shared_path)}/config/database.yml', 'secrets.yml' and puma.rb."
end

task :deploy do
  deploy do
    comment "Deploying #{fetch(:application_name)} to #{fetch(:domain)}:#{fetch(:deploy_to)}"
    invoke :'git:clone'
    invoke :'deploy:link_shared_paths'
    # invoke :'rvm:load_env_vars'
    invoke :'bundle:install'
    invoke :'rails:db_migrate'
    command %{#{fetch(:rails)} db:seed}
    invoke :'rails:assets_precompile'
    invoke :'deploy:cleanup'

    on :launch do
      command "export RAILS_ENV=production"
      invoke :'puma:phased_restart'
      command '/etc/init.d/nginx restart'
      command 'rm -f /home/rails/marcon/current/public/system/'
      command "ln -s /home/rails/marcon/current/public/"
    end
  end
end

puma.rb:

threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
threads threads_count, threads_count

port        ENV.fetch("PORT") { 3000 }

environment ENV.fetch("RAILS_ENV") { "development" }

plugin :tmp_restart

bind "unix:/home/rails/marcon/shared/tmp/sockets/puma.sock" if ENV.fetch("RAILS_ENV") == 'production'

谢谢。

尝试 运行 {sudo gem install bundler} 然后尝试部署。 如果这不起作用,那么您可能需要将 ruby gem 可执行目录添加到您的路径中。

我解决了这个问题。我将我的项目直接克隆到我的服务器,安装依赖项,之后,我从我的本地机器运行 mina deploy。现在一切正常。

但我仍然认为这不应该像这样工作。 mina deploy 在服务器中,我应该不能第一时间部署我的应用程序吧?

谢谢大家