我正试图在OSX Lion中使用Sinatra和Mustache。经过大量的谷歌搜索后,我没有进一步解决问题。我很确定它与OSX中的Ruby权限有关,因为错误(下面)从示例config.ru文件的第一行开始(需要'app')。该项目在这里(https://github.com/defunkt/mustache-sinatra-example)
这是我的错误
Boot Error
Something went wrong while loading config.ru
LoadError: no such file to load -- app
/Users/ghostandthemachine/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/Users/ghostandthemachine/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
config.ru:1:in `block in inner_app'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.1/lib/rack/builder.rb:51:in `instance_eval'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.1/lib/rack/builder.rb:51:in `initialize'
config.ru:1:in `new'
config.ru:1:in `inner_app'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/shotgun-0.9/lib/shotgun/loader.rb:112:in `eval'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/shotgun-0.9/lib/shotgun/loader.rb:112:in `inner_app'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/shotgun-0.9/lib/shotgun/loader.rb:102:in `assemble_app'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/shotgun-0.9/lib/shotgun/loader.rb:86:in `proceed_as_child'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/shotgun-0.9/lib/shotgun/loader.rb:31:in `call!'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/shotgun-0.9/lib/shotgun/loader.rb:18:in `call'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/shotgun-0.9/lib/shotgun/favicon.rb:12:in `call'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.1/lib/rack/builder.rb:134:in `call'
/Users/ghostandthemachine/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.1/lib/rack/handler/webrick.rb:59:in `service'
/Users/ghostandthemachine/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/Users/ghostandthemachine/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/Users/ghostandthemachine/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
任何帮助将不胜感激。提前致谢
答案 0 :(得分:5)
在ruby 1.9.2中,当前目录不会搜索require
d个文件,因此您应该指定路径
require './app'
同样,在app.rb
中,您需要更改
6
require 'views/layout'
至require './views/layout'
和
9
:views => 'views',
至:views => './views',
答案 1 :(得分:1)
更改行
require 'app'
到
require './app'
看起来你正在使用Ruby 1.9.2。当前目录已从此版本中的Ruby加载路径中删除,因此require 'app'
不再有效,您需要指定该文件位于当前目录中require './app'
。我假设示例项目是使用早期版本的Ruby构建的。