我开始浏览Odin项目的课程,开始使用Ubuntu,并且正在经历Installfests guide on deploying a Rails App.我在第2.5步遇到了麻烦。
以下是我得到的结果:
$ git push heroku master
Counting objects: 117, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (103/103), done.
Writing objects: 100% (117/117), 25.89 KiB | 0 bytes/s, done.
Total 117 (delta 8), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.3.4
remote: -----> Installing dependencies using bundler 1.13.7
remote: Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote: Warning: the running version of Bundler (1.13.7) is older than the version that created the lockfile (1.14.6). We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
remote: Fetching gem metadata from https://rubygems.org/.........
remote: Fetching version metadata from https://rubygems.org/..
remote: Fetching dependency metadata from https://rubygems.org/.
remote: Installing rake 12.0.0
remote: Installing i18n 0.8.1
remote: Installing concurrent-ruby 1.0.5
remote: Installing minitest 5.10.1
remote: Installing thread_safe 0.3.6
remote: Installing builder 3.2.3
remote: Installing erubis 2.7.0
remote: Installing mini_portile2 2.1.0
remote: Installing nio4r 2.0.0 with native extensions
remote: Installing rack 2.0.1
remote: Installing websocket-extensions 0.1.2
remote: Installing arel 7.1.4
remote: Installing mime-types-data 3.2016.0521
remote: Installing coffee-script-source 1.12.2
remote: Installing execjs 2.7.0
remote: Installing thor 0.19.4
remote: Installing method_source 0.8.2
remote: Installing multi_json 1.12.1
remote: Installing pg 0.20.0 with native extensions
remote: Installing puma 3.8.2 with native extensions
remote: Using bundler 1.13.7
remote: Installing sass 3.4.23
remote: Installing tilt 2.0.7
remote: Installing turbolinks-source 5.0.0
remote: Installing tzinfo 1.2.3
remote: Installing nokogiri 1.7.1 with native extensions
remote: Installing rack-test 0.6.3
remote: Installing sprockets 3.7.1
remote: Installing websocket-driver 0.6.5 with native extensions
remote: Installing mime-types 3.1
remote: Installing coffee-script 2.4.1
remote: Installing uglifier 3.2.0
remote: Installing turbolinks 5.0.1
remote: Installing activesupport 5.0.2
remote: Installing mail 2.6.4
remote: Installing globalid 0.4.0
remote: Installing activemodel 5.0.2
remote: Installing jbuilder 2.6.3
remote: Installing activejob 5.0.2
remote: Installing activerecord 5.0.2
remote: Installing rails-dom-testing 2.0.2
remote: Installing loofah 2.0.3
remote: Installing rails-html-sanitizer 1.0.3
remote: Installing actionview 5.0.2
remote: Installing actionpack 5.0.2
remote: Installing actioncable 5.0.2
remote: Installing actionmailer 5.0.2
remote: Installing railties 5.0.2
remote: Installing sprockets-rails 3.2.0
remote: Installing rails 5.0.2
remote: Installing coffee-rails 4.2.1
remote: Installing sass-rails 5.0.6
remote: Installing jquery-rails 4.3.1
remote: Bundle complete! 16 Gemfile dependencies, 53 gems now installed.
remote: Gems in the groups development and test were not installed.
remote: Bundled gems are installed into ./vendor/bundle.
remote: Bundle completed (26.35s)
remote: Cleaning up the bundler cache.
remote: -----> Installing node-v6.10.0-linux-x64
remote: -----> Detecting rake tasks
remote: -----> Preparing app for Rails asset pipeline
remote: Running: rake assets:precompile
remote: rake aborted!
remote: NoMethodError: undefined method `roots' for #<ActionDispatch::Routing::Mapper:0x007fc37aff5b28>
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/config/routes.rb:2:in `block in <top (required)>'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.2/lib/action_dispatch/routing/route_set.rb:389:in `instance_exec'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.2/lib/action_dispatch/routing/route_set.rb:389:in `eval_block'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.2/lib/action_dispatch/routing/route_set.rb:371:in `draw'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/config/routes.rb:1:in `<top (required)>'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:287:in `load'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:287:in `block in load'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:259:in `load_dependency'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:287:in `load'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/application/routes_reloader.rb:40:in `each'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/application/routes_reloader.rb:40:in `load_paths'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/application/routes_reloader.rb:16:in `reload!'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/application/routes_reloader.rb:26:in `block in updater'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.2/lib/active_support/file_update_checker.rb:77:in `execute'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/application/routes_reloader.rb:27:in `updater'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/application/finisher.rb:119:in `block in <module:Finisher>'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/initializable.rb:30:in `instance_exec'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/initializable.rb:30:in `run'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/initializable.rb:55:in `block in run_initializers'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/initializable.rb:54:in `run_initializers'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/application.rb:352:in `initialize!'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/config/environment.rb:5:in `<top (required)>'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/application.rb:328:in `require'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/application.rb:328:in `require_environment!'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/railties-5.0.2/lib/rails/application.rb:448:in `block in run_tasks_blocks'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/sprockets-rails-3.2.0/lib/sprockets/rails/task.rb:62:in `block (2 levels) in define'
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/vendor/bundle/ruby/2.3.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
remote: Tasks: TOP => environment
remote: (See full trace by running task with --trace)
remote: !
remote: ! Precompiling assets failed.
remote: !
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to evening-harbor-57945.
remote:
To https://git.heroku.com/evening-harbor-57945.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/evening-harbor-57945.git'
我尝试了不同的东西,例如编辑我的gem文件替换:
gem 'sqlite3'
使用:
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
我还尝试按照git push heroku master
的反馈中的说明更新gemfile,输入:
gem install bundler
但它会产生相同的结果。
答案 0 :(得分:1)
检查您的日志,您会发现错误:
remote: NoMethodError: undefined method `roots' for #<ActionDispatch::Routing::Mapper:0x007fc37aff5b28>
remote: /tmp/build_e6fc23c1f302b4f1aa2bdeafdf93c2f5/config/routes.rb:2:in `block in <top (required)>'
如果仔细阅读,您会发现生成错误的文件和行号:config/routes.rb:2
。
由此我假设您在步骤 2.3 中使用了roots
而不是root
,因此请打开config/routes.rb
并检查您是否拥有此内容:
root 'drinks#index'
那应该解决你的问题。