David
David

Reputation: 621

Heroku Ruby Sinatra rake error

I've been working on a Ruby Sinatra application for the past weeks and I'm now trying to deploy my application on Heroku but cant get rake tasks to work and would appreciate some help.

After some hours I have now managed to be able to launch the app and I can use it without errors. But I would like to be able to run my "seed" task to be able to add a admin user.

Because of this error I cant run the command "Heroku run db:seed".

Command error:

Running `rake db:seed` attached to terminal... up, run.9714
rake aborted!
cannot load such file -- rspec/core/rake_task
/app/rakefile:23:in `require'
/app/rakefile:23:in `block in <top (required)>'
/app/rakefile:21:in `<top (required)>'
(See full trace by running task with --trace)

Push Error:

Fetching repository, done.
Counting objects: 7, done.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 410 bytes, done.
Total 4 (delta 3), reused 0 (delta 0)

-----> Ruby app detected
-----> Compiling Ruby/Rack
-----> Using Ruby version: ruby-2.1.0
-----> Installing dependencies using 1.5.2
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
       Using rake (10.1.0)
       Using bcrypt (3.1.7)
       Using addressable (2.3.5)
       Using backports (3.6.0)
       Using timers (1.1.0)
       Using nio4r (1.0.0)
       Using fastercsv (1.5.5)
       Using json (1.8.1)
       Using multi_json (1.9.2)
       Using json_pure (1.8.1)
       Using uuidtools (2.1.4)
       Using stringex (1.5.1)
       Using ffi (1.9.3)
       Using rb-fsevent (0.9.4)
       Using rack (1.5.2)
       Using tilt (1.4.1)
       Using rubysl-securerandom (2.0.0)
       Using pg (0.17.1)
       Using temple (0.6.7)
       Using celluloid (0.15.2)
       Using bundler (1.5.2)
       Using data_objects (0.10.14)
       Using bcrypt-ruby (3.1.5)
       Using rb-inotify (0.9.3)
       Using dm-core (1.2.1)
       Using rack-protection (1.5.2)
       Using rack-test (0.6.2)
       Using slim (2.0.2)
       Using celluloid-io (0.15.0)
       Using do_postgres (0.10.14)
       Using dm-aggregates (1.2.0)
       Using sinatra (1.4.4)
       Using dm-migrations (1.2.0)
       Using dm-timestamps (1.2.0)
       Using dm-serializer (1.2.2)
       Using dm-constraints (1.2.0)
       Using dm-types (1.2.2)
       Using dm-validations (1.2.0)
       Using dm-do-adapter (1.2.0)
       Using listen (2.7.1)
       Using sinatra-contrib (1.4.2)
       Using dm-transactions (1.2.0)
       Using dm-postgres-adapter (1.2.0)
       Using data_mapper (1.2.0)
       Using rerun (0.9.0)
       Using sinatra-partial (0.4.0)
       Your bundle is complete!
       Gems in the groups development and test were not installed.
       It was installed into ./vendor/bundle
       Bundle completed (0.65s)
       Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
       Could not detect rake tasks
       ensure you can run `$ bundle exec rake -P` against your app with no environment variables present
       and using the production group of your Gemfile.
       This may be intentional, if you expected rake tasks to be run
       cancel the build (CTRL+C) and fix the error then commit the fix:
       rake aborted!
       cannot load such file -- rspec/core/rake_task
       /tmp/build_e454e1f9-d7ee-425e-b596-7852f5cf95f8/rakefile:23:in `require'
       /tmp/build_e454e1f9-d7ee-425e-b596-7852f5cf95f8/rakefile:23:in `block in <top (required)>'
       /tmp/build_e454e1f9-d7ee-425e-b596-7852f5cf95f8/vendor/ruby-2.1.0/lib/ruby/2.1.0/rake/task_manager.rb:196:in `in_namespace'
       /tmp/build_e454e1f9-d7ee-425e-b596-7852f5cf95f8/vendor/ruby-2.1.0/lib/ruby/2.1.0/rake/dsl_definition.rb:104:in `namespace'
       /tmp/build_e454e1f9-d7ee-425e-b596-7852f5cf95f8/rakefile:21:in `<top (required)>'
       /tmp/build_e454e1f9-d7ee-425e-b596-7852f5cf95f8/vendor/ruby-2.1.0/lib/ruby/2.1.0/rake/rake_module.rb:25:in `load'
       /tmp/build_e454e1f9-d7ee-425e-b596-7852f5cf95f8/vendor/ruby-2.1.0/lib/ruby/2.1.0/rake/rake_module.rb:25:in `load_rakefile'
       /tmp/build_e454e1f9-d7ee-425e-b596-7852f5cf95f8/vendor/ruby-2.1.0/lib/ruby/2.1.0/rake/application.rb:637:in `raw_load_rakefile'
       /tmp/build_e454e1f9-d7ee-425e-b596-7852f5cf95f8/vendor/ruby-2.1.0/lib/ruby/2.1.0/rake/application.rb:94:in `block in load_rakefile'
       /tmp/build_e454e1f9-d7ee-425e-b596-7852f5cf95f8/vendor/ruby-2.1.0/lib/ruby/2.1.0/rake/application.rb:165:in `standard_exception_handling'
       /tmp/build_e454e1f9-d7ee-425e-b596-7852f5cf95f8/vendor/ruby-2.1.0/lib/ruby/2.1.0/rake/application.rb:93:in `load_rakefile'
       /tmp/build_e454e1f9-d7ee-425e-b596-7852f5cf95f8/vendor/ruby-2.1.0/lib/ruby/2.1.0/rake/application.rb:77:in `block in run'
       /tmp/build_e454e1f9-d7ee-425e-b596-7852f5cf95f8/vendor/ruby-2.1.0/lib/ruby/2.1.0/rake/application.rb:165:in `standard_exception_handling'
       /tmp/build_e454e1f9-d7ee-425e-b596-7852f5cf95f8/vendor/ruby-2.1.0/lib/ruby/2.1.0/rake/application.rb:75:in `run'
       /tmp/build_e454e1f9-d7ee-425e-b596-7852f5cf95f8/vendor/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
       vendor/bundle/bin/rake:16:in `load'
       vendor/bundle/bin/rake:16:in `<main>'
-----> Discovering process types
       Procfile declares types -> web
       Default types for Ruby  -> console, rake

-----> Compressing... done, 19.0MB
-----> Launching... done, v9

Gemfile:

source 'https://rubygems.org'
ruby '2.1.0'

gem 'sinatra'
gem 'sinatra-partial'
gem 'data_mapper'
gem 'dm-sqlite-adapter', :group => :development
gem 'slim'
gem 'tilt', '~> 1.4.1' #temporary fix
gem 'rerun'
gem 'rubysl-securerandom'
gem 'sinatra-contrib'

group :production do
  gem 'rake'
  gem "pg"
  gem "dm-postgres-adapter"
end

Enviroment.rb:

Dir["./models/*.rb"].each {|model| require model}

configure :production do
  require_relative '../app'
  DataMapper.setup(:default, ENV['HEROKU_POSTGRESQL_PURPLE_URL'])
end

DataMapper.finalize

Procfile:

web: bundle exec rackup config.ru -p $PORT

Upvotes: 1

Views: 448

Answers (1)

Sam Starling
Sam Starling

Reputation: 5378

For some reason, rake db:seed is requiring rspec - seemingly on line 23 of /app/rakefile. I can see that this is missing from your Gemfile - try adding rspec to your Gemfile, pushing to Heroku, and trying again.

Upvotes: 1

Related Questions