ruby-on-rails - capistrano + git 部署 : could not create work tree dir : Permission denied

标签 ruby-on-rails passenger capistrano

我正在使用带有乘客的 git 和 capistrano 进行部署。我一直在敲打我的头几个小时试图使这项工作,并没有取得太大进展。 cap deploy:setup 工作正常,但 cap deploy 因权限问题而失败。我尝试更改切片的权限/所有权,但仍然失败。

需要 'bundler/capistrano'
设置:用户,'some_user'
设置:域,'example.com'
设置:applicationdir,“/home/some_user/public_html/example”
设置:端口,30000

设置:scm,'git'
设置:存储库,“ssh://git@123.45.678.910:50000/home/git/example”
设置:分支,'主人'
设置:scm_verbose,真

# 角色(服务器)
角色:网络,域
角色:应用程序,域
角色 :db, domain, :primary => true

# 部署配置
设置:deploy_to,应用程序目录
设置 :deploy_via, :remote_cache

# 其他设置
default_run_options[:pty] = true
ssh_options[:forward_agent] = 真

#乘客
命名空间:部署做
任务:开始做;结尾
任务:停止做;结尾
任务 :restart, :roles => :app, :except => { :no_release => true } 做
运行“#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}”
结尾
结尾

导致以下错误:

执行“部署”
* 执行`部署:更新'
** 交易:开始
* 执行`deploy:update_code'
更新所有服务器上的缓存结帐
在本地执行:“git ls-remote ssh://git@123.45.678.910:50000/home/git/example.com master”
/Users/some_user/.rvm/gems/ruby-1.9.2-p0/gems/capistrano-2.6.0/lib/capistrano/recipes/deploy.rb:104:警告:不安全的世界可写目录/usr/local/bin在路径中,模式 040777
命令在 78068 毫秒内完成
* 执行“if [ -d/home/some_user/public_html/example.com/shared/cached-copy ]; then cd/home/some_user/public_html/example.com/shared/cached-copy && git fetch origin && git fetch --tags origin && git reset --hard c7f73668d0656c665a6445c33870d05a8550ab2c && git clean -d -x -f; else git clone ssh://git@123.45.678.910:50000/home/git/html/example.com example.com/shared/cached-copy && cd/home/some_user/public_html/example.com/shared/cached-copy && git checkout -b deploy c7f73668d0656c665a6445c33870d05a8550ab2c; fi"
服务器:[“example.com”]
[example.com] 执行命令
** [example.com::out] 致命:无法创建工作树目录“/home/some_user/public_html/example.com/shared/cached-copy”。:权限被拒绝
命令在 353 毫秒内完成
*** [deploy:update_code] 回滚
* 执行“rm -rf/home/some_user/public_html/example.com/releases/20110610173027; true”
服务器:[“example.com”]
[example.com] 执行命令
命令在 218 毫秒内完成
失败:“sh -c 'if [ -d/home/some_user/public_html/example.com/shared/cached-copy ]; then cd/home/some_user/public_html/example.com/shared/cached-copy && git fetch origin && git fetch --tags origin && git reset --hard c7f73668d0656c665a6445c33870d05a8550ab2c && git clean -d -x -f; else git clone ssh://git@123.45.678.910:5006c665a6445c33870d05a8550ab2c some_user/public_html/example.com/shared/cached-copy && cd/home/some_user/public_html/example.com/shared/cached-copy && git checkout -b deploy c7f73668d0656c665a6445c33870d05a8550ab2c; fi'"on example

最佳答案

不知道这会有多大帮助,但在 deploy:setup 之后我总是有权限问题

当您运行时 deploy:setup它为您创建初始目录。然而,它创建的那些文件夹通常归 root 所有。 (无论如何,在我的大多数情况下)。

webapp/
  shared     root:root
  releases   root:root

为了解决这个问题,我将这些新文件夹的所有权更改为将要使用的用户。
webapp/
  shared     myuser:myuser
  releases   myuser:myuser

完成后,我将继续使用我的 deploy:update

关于ruby-on-rails - capistrano + git 部署 : could not create work tree dir : Permission denied,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6310086/

相关文章:

ruby-on-rails - rails : assets not precompiling on Capistrano deploy step due to missing variables

deployment - Capistrano 部署如何使用 use_sudo 和 admin_runner

ruby-on-rails - ruby :2. 5.1-slim 或 ruby​​-2.5.1-alpine 在 nokogiri gem 上失败

ruby - nginx 背后的 Unicorn vs Passenger Standalone

node.js - 基本 Express/Node 函数语法不起作用

ruby-on-rails - 橡胶无法用于Rails AWS部署

ruby-on-rails - Rails ActionController::InvalidAuthenticityToken 错误 Heroku

ruby-on-rails - Rails 验证错误未显示

ruby-on-rails - 如果我将 MongoDB 与 Rails 结合使用,我可以使用 Active Record 关联吗?

ruby-on-rails - phusion passenger 和 ruby​​ 1.9.1 已经开始工作了吗?