我试图设置一个puppet节点,但rubygems似乎没有行为。
如果我通过它自己的二进制文件(/usr/lib/ruby/gems/1.8/gems/facter-1.5.8/bin/facter)在cli上运行facter,它可以正常工作,但是如果我通过rubygems安装的二进制文件(/usr/bin/facter)运行它,它会抛出:
/usr/lib/ruby/1.8/facter/uptime.rb:11: undefined method `get_uptime' for Facter::Util::Uptime:Module (NoMethodError)
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/loader.rb:73:in `load'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/loader.rb:73:in `load_file'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/loader.rb:38:in `load_all'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/loader.rb:33:in `each'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/loader.rb:33:in `load_all'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/loader.rb:30:in `each'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/loader.rb:30:in `load_all'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter/util/collection.rb:90:in `load_all'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/lib/facter.rb:95:in `to_hash'
from /usr/lib/ruby/gems/1.8/gems/facter-1.5.8/bin/facter:137
from /usr/bin/facter:19:in `load'
from /usr/bin/facter:19
我试过删除rubygems并重新安装gem,但似乎没有任何效果。
我假设某个东西被缓存在某个地方,因为当我试图运行puppet时,它会抛出相同的错误。
有什么想法吗?
最佳答案
在安装rubygems之前,您可能已经在rubygems之外安装了facter
。
您会注意到stacktrace中的最终文件是/usr/lib/ruby/1.8/facter/uptime.rb
而不是/usr/lib/ruby/gems/1.8/gems/facter-1.5.8
中的文件。
您应该检查/usr/lib/ruby/1.8/facter
中的文件是否确实只是factor的旧版本,如果是,您应该能够删除它们或将它们移动到不同名称的目录中,它将修复您的问题。