Capistrano 3 +链轮3 + Rails 4.2.1无法部署吗? [英] Capistrano 3 + Sprockets 3 + Rails 4.2.1 won't deploy?

查看:45
本文介绍了Capistrano 3 +链轮3 + Rails 4.2.1无法部署吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行了套装更新,并将链轮更新为3.0.0。

I ran bundle update and updated sprockets to 3.0.0.

当我尝试通过Capistrano 3进行部署时,出现以下错误:

When I try to deploy via Capistrano 3 I get the following error:

INFO [e54ac5ca] Running /usr/bin/env cp /var/www/testapp/releases/20150414002210/public/assets/manifest* /var/www/testapp/releases/20150414002210/assets_manifest_backup as deploy@xx.xxx.xxx.xx
DEBUG [e54ac5ca] Command: cd /var/www/testapp/releases/20150414002210 && /usr/bin/env cp /var/www/testapp/releases/20150414002210/public/assets/manifest* /var/www/testapp/releases/20150414002210/assets_manifest_backup
DEBUG [e54ac5ca]    cp: cannot stat ‘/var/www/testapp/releases/20150414002210/public/assets/manifest*’
DEBUG [e54ac5ca]    : No such file or directory
DEBUG [d2c5a990]    cp: cannot stat ‘/var/www/testapp/releases/20150414002210/public/assets/manifest*’
DEBUG [d2c5a990]    : No such file or directory
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@xx.xxx.xxx.xxx: cp exit status: 1
cp stdout: Nothing written
cp stderr: cp: cannot stat ‘/var/www/testapp/releases/20150414002210/public/assets/manifest*’: No such file or directory
/Users/HomeHome/.rvm/gems/ruby-2.1.3/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:16:in `rescue in block (2 levels) in execute'
/Users/HomeHome/.rvm/gems/ruby-2.1.3/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute'
SSHKit::Command::Failed: cp exit status: 1
cp stdout: Nothing written
cp stderr: cp: cannot stat ‘/var/www/testapp/releases/20150414002210/public/assets/manifest*’: No such file or directory
/Users/HomeHome/.rvm/gems/ruby-2.1.3/gems/sshkit-1.7.1/lib/sshkit/command.rb:95:in `exit_status='
/Users/HomeHome/.rvm/gems/ruby-2.1.3/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:179:in `block in _execute'
/Users/HomeHome/.rvm/gems/ruby-2.1.3/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:133:in `tap'
/Users/HomeHome/.rvm/gems/ruby-2.1.3/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:133:in `_execute'
/Users/HomeHome/.rvm/gems/ruby-2.1.3/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:66:in `execute'
/Users/HomeHome/.rvm/gems/ruby-2.1.3/gems/capistrano-rails-1.1.2/lib/capistrano/tasks/assets.rake:68:in `block (5 levels) in <top (required)>'
/Users/HomeHome/.rvm/gems/ruby-2.1.3/gems/sshkit-1.7.1/lib/sshkit/backends/abstract.rb:77:in `within'
/Users/HomeHome/.rvm/gems/ruby-2.1.3/gems/capistrano-rails-1.1.2/lib/capistrano/tasks/assets.rake:67:in `block (4 levels) in <top (required)>'
/Users/HomeHome/.rvm/gems/ruby-2.1.3/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:54:in `instance_exec'
/Users/HomeHome/.rvm/gems/ruby-2.1.3/gems/sshkit-1.7.1/lib/sshkit/backends/netssh.rb:54:in `run'
/Users/HomeHome/.rvm/gems/ruby-2.1.3/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:13:in `block (2 levels) in execute'
Tasks: TOP => deploy:assets:backup_manifest
(See full trace by running task with --trace)
The deploy has failed with an error: #<SSHKit::Runner::ExecuteError: Exception while executing as deploy@xx.xxx.xxx.xxx: cp exit status: 1
cp stdout: Nothing written
cp stderr: cp: cannot stat ‘/var/www/testapp/releases/20150414002210/public/assets/manifest*’: No such file or directory

我到处寻找可能存在相同问题的人似乎没有任何问题或评论……

I've looked all around for people possibly having the same issues and it seems there are no issues or comments on it anywhere...

老实说,我什至不知道链轮链轮轨道与轨道相关。这一切都让我感到困惑...例如,默认的 Gemfile 带有一个新的 Rails 4.2.1 应用程序说 Gemfile.lock 中允许使用链轮3.0.0,但是当您转到链轮2-> 3升级指南时,它显示 / / =包括已被删除,但它位于 application.js 文件中。

