chillibear.com

Ruby: file-tail: `gem_original_require': no such file to load

Just been trying to play with the file-tail Gem for Ruby and I kept hitting the same error.

#!/usr/bin/env ruby

require 'rubygems'
require 'file-tail'

filename = '/tmp/samplefile.txt'

File.open(filename) do |log|
  log.extend(File::Tail)
  log.interval = 10
  log.backward(10)
  log.tail { |line| puts 
line } end

when run would produce

/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- file-tail (LoadError)
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
	from ./tailtest.rb:4		

Grrr, well after a few minutes of searching I find the answer… that should be:

require 'rubygems'
require 'file/tail'

Note the forward slash in file/tail. It’s caught me out a couple of times now with various Ruby Gems, hopefully by writing it down it’ll stick in my head!

So thanks to this thread where it was actually explicitly mentioned: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/303082

Written on 29 Aug 2009 and categorised in Ruby, tagged as filetail, gemoriginalrequire, and Gem

Home, Post archive

site copyright Eric Freeman

Valid XHTML 1.0 Strict