ruby-on-rails - Capistrano:无法访问 `~/releases/':没有这样的文件或目录

标签 ruby-on-rails ubuntu deployment capistrano

在我的本地计算机和服务器上执行bundle update 后,我无法再进行部署。正如我猜的那样,我得到的错误是某种权限,但我无法了解正在发生的事情:

cap deploy
  * 2012-10-30 02:48:45 executing `deploy'
  * 2012-10-30 02:48:45 executing `deploy:update'
 ** transaction: start
  * 2012-10-30 02:48:45 executing `deploy:update_code'
    executing locally: "git ls-remote ssh://ubuntu@robotinthecloak.com/~/git/strana_cvetov.git HEAD"
ubuntu@robotinthecloak.com's password: 
    command finished in 7500ms
  * executing "git clone -q --depth 1 ssh://ubuntu@robotinthecloak.com/~/git/strana_cvetov.git ~/rails_apps/strana_cvetov/releases/20121029224852 && cd ~/rails_apps/strana_cvetov/releases/20121029224852 && git checkout -q -b deploy 672780789da61c81640fe7fbd2728064d0f89db3 && (echo 672780789da61c81640fe7fbd2728064d0f89db3 > ~/rails_apps/strana_cvetov/releases/20121029224852/REVISION)"
    servers: ["robotinthecloak.com"]
Password: 
    [robotinthecloak.com] executing command
 ** [robotinthecloak.com :: out] ubuntu@robotinthecloak.com's password:
Password: 
 ** [robotinthecloak.com :: out]
    command finished in 2265ms
  * 2012-10-30 02:48:56 executing `deploy:finalize_update'
    triggering before callbacks for `deploy:finalize_update'
  * 2012-10-30 02:48:56 executing `deploy:assets:symlink'
  * executing "rm -rf ~/rails_apps/strana_cvetov/releases/20121029224852/public/assets &&\\\n        mkdir -p ~/rails_apps/strana_cvetov/releases/20121029224852/public &&\\\n        mkdir -p ~/rails_apps/strana_cvetov/shared/assets &&\\\n        ln -s ~/rails_apps/strana_cvetov/shared/assets ~/rails_apps/strana_cvetov/releases/20121029224852/public/assets"
servers: ["robotinthecloak.com"]
[robotinthecloak.com] executing command
command finished in 162ms
  * executing "chmod -R -- g+w \\~/rails_apps/strana_cvetov/releases/20121029224852 && rm -rf -- \\~/rails_apps/strana_cvetov/releases/20121029224852/public/system && mkdir -p -- \\~/rails_apps/strana_cvetov/releases/20121029224852/public/ && ln -s -- ~/rails_apps/strana_cvetov/shared/system \\~/rails_apps/strana_cvetov/releases/20121029224852/public/system && rm -rf -- \\~/rails_apps/strana_cvetov/releases/20121029224852/log && ln -s -- ~/rails_apps/strana_cvetov/shared/log \\~/rails_apps/strana_cvetov/releases/20121029224852/log && rm -rf -- \\~/rails_apps/strana_cvetov/releases/20121029224852/tmp/pids && mkdir -p -- \\~/rails_apps/strana_cvetov/releases/20121029224852/tmp/ && ln -s -- ~/rails_apps/strana_cvetov/shared/pids \\~/rails_apps/strana_cvetov/releases/20121029224852/tmp/pids"
    servers: ["robotinthecloak.com"]
    [robotinthecloak.com] executing command
 ** [out :: robotinthecloak.com] chmod:
 ** [out :: robotinthecloak.com] cannot access `~/rails_apps/strana_cvetov/releases/20121029224852'
 ** [out :: robotinthecloak.com] : No such file or directory
 ** [out :: robotinthecloak.com] 
    command finished in 205ms
*** [deploy:update_code] rolling back
  * executing "rm -rf ~/rails_apps/strana_cvetov/releases/20121029224852; true"
    servers: ["robotinthecloak.com"]
    [robotinthecloak.com] executing command
    command finished in 167ms
