Capistrano在部署时失败:资产:使用SSHKit预编译:: Command :: Failed:rake退出状态:1

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Capistrano在部署时失败:资产:使用SSHKit预编译:: Command :: Failed:rake退出状态:1相关的知识,希望对你有一定的参考价值。

谢谢你检查一下。

我最近碰到了这个。我会很感激如何解决它。

我应该注意到,在私有服务器上部署Rails应用程序我是一个新手。我刚刚开始使用其中一个应用程序开展业务,现在我陷入了困境。

这是问题:Capistrano没有超出部署任务:资产:预编译给出以下错误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

这太可怕了,因为它非常大。如果它更小,我想我会设法解决它。

答案

你在阅读秘密时会得到一个Psych::SyntaxError(stacktrace指向/home/deploy/parthumps/shared/bundle/ruby/2.5.0/gems/railties-5.2.1/lib/rails/secrets.rb:29

检查秘密文件(config/secrets.yml)是否正确。还尝试首先在本地运行assets:precompile以检查它是否只是服务器上的问题。

另一答案

我真的设法在精确的capistrano任务上预编译资产,现在它已经过去了。问题是我在/ parthumps / config没有secretts.yml,而是只有/ parthumps / shared / config。

以上是关于Capistrano在部署时失败:资产:使用SSHKit预编译:: Command :: Failed:rake退出状态:1的主要内容,如果未能解决你的问题,请参考以下文章

Rails 4 + Capistrano + AWS Net::SSH::AuthenticationFailed: 部署

Capistrano 在部署时要求输入密码,尽管有 SSH 密钥

Rails Ubuntu / passenger / capistrano应用程序资产未部署

加速资产:使用 Rails 3.1/3.2 Capistrano 部署预编译

如何在通过 Capistrano 部署 Rails 应用程序时输入 ssh 密钥的密码?

资产预编译 Capistrano 3.4