I just install tilt :
gem list
tilt (1.2.2)
ruby -v
ruby 1.8.6 (2009-06-08 patchlevel 369) [universal-darwin9.0]
And I simply try the basic example from https://github.com/rtomayko/tilt
tilt.rb
require 'rubygems'
require 'haml'
require 'tilt'
template = Tilt::HamlTemplate.new('haml/about.haml')
And it throw :
./tilt.rb:4: uninitiali开发者_运维知识库zed constant Tilt (NameError)
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:29:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:29:in `require'
from tilt.rb:3
Any idea ? Thanks!
You've named your application file tilt.rb
, so when you call require 'tilt'
the file tries to require itself. Your file doesn't define Tilt
, so you get the error you see.
The error actually happens as the file is being required. It doesn't fall into recursive loop because require
keeps track of the files that have been required, and doesn't attempt to reload them.
Rename your file to something other than tilt.rb
, for instance tilt-test.rb
, and don't leave the original file in the same directory, and it should work.
Incidentally, this doesn't happen in Ruby 1.9, since the current directory isn't on the load path by default.
精彩评论