【问题标题】:Bundler on production server can't find any gems生产服务器上的捆绑器找不到任何宝石
【发布时间】:2013-05-10 01:32:51
【问题描述】:

我正在使用乘客 + nginx 来部署 rails 应用程序。我遇到的问题是捆绑器在尝试安装它们时没有找到任何宝石。例如,我收到此错误:

Could not find i18n-0.6.1 in any of the sources (Bundler::GemNotFound)

如果我登录到我的生产机器并手动安装 gem,错误就会消失,但是找不到下一个所需的 gem。为什么是这样?我使用 rvm。这是我的配置文件:

worker_processes  1;

events {
    worker_connections  1024;
}


http {
    passenger_root /usr/local/lib/ruby/gems/2.0.0/gems/passenger-4.0.0.rc4;
    passenger_ruby /usr/local/bin/ruby;

    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    server {
        listen       80;
        server_name  .treadforth.com;
        root /var/www/Tread-Forth/current/public;
        passenger_enabled on;
    }
}

编辑:我应该补充一点,nginx 是以 root 身份运行的。这可能是一个路径问题,但手动安装 gems 允许 bundle 识别它们已安装,所以我不确定。

【问题讨论】:

  • 你在使用 capistrano 吗?您是否将require 'bundler/capistrano' 行添加到deploy.rb
  • 感谢您解决了问题。如果您添加此答案,我将接受。
  • 不错!我很高兴知道这一点。

标签: ruby-on-rails ubuntu nginx capistrano passenger


【解决方案1】:

如果您使用的是 capistrano,则需要将下面的行添加到 config/deploy.rb

require 'bundler/capistrano'

除非您添加它,否则 capistrano 在部署时不会在远程服务器上运行 bundle install。它还添加了--deployment 选项,将您的所有gem 安装在shared/bundle 下,从而为您的应用创建一个很好的独立gem 环境。

【讨论】:

    猜你喜欢
    • 2013-04-19
    • 2014-08-05
    • 1970-01-01
    • 2015-07-17
    • 2012-06-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多