DRYな備忘録

Don't Repeat Yourself.

gemでインストールしたのにrequireすっと no such file to load って怒られる【gem】【Ruby】【apt-get】

f:id:otiai10:20130211073841j:plain

【問題】

gem install でインストールしたはずなのに

% sudo gem install pdf-reader

  ********************************************

  v1.0.0 of PDF::Reader introduced a new page-based API. There are extensive
  examples showing how to use it in the README and examples directory.

  For detailed documentation, check the rdocs for the PDF::Reader,
  PDF::Reader::Page and PDF::Reader::ObjectHash classes.

  The old API is marked as deprecated but will continue to work with no
  visible warnings for now.

  ********************************************

Successfully installed pdf-reader-1.3.0
1 gem installed
Installing ri documentation for pdf-reader-1.3.0...
Installing RDoc documentation for pdf-reader-1.3.0...

ファイルの中でrequireすると

test.rb

require 'pdf/reader'

File.open("sample.pdf", "rb") do |io|
  # instanciate
  reader = PDF::Reader.new(io)

  # pdf output
  puts reader.pdf_version
end

で、

% ruby test.rb
test.rb:1:in `require': no such file to load -- pdf/reader (LoadError)
    from test.rb:1

って叱られる

あーん?

【解決】

まさにこれだった

Rubyでgem install したのにrequireできない - Coding Edge会議室

検索ワードは「gem install require」

デフォルトでgemへのパスが通ってないのかな?