2012-02-20 58 views
2

如果我require ap,irb返回true(我假設告訴我awesomeprint gem已成功加載)。但是,如果我發出命令ap f其中f是亂碼,我得到:awesomeprint in irb無法識別

NoMethodError: undefined method `ap' for main:Object 
from (irb):5 
from /usr/local/bin/irb:12:in `<main>' 

的思考?

這裏是我的$ LOAD_PATH:

"/usr/local/lib/ruby/gems/1.9.1/gems/multi_json-1.1.0/lib", "/usr/local/lib/ruby/gems/1.9.1/gems/multi_xml-0.4.1/lib", "/usr/local/lib/ruby/gems/1.9.1/gems/httparty-0.8.1/lib", "/usr/local/lib/ruby/gems/1.9.1/gems/ap-0.1.1/lib", "/usr/local/lib/ruby/gems/1.9.1/gems/psych-1.2.2/lib", "/usr/local/lib/ruby/gems/1.9.1/gems/crack-0.3.1/lib", "/usr/local/lib/ruby/site_ruby/1.9.1", "/usr/local/lib/ruby/site_ruby/1.9.1/x86_64-darwin11.3.0", "/usr/local/lib/ruby/site_ruby", "/usr/local/lib/ruby/vendor_ruby/1.9.1", "/usr/local/lib/ruby/vendor_ruby/1.9.1/x86_64-darwin11.3.0", "/usr/local/lib/ruby/vendor_ruby", "/usr/local/lib/ruby/1.9.1", "/usr/local/lib/ruby/1.9.1/x86_64-darwin11.3.0"

看來AP是第四之一。

+1

'defined?(AwesomePrint)'的結果是什麼? – Segfault 2012-02-20 02:13:52

+0

無。這看起來不太好。我一定要嘗試重新安裝它('sudo gem install ap')並且它成功了 – Chris 2012-02-20 02:23:28

+0

我認爲在你的加載路徑中有另一個ap.rb。 – Segfault 2012-02-20 02:24:46

回答

8

你想要的寶石稱爲awesome_print,所以sudo gem install awesome_print應該修復它。可能要刪除其他寶石'ap',這似乎是一些HTTP和XML相關的寶石。

+0

啊該死的。得到了與寶石本身混淆的命令'ap'。謝謝您的幫助! – Chris 2012-02-20 02:38:36

+0

doh ..犯了完全相同的錯誤! – 2012-10-14 18:40:39