Title: undefined method `desc' for Sinatr181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16Application:Class
Tags: ruby;sinatra;rake
Question: This is the error I get when I run any ```rake``` command: ```undefined method 'desc' for Sinatr181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16Application:Class```

```# app.rb
require 'sinatra'
require 'sinatra/activerecord'
require 'sinatra/contrib'

get '/' do
  puts "Hello World"
end

# config.ru
require "./app"
run Sinatr181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16Application

# Rakefile
require './app'
require 'sinatra/activerecord/rake'

# Gemfile
source 'https://rubygems.org'
ruby '2.0.0'

gem 'activerecord', '~&gt; 4.0.2'
gem 'sinatra', '~&gt; 1.4.4'
gem 'sinatra-activerecord', '~&gt; 1.2.3'
gem 'sinatra-contrib', '~&gt; 1.4.2'
```

Full trace:

```/Users/j/.rvm/gems/ruby-2.0.0-p247/gems/sinatra-contrib-1.4.2/lib/sinatra/namespace.rb:269:in `method_missing'
/Users/j/.rvm/gems/ruby-2.0.0-p247/gems/sinatra-activerecord-1.2.3/lib/sinatra/activerecord/tasks.rake:4:in `block in <top (required)&gt;'
/Users/j/.rvm/gems/ruby-2.0.0-p247/gems/sinatra-contrib-1.4.2/lib/sinatra/namespace.rb:126:in `class_eval'
/Users/j/.rvm/gems/ruby-2.0.0-p247/gems/sinatra-contrib-1.4.2/lib/sinatra/namespace.rb:126:in `block in new'
/Users/j/.rvm/gems/ruby-2.0.0-p247/gems/sinatra-contrib-1.4.2/lib/sinatra/namespace.rb:118:in `initialize'
/Users/j/.rvm/gems/ruby-2.0.0-p247/gems/sinatra-contrib-1.4.2/lib/sinatra/namespace.rb:118:in `new'
/Users/j/.rvm/gems/ruby-2.0.0-p247/gems/sinatra-contrib-1.4.2/lib/sinatra/namespace.rb:118:in `new'
/Users/j/.rvm/gems/ruby-2.0.0-p247/gems/sinatra-contrib-1.4.2/lib/sinatra/namespace.rb:142:in `namespace'
/Users/j/.rvm/gems/ruby-2.0.0-p247/gems/sinatra-1.4.4/lib/sinatra/base.rb:1972:in `block (2 levels) in delegate'
/Users/j/.rvm/gems/ruby-2.0.0-p247/gems/sinatra-activerecord-1.2.3/lib/sinatra/activerecord/tasks.rake:3:in `<top (required)&gt;'
/Users/j/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
/Users/j/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `block in load'
/Users/j/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
/Users/j/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:223:in `load'
/Users/j/.rvm/gems/ruby-2.0.0-p247/gems/sinatra-activerecord-1.2.3/lib/sinatra/activerecord/rake.rb:77:in `<top (required)&gt;'
/Users/j/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:51:in `require'
/Users/j/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:51:in `require'
/Users/j/.rvm/gems/ruby-2.0.0-p247/gems/backports-3.3.5/lib/backports/tools.rb:328:in `require_with_backports'
/Users/j/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require'
/Users/j/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
/Users/j/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
/Users/j/Desktop/app/Rakefile:2:in `<top (required)&gt;'
/Users/j/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load'
/Users/j/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load_rakefile'
/Users/j/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/application.rb:637:in `raw_load_rakefile'
/Users/j/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/application.rb:94:in `block in load_rakefile'
/Users/j/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/j/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/application.rb:93:in `load_rakefile'
/Users/j/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/application.rb:77:in `block in run'
/Users/j/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/j/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/Users/j/.rvm/gems/ruby-2.0.0-p247@global/gems/rake-10.1.0/bin/rake:33:in `<top (required)&gt;'
/Users/j/.rvm/gems/ruby-2.0.0-p247@global/bin/rake:23:in `load'
/Users/j/.rvm/gems/ruby-2.0.0-p247@global/bin/rake:23:in `<main&gt;'
/Users/j/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `eval'
/Users/j/.rvm/gems/ruby-2.0.0-p247/bin/ruby_executable_hooks:15:in `<main&gt;'
```

Comment: Where does the backtrace point?

Comment: Added the backtrace and Gemfile.

Comment: and what's in ./app ?

Comment: see also:
https://stackoverflow.com/questions/30656858/undefined-method-namespace-for-mainobject-nomethoderror-active-record-r/66110634#66110634

Here is the accepted answer: The Sinatra namespace extension from Sinatra contrib is interfering with Rake’s own namespace support. They both define a ```namespace``` method, and the Sinatra contrib version is being called (incorrectly) from the Sinatra-ActiveRecord Rake tasks.

If you’re not using the namespaces from Sinatra-contrib, then the easiest solution would be to only require those extensions that you need; e.g. change

```require 'sinatra/contrib'
```

to

```require 'sinatra/whatever'
require 'sinatra/anotherextension'
```

If you are using Sinatra namespaces then I think you may be able to get round this by moving to a modular style app. Change your ```app.rb``` to something like

```require 'sinatra/base' # note this has changed from just 'sinatra'
require 'sinatra/activerecord'
require 'sinatra/contrib'

class MyApp < Sinatr181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16Base
  register Sinatr181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16Contrib

  get '/' do
    "Hello World"
  end

  # other routes etc. as needed
end
```

Then in your ```config.ru``` you need ```run MyApp``` rather then ```run Sinatr181a:6c1c:918f:f3a4:2e8c:61d6:1a08:6b16Application``` (of course you can – and should – give your class a better name). This avoids the collision of the two ```namespace``` methods, since the Sinatra version is only available in your application class, not the top level.

Comment for this answer: I was running a modular app, but forgot the `sinatra/base` specific require. Thanks, saved me!

Here is another answer: Found an easiest solution:

Juste add the require:false attribute to sinatra contrib in your gemfile:

```gem "sinatra-contrib",require: false
```

Found this here:

http://aaronlerch.github.io/blog/sinatra-bundler-and-the-global-namespace/

Comment for this answer: I am using Sinatra to mock an external API for tests in a Rails app, and had the same problem with `sinatra` and `sinatra-contrib` being required globally, by default, from my Gemfile.  This does fix it!  Thanks :)

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 4, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2013:00:12/17/13', 'FavoriteCount': 2.0, 'PostTypeId': 1, 'Tags': '<ruby><sinatra><rake>', 'Title': "undefined method `desc' for Sinatra::Application:Class", 'ViewCount': 4657, 'id': 20638136, 'user_AboutMe': '', 'user_AccountId': 543305.0, 'user_DisplayName': 'jamesfzhang', 'user_Reputation': 4233.0, 'user_Views': 300.0, 'user_id': 912404.0}}