OEL上的Ruby LoadError

时间:2013-01-21 09:17:38

标签: ruby rubygems

我刚刚在OEL 5.8服务器上安装了ruby并且看到了一些奇怪的行为

服务器详细信息

 Linux myhost 2.6.18-238.el5 #1 SMP Tue Jan 4 15:41:11 EST 2011 x86_64 x86

Ruby版

ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

当我尝试运行ruby程序时,我得到一个奇怪的错误

 -sh-3.2$ ruby testing.rb
 ruby: No such file or directory -- ('» (LoadError)

类似地调用gem会返回类似的错误

-sh-3.2$ gem -v
/usr/bin/ruby: No such file or directory -- (W
(LoadError)

在ruby上运行strace会在它死之前显示此错误

lstat("/usr", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/lib", {st_mode=S_IFDIR|0755, st_size=12288, ...}) = 0
lstat("/usr/lib/ruby", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/lib/ruby/site_ruby", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/lib/ruby/site_ruby/1.9.1", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/lib/ruby/site_ruby/1.9.1/rubygems", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/usr/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb",  {st_mode=S_IFREG|0644, st_size=1871, ...}) = 0
open("(\227I\6", O_RDONLY)              = -1 ENOENT (No such file or directory)
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
write(2, "ruby", 4ruby)                     = 4
write(2, ": ", 2: )                       = 2
write(2, "No such file or directory -- (\227I"..., 33No such file or directory -- (I) = 33
write(2, " (", 2 ()                       = 2
write(2, "LoadError", 9LoadError)                = 9
write(2, ")\n", 2)
)                      = 2
getrlimit(RLIMIT_STACK, {rlim_cur=10240*1024, rlim_max=RLIM_INFINITY}) = 0
rt_sigaction(SIGINT, {0x1, [], SA_RESTORER|SA_SIGINFO, 0x319d00eb10}, {0x4b1eb0, [],   SA_RESTORER|SA_SIGINFO, 0x319d00eb10}, 8) = 0
rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER|SA_SIGINFO, 0x319d00eb10}, {0x1, [], SA_RESTORER|SA_SIGINFO, 0x319d00eb10}, 8) = 0
write(4, "!", 1)                        = 1
munmap(0x2ac6c5784000, 1052672)         = 0
exit_group(1)  

如果有人想看到它,我有完整的输出

每次我打电话给ruby时,我都会得到一个稍微不同的错误信息(例如)

-sh-3.2$ ruby testing.rb
ruby: No such file or directory -- (Ç/ (LoadError)
-sh-3.2$ ruby testing.rb
ruby: No such file or directory -- Ç (LoadError)
-sh-3.2$ ruby testing.rb
ruby: No such file or directory -- 0w;   (LoadError)
-sh-3.2$ ruby testing.rb
ruby: No such file or directory -- NULLCMD (LoadError)
-sh-3.2$ ruby testing.rb
ruby: No such file or directory -- 07î (LoadError)

并且在每种情况下,我的strace在它死之前显示这样的错误

lstat("/usr/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb", {st_mode=S_IFREG|0644, st_size=1871, ...}) = 0
open("\20\7\3\30", O_RDONLY)            = -1 ENOENT (No such file or directory)

我注意到几周前发生了这种情况,并重新安装了修复它的红宝石,但是在昨天凌晨4点又出现了问题,因为在此期间没有使用该框,所以非常奇怪

我已经完成了常见的事情,例如检查其他版本的Ruby,所有看起来都很好,所以我有点卡在这个

有谁知道可能导致它的原因?更重要的是如何解决它

干杯

麦克

1 个答案:

答案 0 :(得分:0)

在运行RHEL 6.3的系统上遇到此问题。 prelink包每天运行一次并破坏ruby二进制文件。我卸载了prelink并替换了ruby二进制文件。