【问题标题】:Heroku Ruby Sinatra rake errorHeroku Ruby Sinatra 耙子错误
【发布时间】:2014-07-21 03:10:03
【问题描述】:

过去几周我一直在开发一个 Ruby Sinatra 应用程序,现在我正尝试在 Heroku 上部署我的应用程序,但无法让 rake 任务正常工作,希望能得到一些帮助。

几个小时后,我现在能够启动该应用程序,并且可以毫无错误地使用它。但我希望能够运行我的“种子”任务以添加管理员用户。

由于这个错误,我无法运行命令“Heroku run db:seed”。

命令错误:

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)

推送错误:

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

宝石文件:

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

环境.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

过程文件:

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

【问题讨论】:

    标签: ruby heroku sinatra rake


    【解决方案1】:

    出于某种原因,rake db:seed 需要 rspec - 似乎在 /app/rakefile 的第 23 行。我可以看到您的 Gemfile 中缺少此内容 - 尝试将 rspec 添加到您的 Gemfile,推送到 Heroku,然后重试。

    【讨论】:

      猜你喜欢
      • 2011-09-16
      • 1970-01-01
      • 2015-09-16
      • 1970-01-01
      • 1970-01-01
      • 2011-10-25
      • 2016-03-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多