Ruby 搜索路径在具有相同 ruby 版本的两个盒子上不同?
我们有两台服务器,安装了相同的自制 RPM 红宝石。 一台一台服务器,搜索路径不同,失败了下面的代码片段。
#!/usr/bin/env ruby
require 'openssl'
require 'digest/md5'
puts OpenSSL::Digest::MD5.new
损坏的服务器输出:
/tmp/test.rb
/tmp/test.rb:6: uninitialized constant OpenSSL::Digest::MD5 (NameError)
良好的服务器输出:
/tmp/test.rb
d41d8cd98f00b204e9800998ecf8427e
带有命令行标志的损坏的服务器可以正常工作:
ruby -I /usr/lib/ruby/1.8 /tmp/test.rb
d41d8cd98f00b204e9800998ecf8427e
两者都是 CentOS 4.4 x86_64,ruby 1.8.6 p369。我们基于 Fedora 11 RPM 规范文件构建了自己的 RPM。它适用于 913 其他盒子。 帮助?
We have two servers with the same home-brewed RPM of ruby installed.
One one server, the search path is different, and it fails the following snippet.
#!/usr/bin/env ruby
require 'openssl'
require 'digest/md5'
puts OpenSSL::Digest::MD5.new
Broken server output:
/tmp/test.rb
/tmp/test.rb:6: uninitialized constant OpenSSL::Digest::MD5 (NameError)
Good server output:
/tmp/test.rb
d41d8cd98f00b204e9800998ecf8427e
Broken server with command line flags can be made to work:
ruby -I /usr/lib/ruby/1.8 /tmp/test.rb
d41d8cd98f00b204e9800998ecf8427e
Both are CentOS 4.4 x86_64, ruby 1.8.6 p369. We built our own RPM based on Fedora 11 RPM spec file. It works find on 913 other boxes.
Help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您不告诉我们有关您的安装的更多信息,我们真的无能为力。显然,您的图书馆搜索路径已损坏,但您已经知道这一点。每台机器上 $: 变量的值是多少?
编辑:哦,一个疯狂的猜测:因为你使用的是 env,所以调用的 ruby 可执行文件是你的 PATH 中的第一个可执行文件。例如,您确定在这台特定机器上的 /usr/local 中没有安装其他 ruby 吗?
There's really not much we can do if you don't tell us more about your installation. You apparently have a broken library search path, but you already knew that. What is the value of the $: variable on each of the machines?
Edit: Oh, a wild guess: since you're using env, the ruby executable invoked is the first one in your PATH. Are you sure there isn't some other ruby installed in /usr/local, for instance, on this particular machine?