webmachine/webmachine-ruby

Error: uninitialized constant Webmachine::Application

kgish opened this issue · 13 comments

When I try to run the webrick.rb example, I get the following error

$ ruby webrick.rb
webrick.rb:17:in `<main>': uninitialized constant Webmachine::Application (NameError)

Just wondering what I might be doing wrong?

I'm assuming you're running this from a Git clone? Change to the root and run it like this, to make sure all dependencies are properly resolved:

$ bundle exec ruby examples/webrick.rb

I just verified that this works as expected on master.

Semi-off topic: when we removed the SIGINT handlers, I should have paid attention to the examples -- the WEBrick example can't be stopped, for example :)

You're right, just a newbie and wasn't aware that bundle exec ruby is the proper way to run it.

Keep it up :)

I discovered https://github.com/kgish/ruby-webmachine-roar-template, feel free to add such projects to the Readme's "Related libraries".

That's me, not quite done yet.

For some reason I keep getting a 404 when calling /products, whereas /products/id work fine.

Sorry, tried as you suggested but still aborts with uninitialized constant Webmachine::Application error as above :(

I can't reproduce it.

$ git clone git@github.com:seancribbs/webmachine-ruby.git
Cloning into 'webmachine-ruby'...
remote: Counting objects: 3781, done.
remote: Total 3781 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3781/3781), 1.08 MiB | 189.00 KiB/s, done.
Resolving deltas: 100% (1846/1846), done.
Checking connectivity... done.
bethtemp $ cd webmachine-ruby/
webmachine-ruby $ bundle
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Using thread_safe 0.3.4
Using rake 10.4.2
Using as-notifications 1.0.1
Using hitimes 1.2.2
Using nio4r 1.0.1
Using coderay 1.1.0
Using diff-lcs 1.2.5
Installing ice_nine 0.11.1
Using formatador 0.2.5
Using growl 1.0.3
Using rb-fsevent 0.9.4
Using lumberjack 1.0.9
Installing nenv 0.1.1
Using method_source 0.8.2
Using slop 3.6.0
Using thor 0.19.1
Installing guard-compat 1.2.0
Using rspec-support 3.0.4
Using http_parser.rb 0.6.0
Using promise.rb 0.6.1
Using i18n 0.7.0
Using multi_json 1.10.1
Using rack 1.6.0
Using redcarpet 3.2.2
Using websocket_parser 0.1.6
Installing ffi 1.9.6
Using bundler 1.7.4
Using memoizable 0.4.2
Using timers 4.0.1
Using pry 0.10.1
Using rspec-core 3.0.4
Using rspec-expectations 3.0.4
Using rspec-mocks 3.0.4
Installing yard 0.8.7.6
Using webmachine 1.2.2 from source at .
Using rb-inotify 0.9.5
Using adamantium 0.2.0
Using celluloid 0.16.0
Using rspec-its 1.1.0
Using rspec 3.0.0
Installing http 0.6.3
Installing celluloid-io 0.16.1
Using reel 0.5.0
Installing listen 2.8.4
Installing guard 2.10.5
Installing eventmachine 1.0.4
Using httpkit 0.6.0
Installing guard-rspec 4.5.0
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.

webmachine-ruby $ bundle exec ruby examples/webrick.rb &
[1] 90456
[2015-01-03 20:46:20] INFO  WEBrick 1.3.1
[2015-01-03 20:46:20] INFO  ruby 2.0.0 (2013-11-22) [x86_64-darwin13.0.0]
[2015-01-03 20:46:20] INFO  Webmachine::Adapters::WEBrick::Server#start: pid=90456 port=8080

webmachine-ruby $ curl http://localhost:8080/
localhost - - [03/Jan/2015:20:46:36 AEDT] "GET / HTTP/1.1" 200 88
<html><head><title>Hello from Webmachine</title></head><body>Hello, world!</body></html>- -> /

Btw, @kgish, in relation to your 404 error, you need a Products resource ("/products") and a Product resource ("/products/:id"). Check out the example here. Because you've got the two of them smushed together in one resource, that's why you've had to do path_info.has_key?(:id).

This is what my `Gemfile looks like, anything missing?

source 'http://rubygems.org'

gem 'webmachine'
gem 'roar', '~> 0.8.1'
gem 'httparty'
gem 'json'
gem 'sequel'
gem 'sqlite3'
gem 'rake'
gem 'hyperresource'
gem 'aptible-auth'

group :development do
  gem 'guard'
  gem 'guard-livereload', require: false
end

group :test do
  gem 'rspec'
  gem 'webmachine-test', :git => 'https://github.com/bernd/webmachine-test.git'
end
``

Looks pretty normal to me.

That's the Gemfile for your project, right? How does that relate to your issue, which was running the webrick example in the webmachine project?

Can we close this issue now?

Everything works now that I upgraded, thanks.