Problems with Sinatra and Ruby 1.9.2 on a shotgun

I have a simple sinatra app.

require 'rubygems'
require 'sinatra'

get '/' do
  "Hello"
end

When I run it on Shotgun, I get the following error:

loading error

Something went wrong while loading simple.rb

LoadError: there is no such file to load - simple.rb

: 29: in require' <internal:lib/rubygems/custom_require>:29:in requires "/home/thedinga/.rvm/gems/ ruby-1.9.2-p0@global /gems/shotgun-0.8/lib/shotgun/loader.rb:114:in inner_app' /home/thedinga/.rvm/gems/ruby-1.9.2-p0@global/gems/shotgun-0.8/lib/shotgun/loader.rb:102:in assemble_app" / home / thedinga / .rvm / gems / ruby-1.9.2-p0@global /gems/shotgun-0.8/lib/shotgun/loader.rb:86:in proceed_as_child' /home/thedinga/.rvm/gems/ruby-1.9.2-p0@global/gems/shotgun-0.8/lib/shotgun/loader.rb:31:in call! "/home/thedinga/.rvm/gems/ ruby-1.9.2-p0@global /gems/shotgun-0.8/lib/shotgun/loader.rb:18:in call' /home/thedinga/.rvm/gems/ruby-1.9.2-p0@global/gems/shotgun-0.8/lib/shotgun/favicon.rb:12:in Call" /home/thedinga/.rvm/gems/ ruby-1.9.2-p0@global /gems/rack-1.2.1/lib/rack/builder.rb:77:in call' /home/thedinga/.rvm/gems/ruby-1.9.2-p0@global/gems/rack-1.2.1/lib/rack/content_length.rb:13:inCall "/home/thedinga/.rvm/gems/ ruby-1.9.2-p0@global /gems/rack-1.2.1/lib/rack/handler/webrick.rb:52:in service' /home/thedinga/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/httpserver.rb:111:in Service "/home/thedinga/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/ webrick / httpserver.rb: 70: inrun' /home/thedinga/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/server.rb:183:in block in start_thread '

If I used ruby simple.rba shotgun instead, I get the output that you expect in a browser. As a side element, if I push it towards Heroku (which I really would like to run the sinatra application), Heroku will also not be able to launch the application. Is this a problem with version 1.9.2? or am i missing something else?

+5
source share
5 answers

the above code works, just fix "# {path} / myapp" in the config.ru file to require "# {path} / myapp".

ruby ​​ "caracter inner # {}. " caracter " " # path/myapp ", " value/of/path/variabel/myapp ".

,

# FILE config.ru

path = File.expand_path "../", __FILE__

require 'rubygems'
require 'sinatra'
require "#{path}/myapp"

run Sinatra::Application


# FILE myapp.rb

get '/' do
  'hello'
end

,

+8

?

# FILE config.ru

path = File.expand_path "../", __FILE__

require 'rubygems'
require 'sinatra'
require '#{path}/myapp'

run Sinatra::Application


# FILE myapp.rb

get '/' do
  'hello'
end

# FILE start.sh

shotgun -o 0.0.0.0 -p 8888 &

ruby1.9.2-p0..

+3

github.

$ shotgun -I. simple.rb
+2

config.ru :

root = ::File.dirname(__FILE__)
require ::File.join( root, 'app' )

# Assuming your application is subclassed from Sinatra::Application
run MyApp.new 

app.rb ( ) Sinatra ( rubygems, 1.9).

+1

I use Ruby 1.9.2 and Sinatra, and I also have problems running it with Shotgun. There is a simple way: use sinatra-repeatergem instead of Shotgun. Installation and configuration are described in the Sinatra book: http://sinatra-book.gittr.com/#automatic_code_reloading

0
source

All Articles