0

I want to start my app using thin server

In config.ru

require 'sinatra'

require 'app'
run Sinatra.application

they are on the same directory

kithokit@19:05:26 hello (master) $ ls config.ru app.rb 
app.rb  config.ru

but i still got this error

kithokit@19:05:14 meet-api (master) $ thin start
Using rack adapter
/home/kithokit/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- app (LoadError)
        from /home/kithokit/.rvm/rubies/ruby-1.9.3-p327/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
TheOneTeam
  • 25,806
  • 45
  • 116
  • 158

1 Answers1

1

Change this line

require 'app'

to

require './app'

for more alternatives also see: Why does Ruby 1.9.2 remove "." from LOAD_PATH, and what's the alternative?

Community
  • 1
  • 1
Patrick Oscity
  • 53,604
  • 17
  • 144
  • 168
  • A bit confused. I use ruby-1.9.3, which mean require 'app' should work. but u are right, we need to add "./" Do you know why? Any more reference? – TheOneTeam Nov 14 '13 at 13:10
  • Is it better to use $LOAD_PATH.unshift('.') rather than $LOAD_PATH << '.' ? – TheOneTeam Nov 14 '13 at 13:36
  • Unshift will prepend the path. This means your own classes are loaded in favor of gems etc with the same name. Normally you will avoid name collisions so in practice i guess it does not matter. – Patrick Oscity Nov 14 '13 at 13:57
  • If you read carefully, you will notice that `./` is necessary with *1.9.2 and above* which means it will only work the "old way" up until 1.9.1. You have 1.9.3, which does not have `./` in `$LOAD_PATH`. – Patrick Oscity Nov 14 '13 at 14:12