failed: "sh -c 'chmod -R -- g+w \\~/rails_apps/strana_cvetov/releases/20121029224852 && rm -rf -- \\~/rails_apps/strana_cvetov/releases/20121029224852/public/system && mkdir -p -- \\~/rails_apps/strana_cvetov/releases/20121029224852/public/ && ln -s -- ~/rails_apps/strana_cvetov/shared/system \\~/rails_apps/strana_cvetov/releases/20121029224852/public/system && rm -rf -- \\~/rails_apps/strana_cvetov/releases/20121029224852/log && ln -s -- ~/rails_apps/strana_cvetov/shared/log \\~/rails_apps/strana_cvetov/releases/20121029224852/log && rm -rf -- \\~/rails_apps/strana_cvetov/releases/20121029224852/tmp/pids && mkdir -p -- \\~/rails_apps/strana_cvetov/releases/20121029224852/tmp/ && ln -s -- ~/rails_apps/strana_cvetov/shared/pids \\~/rails_apps/strana_cvetov/releases/20121029224852/tmp/pids'" on robotinthecloak.com

我的 deploy.rb 看起来像这样:

# The name of the app
set :application, "strana_cvetov"

# The address of the remote host
set :location, "robotinthecloak.com"

# setup some Capistrano roles
role :app, location
role :web, location
role :db,  location, :primary => true

# The directory on the server that will be deployed to
set :deploy_to, "~/rails_apps/#{application}"
# The type of Source Code Management system
set :scm, :git
# The location of the LOCAL repository relative to the current app
set :repository,  "ssh://ubuntu@#{location}/~/git/#{application}.git"
# The way in which files will be transferred from repository to remote host
set :deploy_via, :copy

set :use_sudo,            false
#tell git to clone only the latest revision and not the whole repository
set :git_shallow_clone,   1
set :keep_releases,       5

#options necessary to make Ubuntu’s SSH happy
ssh_options[:paranoid]    = false
default_run_options[:pty] = true

set :rails_env, :production

# Set up SSH so it can connect to the EC2 node - assumes your SSH key is in ~/.ssh/id_rsa
set :user, "ubuntu"

# Passenger
namespace :deploy do
  task :start do ; end
  task :stop do ; end
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
  end

  namespace :assets do
    task :precompile, :roles => :web, :except => { :no_release => true } do
      run "cd #{current_path} && #{bundle exec rake} RAILS_ENV=#{rails_env} RAILS_GROUPS=assets assets:precompile --trace"
    end
  end
end

after "deploy:create_symlink", "deploy:resymlink", "deploy:update_crontab"

当我运行 deploy:check 时,它说 You appear to have all necessary dependencies installed

我搜索了网络、这个站点,尝试了所有我能找到的解决方案,但没有任何效果。

该服务器上的其他项目也没有部署同样的错误,但几天前一切正常,我在那里什么也没碰。怎么回事?

最佳答案

使用部署到的完整路径,'~'可能是骗人的

set :deploy_to, "/home/username/rails_apps/#{application}"

关于ruby-on-rails - Capistrano:无法访问 `~/releases/':没有这样的文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13130918/

相关文章:

ruby-on-rails - Ruby 中的互斥锁不适用于 Redis?

heroku - Heroku 平台上的扩展指南

eclipse - Eclipse 中的 Tomcat 部署自动化

maven - Jenkins 在 mercurial commit 之后构建

postgresql - 在从 9.5 升级到 9.6 期间无法创建目标集群

git - azure 网站,不断收到错误 : Could not connect to the Local Git repository

ruby-on-rails - Paperclip 安装后未定义的方法 has_attached_file?

ruby-on-rails - 应该将 Ruby on Rails 项目的哪些部分检入存储库?

ruby-on-rails - 如何在 Rails 中将文本字段范围指定为 best_in_place?

ubuntu - 哪种情况会发生 invoke-rc.d 会失败但服务不会?