mina-deploy / mina

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

mkdir: cannot create directory ‘config’: File exists #491

Closed bezmolwniy closed 7 years ago

bezmolwniy commented 7 years ago

error appears when run mina setup:

{19:50}~/blog:master ✗ ➭ mina setup
-----> Setting up /home/blog/app
       total 24
       drwxr-xr-x 6 blog blog 4096 дек 11 19:34 .
       drwxr-xr-x 6 blog blog 4096 дек 11 19:27 ..
       drwxr-xr-x 2 blog blog 4096 дек 11 19:27 releases
       drwxr-xr-x 7 blog blog 4096 дек 11 19:34 scm
       drwxr-xr-x 7 blog blog 4096 дек 11 19:27 shared
       drwxr-xr-x 2 blog blog 4096 дек 11 19:34 tmp
       # github.com:22 SSH-2.0-libssh-0.7.0
       mkdir: cannot create directory ‘config’: File exists
       Connection to 78.155.207.47 closed.

deploy.rb:

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

# 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 :domain, '78.155.207.47'
set :user, 'blog'
set :deploy_to, "/home/#{fetch(:user)}/app"
set :repository, 'git@github.com:bezmolwniy/blog.git'
set :branch, 'master'
set :rvm_use_path, '/etc/profile.d/rvm.sh'

# 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.

# They will be linked in the 'deploy:link_shared_paths' step.
set :shared_files, ['config/database.yml', 'config/secrets.yml', 'log']

# This task is the environment that is loaded all remote run commands, such as
# `mina deploy` or `mina rake`.
task :environment do
  ruby_version = File.read('.ruby-version').strip
  raise "Couldn't determine Ruby version: Do you have a file .ruby-version in your project root?" if ruby_version.empty?

  invoke :'rvm:use', ruby_version
end

task :setup do

  in_path(fetch(:shared_path)) do

    command %[mkdir config]

    # Create database.yml for Postgres if it doesn't exist
    path_database_yml = "config/database.yml"
    database_yml = %[production:
  database: #{fetch(:user)}
  adapter: postgresql
  pool: 5
  timeout: 5000]
    command %[test -e #{path_database_yml} || echo "#{database_yml}" > #{path_database_yml}]

    # Create secrets.yml if it doesn't exist
    path_secrets_yml = "config/secrets.yml"
    secrets_yml = %[production:\n  secret_key_base:\n    #{`rake secret`.strip}]
    command %[test -e #{path_secrets_yml} || echo "#{secrets_yml}" > #{path_secrets_yml}]

    # Remove others-permission for config directory
    command %[chmod -R o-rwx config]
  end

end

desc "Deploys the current version to the server."
task :deploy do
  # uncomment this line to make sure you pushed your local branch to the remote origin
  # invoke :'git:ensure_pushed'
  deploy do
    # Put things that will set up an empty directory into a fully set-up
    # instance of your project.
    invoke :'git:clone'
    # Workaround for https://github.com/mina-deploy/mina/issues/452
    fetch(:shared_files, []).each do |linked_path|
      command %{rm -f "./#{linked_path}"}
    end
    invoke :'deploy:link_shared_paths'
    invoke :'bundle:install'
    invoke :'rails:db_migrate'
    invoke :'rails:assets_precompile'
    invoke :'deploy:cleanup'

    on :launch do
      # command "sudo service #{fetch(:user)} restart"
    end
  end

  # you can use `run :local` to run tasks on local machine before of after the deploy scripts
  # run :local { say 'done' }
end

# For help in making your deploy script, see the Mina documentation:
#
#  - https://github.com/mina-deploy/mina/docs

I use mina 1.0.2

d4be4st commented 7 years ago

You have command %[mkdir config] in your setup task

This will fail as mkdir fails when the target folder already exist. It exists because your shared_files have a config/.. in them

Just remove that line from your setup task