Capistrano 中的捆绑包安装未在 Rails 中安装资产 gem

发布于 2025-01-08 03:12:36 字数 1157 浏览 0 评论 0原文

当我运行 cap deploy 时,:assets 组中的 gem 未安装。

这是一个问题,因为我使用的是预编译资源,而 Capistrano 必须在服务器上运行 rake assets:precompile 。除非安装了资产 gem,否则这将失败。

我可以通过在正确的发布目录中手动运行 bundle install 来解决此问题。但显然这不是正确的工作流程。

以下是 Capistrano 在每次部署时执行的用于安装 gem 的完整命令:

rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'default' -c 'cd 
/home/deploy/rails_apps/vlc/releases/20120223192328 && bundle install --gemfile 
/home/deploy/rails_apps/vlc/releases/20120223192328/Gemfile --path 
/home/deploy/rails_apps/vlc/shared/bundle --deployment --quiet --without development test'

这是结尾,我认为这可能是问题的一部分:

--deployment --quiet --without development test'

显然,这些标志导致 Bundler 在没有 :assets 组的情况下安装。这里的预期行为是什么?我所看到的不寻常吗? (我猜是这样,因为 Capistrano 故意不安装即将使用的 gem 组是没有意义的。)

作为旁注,我还在 application.rb 中注意到这一行:

Bundler.require(*Rails.groups(:assets => %w(development test)))

我假设 application.rb 中的任何内容都不会影响 bundle install,因为 Rails 不会为此启动。但如果这条线实际上与我的问题相关,请纠正我。

When I run cap deploy, the gems in the :assets group are not installed.

This is a problem because I'm using precompiled assets, and Capistrano has to run rake assets:precompile on the server. That will fail unless the assets gems are installed.

I can work around this problem by manually running bundle install within the correct release directory. But obviously this isn't the proper workflow.

Here's the full command Capistrano is executing to install the gems on each deploy:

rvm_path=/usr/local/rvm /usr/local/rvm/bin/rvm-shell 'default' -c 'cd 
/home/deploy/rails_apps/vlc/releases/20120223192328 && bundle install --gemfile 
/home/deploy/rails_apps/vlc/releases/20120223192328/Gemfile --path 
/home/deploy/rails_apps/vlc/shared/bundle --deployment --quiet --without development test'

Here's the end, which I think might be part of the problem:

--deployment --quiet --without development test'

Evidently, these flags cause Bundler to install without the :assets group. What is the expected behavior here? Is what I'm seeing out of the ordinary? (I'm guessing so, since it doesn't make sense for Capistrano to deliberately refrain from installing a gem group that it's about to use.)

As a side note, I also note this line in application.rb:

Bundler.require(*Rails.groups(:assets => %w(development test)))

I'm assuming nothing in application.rb would affect a bundle install, since Rails doesn't boot for that. But please correct me if this line is actually relevant to my problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

阪姬 2025-01-15 03:12:36

--without 被记住选项,检查您的项目目录/服务器上的文件 .bundle/config 它可能已经包含这样的内容:

---
BUNDLE_WITHOUT: assets

--without is remembered option, check in your project dir / on server the file .bundle/config it's possible it already contains something like this:

---
BUNDLE_WITHOUT: assets
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文