Apache,乘客 /轨道,红宝石,Redmine-铁路启动 /宝石路径问题
我有一个红宝石宝石路径问题在Apache上开始乘客。
环境:
ubuntu-20
passenger-6.0.14
ruby-3.0.4
Ruby使用Ruby-install安装了整个系统,并且位于
/opt/rubies/ruby-3.0.4
Chruby设置Ruby环境。
Ruby应用程序和宝石(希望)以每个用户和每个应用程序为基础。在这种情况下,Redmine是唯一的应用程序。
当我访问新创建的Redmine网站时,乘客由于GEM路径问题而无法启动Rails:
Raw Bundler exception:
Bundler was unable to find one of the gems defined in the Gemfile
Bundler tried to load the gems from #<struct Bundler::Settings::Path explicit_path=nil, system_path=false>
Could not find rails-6.1.4.7, rouge-3.28.0, ...
GEMS实际上是在场:
$ cd ~
$ find . | grep rails-6.1.4
./.gem/ruby/3.0.4/specifications/rails-6.1.4.7.gemspec
./.gem/ruby/3.0.4/cache/rails-6.1.4.7.gem
./.gem/ruby/3.0.4/gems/rails-6.1.4.7
./.gem/ruby/3.0.4/gems/rails-6.1.4.7/README.md
Apache SSL SSL启动虚拟主机看起来像:
<IfModule mod_passenger.c>
PassengerRoot /home/test_user/.gem/ruby/3.0.4/gems/passenger-6.0.14
PassengerDefaultRuby /opt/rubies/ruby-3.0.4/bin/ruby
</IfModule>
...
Include rubies/test_user.include
Rubies/test_user.include.include
<Directory /var/www/html/issues-test>
PassengerAppRoot /home/test_user/redmine_test
PassengerAppEnv redmine_test
PassengerAppGroupName redmine_test
RailsBaseURI /issues-test
PassengerUser test_user
PassengerGroup test_user
PassengerFriendlyErrorPages on
</Directory>
。安装红色敏的用户的GEM环境:
- RUBYGEMS VERSION: 3.2.33
- RUBY VERSION: 3.0.4 (2022-04-12 patchlevel 208) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/test_user/.gem/ruby/3.0.4
- USER INSTALLATION DIRECTORY: /home/test_user/.gem/ruby/3.0.0
- RUBY EXECUTABLE: /opt/rubies/ruby-3.0.4/bin/ruby
- GIT EXECUTABLE: /usr/bin/git
- EXECUTABLE DIRECTORY: /home/test_user/.gem/ruby/3.0.4/bin
- SPEC CACHE DIRECTORY: /home/test_user/.local/share/gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /opt/rubies/ruby-3.0.4/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/test_user/.gem/ruby/3.0.4
- /opt/rubies/ruby-3.0.4/lib/ruby/gems/3.0.0
- SHELL PATH:
- /home/test_user/.gem/ruby/3.0.4/bin
- /opt/rubies/ruby-3.0.4/lib/ruby/gems/3.0.0/bin
- /opt/rubies/ruby-3.0.4/bin
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /snap/bin
请注意,Shell路径不包括
/home/test_user/.gem/ruby/3.0.4/gems/
路径; test_user.ixlude没有显示乘客宝石的路径。
我不清楚红宝石/乘客如何建立宝石的路径。
乘客安装是从用户环境完成的。
注意:我也尚不清楚安装目录为何显示,
/home/test_user/.gem/ruby/3.0.4
但用户安装目录显示
/home/test_user/.gem/ruby/3.0.0.
(某个时候我可能已经完成了Ruby-install 3.0,并且安装了3.0.4)。但是,没有目录〜/.gem/ruby/3.0.0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有几个问题。感谢@casper的一些提示。
它是作为红人用户安装的,因此必须设计安装。
检查
不幸的是,我从来源安装了,因为常规存储库已经过时了。从源头卸载是非平凡的,因为乘客文件与其他应用程序文件混合在一起,并且没有简单的方法可以全部找到它们并进行区分。我最终为用户删除了整个Ruby / Redmine环境并重新开始。
要安装乘客作为root,在Ruby-Onstall/Chruby环境中:
一旦乘客重新安装了全球,试图为特定用户设置Redmine仍然失败了,但Bundler找不到任何GEMS 。我读了几个地方,不必明确设置Gem_path,因为乘客/Ruby/Bundler应该能够在常规的地方自动找到所需的宝石,但显然不是。我的假设是,由于Redmine应用程序的乘客定义正确指定了用户环境,因此应找到它们。 (对我而言,如果此问题特定于乘客,Apache2安装或Ruby/Bundler,这对我来说尚不清楚)
问题可能是因为我正在使用Ruby-install而不是RVM;乘客的文档似乎假设RVM用作安装程序。
无论如何,我都必须在Apache2配置中明确设置GEM_PATH。
该路径是如果从用户帐户给出“ Gem Env Gem_path”,则显示的路径。
因此,对于这种情况,在(文件rubies/test_user.include)中,添加行:
setenv gem_path/home/test_user/.gem/ruby/3.0.4/:/opt/opt/rubies/ruby-3.0.4/lib/lib/ruby/gems/3.0.0/
完整的Apache2配置片段看起来像:
There were a couple of issues here. Thanks @Casper for some hints.
It was installed as the redmine user, so had to be de-installed.
Checking the passenger uninstall page for apache, it says
"Remove the passenger files" and then details how to do that, assuming passenger was installed any way except from source.
Unfortunately, I installed from source, as the regular repositories are way out of date. Uninstalling from source is non-trivial, as the passenger files are mixed in with the other application files and there is no easy way to find them all and differentiate. I ended up deleting the entire ruby / redmine environment for the user and starting over.
To install passenger as root, in a ruby-install/chruby environment:
Once passenger was re-installed globally, attempting to set up redmine for a specific user still failed with the same error -- Bundler can't find any gems. I read several places that one should not have to set the GEM_PATH explicitly, as Passenger/Ruby/Bundler are supposed to be able to automatically find the gems they need if they are in a conventional place, but apparently not. My assumption was that since the passenger definition for the redmine app specified the user environment properly, they should be found. (It's not clear to me if this problem is specific to Passenger, an Apache2 installation, or Ruby/Bundler)
The problem may be because I am using ruby-install and not rvm; passenger's docs seem to assume rvm is used as the installer.
In any case, I had to explicitly set GEM_PATH in the apache2 configuration.
The path is the one shown if "gem env GEM_PATH" is given from the user account.
So for this case, in (file rubies/test_user.include above), add the line:
SetEnv GEM_PATH /home/test_user/.gem/ruby/3.0.4/:/opt/rubies/ruby-3.0.4/lib/ruby/gems/3.0.0/
The complete apache2 config fragment looks like: