我无法通过mina deploy

时间:2018-04-22 18:03:17

标签: ruby-on-rails ruby rvm mina

我尝试通过mina deploy将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

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

我已经运行了#34; gem install bundle"在我的服务器上,当我运行"捆绑--version"它返回bundler的版本,因此已安装。我服务器中的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'

感谢。

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

我解决了这个问题。我将我的项目直接克隆到我的服务器,安装依赖项,然后,我从我的本地机器上修改了mina部署。现在一切正常。

但我仍然认为这不应该像这样。我不应该在服务器中mina deploy第一次部署我的应用程序吗?

谢谢大家。