感谢您查看此内容。
我最近遇到了这个问题。如果有任何关于如何解决这个问题的想法,我将不胜感激。
我应该注意到,我对于在私有(private)服务器上部署 Rails 应用程序还很陌生。我只是碰巧用这些应用程序之一开办了一家企业,但现在我陷入了困境。
问题是:Capistrano 无法完成 deploy:assets:precompile 的任务,出现以下错误 SSHKit::Command::Failed: rake exit status: 1
查看下面的日志示例
** Execute deploy:updated
** Invoke deploy:compile_assets (first_time)
** Invoke deploy:set_rails_env
** Execute deploy:compile_assets
** Invoke deploy:assets:precompile (first_time)
** Execute deploy:assets:precompile
00:22 deploy:assets:precompile
01 $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile
01 rake aborted!
01 Psych::SyntaxError: (<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 1
01
(...) /home/deploy/parthumps/shared/bundle/ruby/2.5.0/gems/railties-5.2.1/lib/rails/secrets.rb:29:in `block in parse'
01 /home/deploy/parthumps/shared/bundle/ruby/2.5.0/gems/railties-5.2.1/lib/rails/secrets.rb:26:in `each'
01 /home/deploy/parthumps/shared/bundle/ruby/2.5.0/gems/railties-5.2.1/lib/rails/secrets.rb:26:in `each_with_object'
(...)
#<Thread:0x00007fd8daf941c8@/home/deploy/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/sshkit-1.17.0/lib/sshkit/runners/parallel.rb:10 run> terminated with exception (report_on_exception is true):
Traceback (most recent call last):
1: from /home/deploy/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/sshkit-1.17.0/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
/home/deploy/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/sshkit-1.17.0/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as deploy@(SERVER IP): rake exit status: 1 (SSHKit::Runner::ExecuteError)
rake stdout: Nothing written
rake stderr: rake aborted!
Psych::SyntaxError: (<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 1
(...)
/home/deploy/parthumps/shared/bundle/ruby/2.5.0/gems/railties-5.2.1/lib/rails/secrets.rb:29:in `block in parse'
/home/deploy/parthumps/shared/bundle/ruby/2.5.0/gems/railties-5.2.1/lib/rails/secrets.rb:26:in `each'
(...)
/home/deploy/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/sshkit-1.17.0/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute'
/home/deploy/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/sshkit-1.17.0/lib/sshkit/runners/parallel.rb:11:in `block (2 levels) in execute'
Caused by:
SSHKit::Command::Failed: rake exit status: 1
rake stdout: Nothing written
rake stderr: rake aborted!
Psych::SyntaxError: (<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 1
(...) (See full trace by running task with --trace)
** Invoke deploy:failed (first_time)
** Execute deploy:failed
** DEPLOY FAILED
这很可怕,因为它太大了。我想如果它更小我就能修复它。
最佳答案
读取 secret 时出现 Psych::SyntaxError
(堆栈跟踪指向 /home/deploy/parthumps/shared/bundle/ruby/2.5.0/gems/railties -5.2.1/lib/rails/secrets.rb:29
)
检查 secret 文件 (config/secrets.yml
) 是否正确。
另外,首先尝试在本地运行 assets:precompile
以检查是否只是服务器上的问题。
关于ruby-on-rails - Capistrano 在部署时失败: Assets :使用 SSHKit::Command::Failed 预编译:rake 退出状态:1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52799183/