mina-deploy / mina

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

NoMethodError: undefined method `to' for main:Object #522

Closed wonderer007 closed 7 years ago

wonderer007 commented 7 years ago

Last time I deployed my code with this deploy.rb it worked fine but at the moment but not its giving me error

mina aborted!
NoMethodError: undefined method `to' for main:Object
/Users/haiderali/Development/SalonApp/config/deploy.rb:104:in `block (2 levels) in <top (required)>'
/Users/haiderali/.rvm/gems/ruby-2.3.0/gems/mina-1.0.6/lib/mina/helpers/internal.rb:7:in `deploy_script'
/Users/haiderali/.rvm/gems/ruby-2.3.0/gems/mina-1.0.6/lib/mina/dsl.rb:50:in `block in deploy'
/Users/haiderali/.rvm/gems/ruby-2.3.0/gems/mina-1.0.6/lib/mina/dsl.rb:29:in `run'
/Users/haiderali/.rvm/gems/ruby-2.3.0/gems/mina-1.0.6/lib/mina/dsl.rb:49:in `deploy'
/Users/haiderali/Development/SalonApp/config/deploy.rb:94:in `block in <top (required)>'
/Users/haiderali/.rvm/gems/ruby-2.3.0/gems/mina-1.0.6/lib/mina/application.rb:16:in `run'
/Users/haiderali/.rvm/gems/ruby-2.3.0/gems/mina-1.0.6/bin/mina:4:in `<top (required)>'
/Users/haiderali/.rvm/gems/ruby-2.3.0/bin/mina:23:in `load'
/Users/haiderali/.rvm/gems/ruby-2.3.0/bin/mina:23:in `<main>'
/Users/haiderali/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
/Users/haiderali/.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => deploy
(See full trace by running task with --trace

deploy.rb is

require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/puma'
require 'mina/nginx'
# require 'mina/rbenv'  # for rbenv support. (http://rbenv.org)
require 'mina/rvm'    # for rvm support. (http://rvm.io)

# Basic settings:
#   domain       - The hostname to SSH to.
#   deploy_to    - Path to deploy into.
#   repository   - Git repo to clone from. (needed by mina/git)
#   branch       - Branch name to deploy. (needed by mina/git)

#set :rails_env, 'production'
set :domain, 'xx.xxx.xxx.xxx'
set :deploy_to, '/var/www/SalonApp'
set :repository, 'git@bitbucket.org:jalapenoapps/salonweb.git'
set :branch, 'deploy'

# For system-wide RVM install.
set :rvm_path, '/home/ubuntu/.rvm/bin/rvm'

# Manually create these paths in shared/ (eg: shared/config/database.yml) in your server.
# They will be linked in the 'deploy:link_shared_paths' step.
set :shared_paths, ['config/database.yml', 'config/secrets.yml', 'log', "tmp/sockets", "tmp/pids"]

set :user, 'ubuntu'
# set :port, '22'
set :ssh_options, '-A'

# Optional settings:
#   set :user, 'foobar'    # Username in the server to SSH to.
#   set :port, '30000'     # SSH port number.
#   set :forward_agent, true     # SSH forward_agent.

# This task is the environment that is loaded for most commands, such as
# `mina deploy` or `mina rake`.
task :environment do
  # If you're using rbenv, use this to load the rbenv environment.
  # Be sure to commit your .ruby-version or .rbenv-version to your repository.
  # invoke :'rbenv:load'

  # For those using RVM, use this to load an RVM version@gemset.
  invoke :'rvm:use', 'ruby-2.3.0@default'
end

# Put any custom mkdir's in here for when `mina setup` is ran.
# For Rails apps, we'll make some of the shared paths that are shared between
# all releases.
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}/tmp"]
  queue! %[chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/tmp"]

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

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

  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! %[touch "#{deploy_to}/#{shared_path}/config/nginx.conf"]

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

  # Puma needs a place to store its pid file and socket file.
  queue! %(mkdir -p "#{deploy_to}/#{shared_path}/tmp/sockets")
  queue! %(chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/tmp/sockets")
  queue! %(mkdir -p "#{deploy_to}/#{shared_path}/tmp/pids")
  queue! %(chmod g+rx,u+rwx "#{deploy_to}/#{shared_path}/tmp/pids")

  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
  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
#      invoke :'puma:restart'
      invoke :'puma:restart'
      invoke :'nginx:restart'
    end
  end
end

can anyone please spot the issue, I have google enough but no help Thanks in advance

artem-russkikh commented 7 years ago

Your configuration is for older version, check https://github.com/mina-deploy/mina/blob/master/docs/migrating.md

wonderer007 commented 7 years ago

@artem-russkikh now getting this error

-----> Creating a temporary build path
-----> Using RVM environment "ruby-2.3.0"
       Using /home/ubuntu/.rvm/gems/ruby-2.3.0
-----> Cloning the Git repository
       Cloning into bare repository '/var/www/SalonApp/scm'...
       remote: Counting objects: 2180, done.
remote: Compressing objects: 100% (964/964), done.
remote: Total 2180 (delta 622), reused 0 (delta 0)
Receiving objects: 100% (2180/2180), 10.31 MiB | 5.90 MiB/s, done.  
Resolving deltas: 100% (1259/1259), done.
       Checking connectivity... done.
-----> Using git branch 'deploy'
       Cloning into '.'...
       done.
-----> Using this git commit
       Haider Ali (ffba21e):
       > commit
       Connection to 35.xx.2x9.x26 closed.

-----> Symlinking shared paths
-----> Installing gem dependencies using Bundler
       bash: line 81: bundle: command not found
 !     ERROR: Deploy failed.
-----> Cleaning up build
       Unlinking current
       OK
 !     Run Error
artem-russkikh commented 7 years ago

@wonderer007 do you install bundler on the server?

gem install bundler
d4be4st commented 7 years ago

same issue as https://github.com/mina-deploy/mina/issues/513#issuecomment-328018337