This is the error I get when I run any rake command: undefined method 'desc' for Sinatra::Application:Class
# app.rb
require 'sinatra'
require 'sinatra/activerecord'
require 'sinatra/contrib'
get '/' do
puts "Hello World"
end
# config.ru
require "./app"
run Sinatra::Application
# Rakefile
require './app'
require 'sinatra/activerecord/rake'
# Gemfile
source 'https://rubygems.org'
ruby '2.0.0'
gem 'activerecord', '~> 4.0.2'
gem 'sinatra', '~> 1.4.4'
gem 'sinatra-activerecord', '~> 1.2.3'
gem 'sinatra-contrib', '~> 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)>'
/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)>'
/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)>'
/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)>'
/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)>'
/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>'
/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>'
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/
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 < Sinatra::Base
register Sinatra::Contrib
get '/' do
"Hello World"
end
# other routes etc. as needed
end
Then in your config.ru you need run MyApp rather then run Sinatra::Application (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.
Related
I am creating some automated tests using Cucumber and Capybara. I want to add the Touch Action gem (https://github.com/Ricardonacif/touch_action). I added the gem and then in my env file required it but i am getting the following error. I am really confused as to whether i should be creating a separate helper file but i tried something along these lines and still got the same error. Could anyone offer any advice as to how to resolve this?
uninitialized constant RSpec (NameError)
/Users/em/.rvm/gems/ruby-2.1.1/gems/touch_action-1.3.0/lib/touch_action/capybara_rspec_helper.rb:17:in `<top (required)>'
/Users/em/.rvm/gems/ruby-2.1.1/gems/touch_action-1.3.0/lib/touch_action.rb:12:in `require'
/Users/em/.rvm/gems/ruby-2.1.1/gems/touch_action-1.3.0/lib/touch_action.rb:12:in `<top (required)>'
/Users/em/reallyenglish/learning_specs/learning-platform-specs/features/support/env.rb:3:in `require'
/Users/em/reallyenglish/learning_specs/learning-platform-specs/features/support/env.rb:3:in `<top (required)>'
/Users/em/.rvm/gems/ruby-2.1.1/gems/cucumber-2.0.0/lib/cucumber/rb_support/rb_language.rb:94:in `load'
/Users/em/.rvm/gems/ruby-2.1.1/gems/cucumber-2.0.0/lib/cucumber/rb_support/rb_language.rb:94:in `load_code_file'
/Users/em/.rvm/gems/ruby-2.1.1/gems/cucumber-2.0.0/lib/cucumber/runtime/support_code.rb:237:in `load_file'
/Users/em/.rvm/gems/ruby-2.1.1/gems/cucumber-2.0.0/lib/cucumber/runtime/support_code.rb:97:in `block in load_files!'
/Users/em/.rvm/gems/ruby-2.1.1/gems/cucumber-2.0.0/lib/cucumber/runtime/support_code.rb:96:in `each'
/Users/em/.rvm/gems/ruby-2.1.1/gems/cucumber-2.0.0/lib/cucumber/runtime/support_code.rb:96:in `load_files!'
/Users/em/.rvm/gems/ruby-2.1.1/gems/cucumber-2.0.0/lib/cucumber/runtime.rb:242:in `load_step_definitions'
/Users/em/.rvm/gems/ruby-2.1.1/gems/cucumber-2.0.0/lib/cucumber/runtime.rb:65:in `run!'
/Users/em/.rvm/gems/ruby-2.1.1/gems/cucumber-2.0.0/lib/cucumber/cli/main.rb:38:in `execute!'
/Users/em/.rvm/gems/ruby-2.1.1/gems/cucumber-2.0.0/bin/cucumber:9:in `<top (required)>'
/Users/em/.rvm/gems/ruby-2.1.1/bin/cucumber:23:in `load'
/Users/em/.rvm/gems/ruby-2.1.1/bin/cucumber:23:in `<main>'
/Users/em/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
/Users/em/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'
Gemfile
source "https://rubygems.org"
gem 'rake'
gem 'touch_action'
group(:test) do
gem 'cucumber'
gem 'capybara'
gem 'rspec'
gem 'selenium-webdriver'
end
env.rb
require 'capybara'
require 'capybara/cucumber'
require 'touch_action'
Capybara.configure do |config|
config.default_selector = :css
config.default_driver = :selenium
config.app_host = 'http://testem.co.uk
# Capybara.ignore_hidden_elements = false --video testing
config.include Capybara::DSL
end
After do
page.execute_script("window.localStorage.clear()")
end
After our chat discussion, it seems that touch-action needs rspec to be explicitly required. Your env.rb file should look like this:
require 'rspec'
require 'capybara'
require 'capybara/cucumber'
require 'touch_action'
I'm trying to get started with Mongoid in a Sinatra app, but it looks like I'm running into dependency issues. If it helps, I'm on a Macbook Pro using RVM and running Ruby 1.9.3.
Here are the errors I'm getting after running $ ruby config.ru:
/Users/duncanmalashock/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems/specification.rb:1637:in `raise_if_conflicts': Unable to activate mongoid-3.0.23, because activemodel-4.0.0 conflicts with activemodel (~> 3.1) (Gem::LoadError)
from /Users/duncanmalashock/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems/specification.rb:746:in `activate'
from /Users/duncanmalashock/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems.rb:212:in `rescue in try_activate'
from /Users/duncanmalashock/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems.rb:209:in `try_activate'
from /Users/duncanmalashock/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems/custom_require.rb:59:in `rescue in require'
from /Users/duncanmalashock/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems/custom_require.rb:35:in `require'
from /Users/duncanmalashock/Penumbra/penumbra.rb:4:in `<top (required)>'
from /Users/duncanmalashock/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/duncanmalashock/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from config.ru:2:in `<main>'
Can anyone help?
Here are the files involved:
mongoid.yml:
development:
sessions:
default:
database: mongoid
hosts:
- localhost:27017
config.ru:
require 'sinatra'
require './penumbra'
run Sinatra::Application
Gemfile:
source :rubygems
source :rubyforge
# Thin Server
gem 'thin'
# Sinatra
gem 'sinatra'
gem 'sinatra-contrib', :require => 'sinatra/multi_route'
gem 'sinatra-partial', :require => 'sinatra/partial'
gem 'sinatra-reloader'
# MongoDB
gem "mongoid"
# Shopify
gem 'shopify_api'
penumbra.rb:
require 'sinatra'
require 'shopify_api'
require 'mongo'
require 'mongoid'
require 'json'
require "sinatra/reloader" if development?
Mongoid.load!("./mongoid.yml", :production)
def isactivepage(link_name)
if (link_name == #page_name)
return ' activelink'
else return ''
end
end
get '/' do
#page_name = "Home"
erb :"pages/index"
end
get '/about' do
#page_name = "About"
erb :"pages/about"
end
After running $ bundle exec rackup:
/Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/mongoid-1.0.6/lib/mongoid.rb:68:in `method_missing': undefined method `load!' for #<Mongoid::Config:0x007fc0838cb1d0> (NoMethodError)
from /Users/duncanmalashock/Penumbra/penumbra.rb:9:in `<top (required)>'
from /Users/duncanmalashock/Penumbra/config.ru:2:in `require'
from /Users/duncanmalashock/Penumbra/config.ru:2:in `block in <main>'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
from /Users/duncanmalashock/Penumbra/config.ru:in `new'
from /Users/duncanmalashock/Penumbra/config.ru:in `<main>'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/server.rb:250:in `start'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/server.rb:141:in `start'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/bin/rackup:4:in `<top (required)>'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/bin/rackup:23:in `load'
from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/bin/rackup:23:in `<main>'
You have a Gemfile, but you’re not starting your app using Bundler, and that’s why you have the conflict.
The current version of shopify_api (3.0.3) has a dependency on activemodel via activeresource with the version requirements set to >=3.0.0. On your system you have Rails 4 installed, so activemodel 4.0 is loaded.
The current version of mongoid also has a dependency on activemodel, but this time the version requirement is ~> 3.2.
These two version requirements are not compatible, so you get the error activemodel-4.0.0 conflicts with activemodel (~> 3.1).
To fix it, simply use Bundler to start your app. You say you are running with $ ruby config.ru but this isn’t the correct way to use a config.ru (you would get errors later even if you fixed your dependency issues). You should use rackup. In this case you should run:
$ bundle exec rackup
I was trying to setup facebook app locally, using ruby and sinatra, in Kubuntu 12.04.
I have included following gems in my gemfile. I have postgresql installed in my system and I am able to run the postgresql command line and run basic commands as createdb, create table etc.
gem "sinatra"
gem "koala"
gem "json", "1.5.5"
gem "httparty"
gem "thin"
gem "rack", "1.3.10"
gem "pg"
gem "activerecord"
gem "sinatra-activerecord"
And in my app.rb file added these files,
require "rubygems"
require "sinatra"
require "sinatra/activerecord"
require "koala"
require "./config/environment" #database configuration
Running
rake -T
in my terminal gives me the following error.
rake aborted!
(<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 1
/var/lib/gems/1.9.1/gems/sinatra-activerecord-1.2.2/lib/sinatra/activerecord.rb:39:in `database_file='
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:1033:in `set'
/var/lib/gems/1.9.1/gems/sinatra-activerecord-1.2.2/lib/sinatra/activerecord.rb:50:in `registered'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:1317:in `block in register'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:1315:in `each'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:1315:in `register'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:1648:in `register'
/var/lib/gems/1.9.1/gems/sinatra-1.3.3/lib/sinatra/base.rb:1688:in `register'
/var/lib/gems/1.9.1/gems/sinatra-activerecord-1.2.2/lib/sinatra/activerecord.rb:76:in `<module:Sinatra>'
/var/lib/gems/1.9.1/gems/sinatra-activerecord-1.2.2/lib/sinatra/activerecord.rb:6:in `<top (required)>'
/home/nitin/facebook_app/guarded-gorge-3234/app.rb:3:in `<top (required)>'
/home/nitin/facebook_app/guarded-gorge-3234/Rakefile:1:in `<top (required)>'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/rake_module.rb:25:in `load'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/rake_module.rb:25:in `load_rakefile'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:589:in `raw_load_rakefile'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:89:in `block in load_rakefile'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:88:in `load_rakefile'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:72:in `block in run'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/var/lib/gems/1.9.1/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
Could any one please help. Thank you.
As #iain mentioned, this is due to a parse error in your config/database.yml file.
Check that it is valid syntax, and replace any tabs with spaces.
I have a Jenkins CI server and when I run following build script I get errors:
rdoc spec
Here is the errors:
/usr/bin/ruby1.9.1 -S rspec spec/requests/home_spec.rb
/home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/bundler-1.0.21/lib/bundler/spec_set.rb:88:in `block in materialize': Could not find json-1.6.5 in any of the sources (Bundler::GemNotFound)
from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/bundler-1.0.21/lib/bundler/spec_set.rb:82:in `map!'
from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/bundler-1.0.21/lib/bundler/spec_set.rb:82:in `materialize'
from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/bundler-1.0.21/lib/bundler/definition.rb:90:in `specs'
from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/bundler-1.0.21/lib/bundler/definition.rb:135:in `specs_for'
from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/bundler-1.0.21/lib/bundler/runtime.rb:11:in `setup'
from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/bundler-1.0.21/lib/bundler.rb:117:in `setup'
from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/bundler-1.0.21/lib/bundler.rb:122:in `require'
from /var/lib/jenkins/jobs/App1/workspace/config/boot.rb:10:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from /var/lib/jenkins/jobs/App1/workspace/spec/spec_helper.rb:11:in `<top (required)>'
from <internal:lib/rubygems/custom_require>:29:in `require'
from <internal:lib/rubygems/custom_require>:29:in `require'
from /var/lib/jenkins/jobs/App1/workspace/spec/requests/home_spec.rb:1:in `<top (required)>'
from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load'
from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `block in load_spec_files'
from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `map'
from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/configuration.rb:698:in `load_spec_files'
from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/command_line.rb:22:in `run'
from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:80:in `run_in_process'
from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:69:in `run'
from /home/zeck/.rvm/gems/ruby-1.9.3-p0/gems/rspec-core-2.8.0/lib/rspec/core/runner.rb:10:in `block in autorun'
rake aborted!
Here is the my Rakefile:
require 'rdoc/task'
require 'rspec/core/rake_task'
desc 'Generate test result'
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = 'spec/*/*_spec.rb'
end
And here is the my Gemfile:
source :rubygems
# Required gems
gem 'sinatra', '>= 1.3.2'
gem 'rdoc', '>= 3.12'
gem 'rake'
gem 'json', '>= 1.6.5'
group :test do
gem 'rspec', '>= 2.9.0'
gem 'rack-test'
gem 'simplecov', '>= 0.6.1', require: false
end
I don't have any idea. Please help me. I'm using Ruby 1.9.3 with RVM.
Thank you for every advise. Sorry for poor English :)
Probably the reason is that environment where Jenkins is running your build is different than the environment where you run the build.
Usually the difference is caused by an environment variable which is set for you but not for Jenkins
You can check your environment variables by running the command env. You can check Jenkins' environment at Manage Jenkins -> System Information.
If you need to set some environment variables, you can do it at Manage Jenkins -> Configure System.
I decided to go through the tutorial. After I create a new app and add new user:string email:string and then perform rake db:migrate in the app directory, I get this output:
rake aborted!
undefined method `task' for #<DemoApp::Application:0x00000100e49e08>
/usr/local/rvm/gems/ruby-1.9.2-p180#rails3tutorial/gems/railties-3.0.7/lib/rails/application.rb:215:in `initialize_tasks'
/usr/local/rvm/gems/ruby-1.9.2-p180#rails3tutorial/gems/railties-3.0.7/lib/rails/application.rb:139:in `load_tasks'
/usr/local/rvm/gems/ruby-1.9.2-p180#rails3tutorial/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing'
/Users/zigloo99/rails_projects/demo_app/Rakefile:7:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load'
/usr/local/rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load_rakefile'
/usr/local/rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.0/lib/rake/application.rb:495:in `raw_load_rakefile'
/usr/local/rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.0/lib/rake/application.rb:78:in `block in load_rakefile'
/usr/local/rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.0/lib/rake/application.rb:77:in `load_rakefile'
/usr/local/rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.0/lib/rake/application.rb:61:in `block in run'
/usr/local/rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.0/lib/rake/application.rb:59:in `run'
/usr/local/rvm/gems/ruby-1.9.2-p180#global/gems/rake-0.9.0/bin/rake:31:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.2-p180#global/bin/rake:19:in `load'
/usr/local/rvm/gems/ruby-1.9.2-p180#global/bin/rake:19:in `<main>'
I am using RVM too ruby 1.9.2 and rails 3.0.7 as in the tutorial.
Any thoughts?
This is happening because the latest version of Rake (0.9.0) is broken on Rails 3.0 applications and we are currently awaiting a solid fix.
Right now, a way around this error is to add this line above the load_tasks line in your application's Rakefile:
<AppName>::Application.send :include, ::Rake::DSL if defined?(::Rake::DSL)
Another solution is to require rake 0.8.7 in your Gemfile before starting a new rails project.
# Gemfile
gem 'rake', '0.8.7', :require => 'rake'
then run bundle install