mina-deploy / mina

Blazing fast deployer and server automation tool
https://rubygems.org/gems/mina
Other
4.35k stars 490 forks source link

undefined local variable or method current_path #483

Closed folivi closed 7 years ago

folivi commented 7 years ago

Hi, I'm having this issue with on ruby 2.3.0 and not on ruby 2.2.3

NameError: undefined local variable or method `current_path' for main:Object

Any idea how to fix it?

Cheers

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

set :term_mode, nil
set :domain, 'mydomain.com'
set :rails_env, 'production'
set :deploy_to, "/home/user/rails/myapp/#{rails_env}"
set :repository, 'mygit'
set :app_path,   "#{deploy_to}/#{current_path}"

set :branch, 'master'
set :user, 'myuser'

# For system-wide RVM install.
set :rvm_path, '/usr/local/rvm/scripts/rvm'

set :shared_paths, ['config/database.yml', 'config/secrets.yml', 'log']

set :port, '2242'     # SSH port number.
set :forward_agent, true     # SSH forward_agent.
task :environment do

  invoke :'rvm:use[ruby-2.3.0]'
end

task :setup => :environment do
  queue! %[mkdir -p "#{deploy_to}/#{shared_path}/log"]
  queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/log"]

  queue! %[mkdir -p "#{deploy_to}/#{shared_path}/config"]
  queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/config"]

  queue! %[touch "#{deploy_to}/#{shared_path}/config/database.yml"]
  queue! %[touch "#{deploy_to}/#{shared_path}/config/secrets.yml"]
  queue  %[echo "-----> Be sure to edit '#{deploy_to}/#{shared_path}/config/database.yml' and 'secrets.yml'."]

  if repository
    repo_host = repository.split(%r{@|://}).last.split(%r{:|\/}).first
    repo_port = /:([0-9]+)/.match(repository) && /:([0-9]+)/.match(repository)[1] || '22'

    queue %[
      if ! ssh-keygen -H  -F #{repo_host} &>/dev/null; then
        ssh-keyscan -t rsa -p #{repo_port} -H #{repo_host} >> ~/.ssh/known_hosts
      fi
    ]
  end
end

desc "Deploys the current version to the server."
task :deploy => :environment do
  to :before_hook do
    # Put things to run locally before ssh
  end
  deploy do
    # Put things that will set up an empty directory into a fully set-up
    # instance of your project.
    invoke :'git:clone'
    invoke :'deploy:link_shared_paths'
    invoke :'bundle:install'
    invoke :'rails:db_migrate'
    invoke :'rails:assets_precompile'
    invoke :'deploy:cleanup'

    to :launch do      
      queue "mkdir -p #{deploy_to}/#{current_path}/tmp/"
      queue "touch #{deploy_to}/#{current_path}/tmp/restart.txt"
    end
  end
end
d4be4st commented 7 years ago

On ruby 2.3.0 you installed newest version of mina (1.0.x) which is not backwards compitable.

https://github.com/mina-deploy/mina/blob/master/docs/migrating.md