代码之家  ›  专栏  ›  技术社区  ›  Marvin Danig

Rbenv在Capistrano部署期间找不到纱线

  •  0
  • Marvin Danig  · 技术社区  · 6 年前

    我一直在使用Capistrano部署我的Rails应用程序。以下步骤失败:

       01 $HOME/.rbenv/bin/rbenv exec bundle install --path /var/www/bubblin.io/shared/bundle --without development test --deployment --quiet
        ✔ 01 marvin@bubblin.io 1.053s
    00:26 yarn:install
          01 $HOME/.rbenv/bin/rbenv exec yarn install --production
          01 rbenv: yarn: command not found
    
    $HOME/.rbenv/bin/rbenv exec yarn install --production
          01 rbenv: yarn: command not found
    #<Thread:0x00007fb9b626fcd8@/Users/sa/.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 /Users/sa/.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'
    /Users/sa/.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 marvin@bubblin.io: yarn exit status: 127 (SSHKit::Runner::ExecuteError)
    yarn stdout: rbenv: yarn: command not found
    yarn stderr: Nothing written
    (Backtrace restricted to imported tasks)
    cap aborted!
    SSHKit::Runner::ExecuteError: Exception while executing as marvin@bubblin.io: yarn exit status: 127
    yarn stdout: rbenv: yarn: command not found
    yarn stderr: Nothing written
    

    $ yarn install --production
    yarn install v1.10.1
    [1/4] Resolving packages...
    success Nothing to install.
    success Saved lockfile.
    Done in 0.06s.
    

    但是当我在同一个命令前面加上 rbenv exec 它失败了。

    $ rbenv exec yarn install --production
    rbenv: yarn: command not found
    

    rbenv yarn 不知为什么?

    1 回复  |  直到 6 年前
        1
  •  2
  •   zdk    6 年前

    我想 yarn rbenv exec 也许?

    desc "Yarn Install"
    task :yarn_install do
      on roles(:all) do |host|
        execute :yarn, :install, "--production"
      end
    end
    

    然后,用 bundle exec cap production yarn_install

    或者,从其他任务中调用该任务。

    在Gemfile中,删除或注释“capistrano yarn”

    #gem 'capistrano-yarn'
    

    在Capfile中,删除或注释“capistrano/yarn”

    #require 'capistrano/yarn'
    

    创建新项目:

    rails new <name> --skip-yarn

    webpacker.check_yarn_integrity false 应用内环境文件(即app/config/development.rb app/config/production.rb)

    config.webpacker.check_yarn_integrity = false
    

    javascript_pack_tag stylesheet_pack_tag 在里面 app/views/* 路径,然后将它们注释掉,如下所示:

    <%# javascript_pack_tag "" %>
    <%# stylesheet_pack_tag "" %>