繁体   English   中英

Ruby on Rails:错误“require”:无法加载此类文件——bundler/setup (LoadError)

[英]Ruby on Rails: Error `require': cannot load such file -- bundler/setup (LoadError)

我正在尝试在托管服务器上设置 redmine。 Redmine 安装成功,我可以启动 rails 服务器并使用 lynx 访问本地的 redmine 页面。 Apache 中的集成是通过 FCGI 完成的,当我在浏览器中进入 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​​ 和 gem 路径有歧义。 它们安装在/usr/home/admin/.gem而 fcgi 试图在/usr/lib/ruby/2.3.0/rubygems/中找到它们,这是因为 Apache 不知道在哪里查找。

如果您的共享主机系统允许或通过 apache 配置,您应该尝试通过.htaccess文件传递 env 配置变量

SetEnv GEM_HOME /usr/home/admin/.gem

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

因此,根据版本,它可能还需要您添加

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

require 'rubygems'
require 'fcgi'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM