Ruby on Rails:错误'require':无法加载此类文件-捆绑程序/安装程序(LoadError)

问题描述 投票:0回答:1

我正在尝试在托管服务器上设置Redmine。 Redmine安装工作正常,我可以启动rails服务器并使用lynx访问redmine页面本地设置。通过FCGI在Apache中进行集成,当我在浏览器中输入redmine起始页面时,出现服务器错误500。在服务器日志中,我看到以下内容:

Feb 18 01:17:12 dedi444 apache: /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler/setup (LoadError)
Feb 18 01:17:12 dedi444 apache:         from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
Feb 18 01:17:12 dedi444 apache:         from /usr/www/users/admin/redmine/config/boot.rb:4:in `<top (required)>'
Feb 18 01:17:12 dedi444 apache:         from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
Feb 18 01:17:12 dedi444 apache:         from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
Feb 18 01:17:12 dedi444 apache:         from /usr/www/users/admin/redmine/startup.rb:1:in `<main>'
Feb 18 01:17:12 dedi444 apache: /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler/setup (LoadError)
Feb 18 01:17:12 dedi444 apache:         from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
Feb 18 01:17:12 dedi444 apache:         from /usr/www/users/admin/redmine/config/boot.rb:4:in `<top (required)>'
Feb 18 01:17:12 dedi444 apache:         from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
Feb 18 01:17:12 dedi444 apache:         from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
Feb 18 01:17:12 dedi444 apache:         from /usr/www/users/admin/redmine/startup.rb:1:in `<main>'
Feb 18 01:17:18 dedi444 apache: [Tue Feb 18 01:17:18.386071 2020] [fcgid:info] [pid 31847:tid 140048663593024] mod_fcgid: process /usr/www/users/admin/test/dispatch.fcgi(3096) exit(communication error), terminated by calling exit(), return code: 1

我搜索了错误消息其他答案,建议使用捆绑安装-输出为

...
Bundle complete! 27 Gemfile dependencies, 58 gems now installed.
Gems in the groups development, test and rmagick were not installed.
Bundled gems are installed into `/usr/home/admin/.gem`

编辑其他信息:我继续搜索答案,也许是GEM_PATH出了问题,而ruby找不到包/设置。我的fcgi脚本如下所示:

#!/bin/dash                                                                                                                                       
export GEM_HOME="$HOME/.gem/ruby/2.3.0/"
export GEM_PATH="$GEM_HOME:/var/lib/ruby/gems/1.8"
exec /usr/bin/ruby /usr/www/users/admin/redmine/startup.rb

如何找到系统中“捆绑/设置”的位置?

知道我能做什么吗?

非常感谢克劳斯

ruby-on-rails redmine
1个回答
0
投票

看起来您对红宝石和宝石的路径有歧义。它们安装在/usr/home/admin/.gem中,而fcgi试图在/usr/lib/ruby/2.3.0/rubygems/中找到它们,这是因为Apache不知道在哪里查找。

如果共享的托管系统允许,请尝试通过。htaccess文件传递环境配置变量,或者通过apache config

SetEnv GEM_HOME /usr/home/admin/.gem

但是,Redmine最好通过某些应用服务器(puma,thin,webrick ...)使用,并反向代理或通过Passenger作为Apache模块运行,并且最好使用通过rvm或rbenv安装的Ruby。 ..

因此,取决于版本,它可能还需要您添加

gem "fcgi"中的[Gemfile并再次运行bundle install,并在dispatch.fcgi中添加这些行

require 'rubygems'
require 'fcgi'
© www.soinside.com 2019 - 2024. All rights reserved.