Honestly I'm not even sure how sprockets, sprockets-rails are related to rails. It's all quite confusing to me... for example, the default Gemfile which comes with a fresh Rails 4.2.1 app says sprockets 3.0.0 is allowed in Gemfile.lock, yet when you go to the sprockets 2->3 upgrade guide, it shows that //= include has been removed, yet it's right there in the application.js file.

所以,也许我错过了一些东西,但是我不太确定如何解决这个问题。

So, maybe I'm missing something, but I'm not quite sure how to solve this.

推荐答案

这个问题很容易解决,但我认为首先我们应该解决其他一些问题。

The problem is easy to fix, but I think that first we should address some of the other questions.

sprockets 是一个ruby库,可自动管理Web前端资产(CSS,JS,图像等)。

sprockets is a ruby library that automates managing web front end assets (CSS, JS, images, etc).

它基于以下想法:在开发过程中保持资产文件的逻辑组织,然后进行链化和精简 >部署到生产之前。 Sprockets使此过程自动化。

It is based on the idea of keeping your asset files logically organized in development, and to then chain and minify them before deploying to production. Sprockets makes this process automatic.

Rails 3.1(很久以前就是现在)发布了一项名为资产管道的新功能,该功能可以自动管理Web资产。 Rails的资产管道一直(并仍然)由链轮驱动。

Rails 3.1 (a long time ago, now) released a new feature called "Asset Pipeline", that automated the management of web assets. The Rails' Asset Pipeline was, and still is, powered by sprockets.

链轮轨道均得到积极维护和开发库。新版本发布了新功能和重大更改。

我相信Rails默认不会使用最新版本的 sprockets 。没关系,我们在这里谈论的是编译CSS和JS,而不是与某些外部API交互;甚至旧版本的链轮都可以完成工作。

这意味着更新链轮这不是一个好主意。每个版本的Rails都声明 sprockets 的特定(最小-最大)版本,这有充分的理由:这是当前资产管道所依赖的版本。更新它可能会破坏事情。

Both sprockets and rails are actively maintained and developed libraries. New versions are released with new features and breaking changes.
I believe that Rails does not use, by default, the latest version of sprockets. It is ok, we're talking about compiling CSS and JS here, not interacting with some external API; even an old version of sprockets can do the job.
This means that updating sprockets is not a good idea. Each version of Rails declares a specific (min-max) version of sprockets, for good reason: it's the version that the current Asset Pipeline relies on. Updating it might break things.

然后,我们转到清单文件。

默认情况下,在预编译资产后(解析引用,包括将某些文件分成其他文件,然后链接并缩小),然后将已编译资产复制到 RAILS_ROOT / public / assets 中。通过它们,Rails生成一个清单文件,其中包含所有预编译资产的列表。在您的Rails版本中,它应该是 manifest.json ,但以前是 manifest.yml

Then, let's move to the manifest file.
By default, after precompiling the assets (resolving references, including some files into others, chaining and minifying them), the compiled assets are copied in RAILS_ROOT/public/assets. With them, Rails generates a manifest file that contains a list of all the precompiled assets. In your version of Rails it should be manifest.json, but it used to be manifest.yml.

现在,难题的最后一部分是 capistrano ,我想您知道该如何使用。

Now, the last piece of the puzzle is capistrano, which I imagine you know how to use.

该行:

cp: cannot stat ‘/var/www/testapp/releases/20150414002210/public/assets/manifest*’

表示 capistrano 试图在 RAILS_ROOT / public / assets 目录中找到一个清单文件。使用通配符是因为它可能是 manifest.json manifest.yml ,具体取决于Rails的版本。

另外, stat 表示 capistrano 试图从文件中获取一些信息,可能弄清楚它是最近的。

means that capistrano tried to find a manifest file in your RAILS_ROOT/public/assets directory. The wildcard is there because it might be either manifest.json or manifest.yml, depending on the version of Rails.
Also, stat means that capistrano is trying to get some info from the file, probably to figure out how recent it is.

问题是文件不存在。

您应该预编译资产,然后提交生成的文件,然后尝试再次部署。

The problem is that the file is not present.
You should precompile the assets, then commit the generated files and try to deploy again.

这篇关于Capistrano 3 +链轮3 + Rails 4.2.1无法部署吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