我正在尝试部署 Rails 5.1 应用程序。我已经多次部署该应用程序没有问题,但现在,突然间我从 Capistrano 收到此错误消息
00:13 deploy:cleanup
SSHKit::Command::Failed: rm exit status: 1
rm stdout: Nothing written
rm stderr: rm: cannot remove '/opt/www/absence-
registrator/releases/20171017091250/node_modules/jquery/dist/jquery.js':
Permission denied
Tasks: TOP => deploy:cleanup
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as
user@myapp.com: rm exit status: 1 │
rm stdout: Nothing written
rm stderr: rm: cannot remove '/opt/www/absence-
registrator/releases/20171017091250/node_modules/jquery/dist/jquery.js':Permission denied
rm: cannot remove '/opt/www/absence-registrator/releases/20171017091250/node_modules/jquery/dist/jquery.slim.js': Permission denied rm: cannot remove '/opt/www/absence-registrator/releases/20171017091250/node_modules/jquery/dist/jquery.min.js': Permission denied rm: cannot remove '/opt/www/absence-registrator/releases/20171017091250/node_modules/jquery/dist/jquery.min.map': Permission denied
Capistrano 用于删除旧版本的部署用户似乎没有足够的权限来删除 node_modules
我试图通过将 node_modules 设置为链接目录来解决此问题:
set :linked_dirs, %w{log tmp/pids tmp/cache tmp/sockets node_modules}
但这也没有解决它。
有人知道如何解决这个问题吗?
感谢您的帮助,
安东尼
ps:这是当前目录下 ls -lt 命令的输出:
-rw-rw-r-- 1 deploy deploy 864 Oct 27 14:04 Capfile
-rw-rw-r-- 1 deploy deploy 2454 Oct 27 14:04 Gemfile
-rw-rw-r-- 1 deploy deploy 8520 Oct 27 14:04 Gemfile.lock
-rw-rw-r-- 1 deploy deploy 148 Oct 27 14:04 README.md
-rw-rw-r-- 1 deploy deploy 227 Oct 27 14:04 Rakefile
drwxrwxr-x 10 deploy deploy 4096 Oct 27 14:04 app
drwxrwxr-x 2 deploy deploy 4096 Oct 27 14:04 bin
drwxrwxr-x 6 deploy deploy 4096 Oct 27 14:04 config
-rw-rw-r-- 1 deploy deploy 130 Oct 27 14:04 config.ru
drwxrwxr-x 3 deploy deploy 4096 Oct 27 14:04 db
drwxrwxr-x 4 deploy deploy 4096 Oct 27 14:04 lib
-rw-rw-r-- 1 deploy deploy 103 Oct 27 14:04 package.json
drwxrwxr-x 8 deploy deploy 4096 Oct 27 14:04 spec
drwxrwxr-x 2 deploy deploy 4096 Oct 27 14:04 vendor
-rw-rw-r-- 1 deploy deploy 228 Oct 27 14:04 yarn.lock
drwxrwxr-x 2 deploy deploy 4096 Oct 27 13:58 assets_manifest_backup
drwxrwxr-x 3 deploy deploy 4096 Oct 27 13:58 public
lrwxrwxrwx 1 deploy deploy 48 Oct 27 13:58 node_modules ->
/opt/www/absence-registrator/shared/node_modules
drwxrwxr-x 2 deploy deploy 4096 Oct 27 13:58 tmp
lrwxrwxrwx 1 deploy deploy 39 Oct 27 13:58 log -> /opt/www/absence-
registrator/shared/log
-rw-rw-r-- 1 deploy deploy 41 Oct 27 13:58 REVISION
最佳答案
根本原因
root
安装包业主 deploy
部署应用程序的用户,它没有删除文件的权限,所有者是 root
解决方案
既然你把你的
node_modules
要成为共享目录,您无需使用 sudo 修复 npm 问题。您可以简单地更改 releases
的所有者文件夹递归到 deploy:deploy
.目的是使旧版本可以成功删除。该命令将是sudo chown -R deploy:deploy /opt/www/absence-registrator/releases
关于ruby-on-rails - Capistrano 在清理期间无法删除节点模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46971619/