Ruby-on-rails Rails 3:乘客找不到捆绑程序安装的 git gems
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3605235/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Rails 3: Passenger can't find git gems installed by bundler
提问by junique
Rails 3.0.0, Passenger 2.2.15:
Rails 3.0.0,乘客 2.2.15:
- Create a new Rails project
- Add
gem 'paperclip', :git => 'git://github.com/lmumar/paperclip.git', :branch => 'rails3'to your Gemfile - Do
bundle install - Everything OK, starting with
rails/script server& accessing also works - However, when accessing with Passenger, it says:
- 创建一个新的 Rails 项目
- 添加
gem 'paperclip', :git => 'git://github.com/lmumar/paperclip.git', :branch => 'rails3'到您的 Gemfile - 做
bundle install - 一切正常,开始
rails/script server& 访问也有效 - 但是,在使用Passenger 访问时,它说:
git://github.com/lmumar/paperclip.git (at rails3) is not checked out. Please run bundle install(Bundler::GitError)
git://github.com/lmumar/paperclip.git(在 rails3 上)未检出。请运行bundle install(Bundler::GitError)
I have tried bundler pack(doesn't help) and setting BUNDER_HOME to ~/.bundler (the Paperclip git gets installed there by bundler install) in the .htaccess and various places in config/*.rb, but this wasn't successful, too.
我已经尝试过bundler pack(没有帮助)并将 BUNDER_HOME 设置为 ~/.bundler(Paperclip git 被安装在那里bundler install)在 .htaccess 和 config/*.rb 中的各个位置,但这也没有成功。
~/.bundler is owned by the same user as the Rails project (Passenger runs under this user), so it can't be a permission problem. sudo is installed and called by bundle install.
~/.bundler 和 Rails 项目属于同一个用户(Passenger 在这个用户下运行),所以不会是权限问题。sudo 由 安装和调用bundle install。
Any hints?
任何提示?
采纳答案by junique
Solution (took me a few hours):
解决方案(花了我几个小时):
Mare sure that RAILS_ROOT/.bundle/config(SetEnv etc. didn't work for me) contains:
Mare 确定RAILS_ROOT/.bundle/config(SetEnv 等对我不起作用)包含:
---
BUNDLE_PATH: /home/xxxxx/.bundler
Note BUNDLE_PATH, not BUNDLER_PATH! There was also an DISABLED_SHARED_GEMS=1 entry, I removed it.
注意 BUNDLE_PATH,而不是 BUNDLER_PATH!还有一个 DISABLED_SHARED_GEMS=1 条目,我删除了它。
Then bundler recognises the correct path even when loaded from Passenger. Without Passenger, it always worked (and used /home/xxxxx/.bundler, as said in the question)
即使从Passenger加载,bundler也会识别正确的路径。没有乘客,它总是有效(并使用 /home/xxxxx/.bundler,如问题中所述)
回答by Roberto
Im used to have this problem, resolve using
我曾经有这个问题,解决使用
bundle --deployment
Which will install the gems in vendor/bundle
这将在供应商/捆绑包中安装 gem
回答by indirect
You can use bundle install --path vendor/bundleto install the gems locally, instead of into system gems.
您可以使用bundle install --path vendor/bundle在本地安装 gems,而不是安装到系统 gems 中。
If you want to keep using system gems, though, it's just one line in your Apache configuration to tell Passenger where to find your system gems:
但是,如果您想继续使用系统 gems,只需在您的 Apache 配置中添加一行即可告诉 Passenger 在哪里可以找到您的系统 gems:
SetEnv GEM_HOME /Users/bob/.bundle
There's a slightly more elaborate writeup on my blog at Using Passenger with GEM_HOME set
在我的博客上有一篇更详细的文章,在使用 GEM_HOME 集的乘客
回答by declan
I ran into this problem while writing a Sinatra app. To solve it I added this line to config.ru.
我在编写 Sinatra 应用程序时遇到了这个问题。为了解决它,我将此行添加到config.ru。
require 'bundler/setup'
回答by Code-Source
I had the same problem and it was due to a rights issue with RVM.
我遇到了同样的问题,这是由于 RVM 的版权问题。
The user that run the web server can not check if GIT gem is available. As "Passenger" using the web user to run, it can not do this check.
运行 Web 服务器的用户无法检查 GIT gem 是否可用。由于“Passenger”使用网页用户运行,所以不能做此项检查。
The solution I found was to add web user to rvm group:
我找到的解决方案是将 web 用户添加到 rvm 组:
usermod -a -G rvm apache
I hope this will help some other people that don't want to have GEM deployed into "vendor/bundle".
我希望这会帮助其他一些不想将 GEM 部署到“供应商/捆绑包”中的人。
回答by VPaul
I installed the passenger gem and its apache module as a sudo user and that was the problem in my case.
我以 sudo 用户身份安装了乘客 gem 及其 apache 模块,这就是我的问题。
The reason why I used sudo initially was that I copied the code from railscasts' episode 122. Installing it without sodu access resolved this issue. Since Ruby was installed using rvm without the sudo access on my system.
我最初使用 sudo 的原因是我从 railscasts 的第 122 集中复制了代码。在没有 sodu 访问权限的情况下安装它解决了这个问题。由于 Ruby 是使用 rvm 安装的,而我的系统上没有 sudo 访问权限。

