簡體   English   中英

將應用程序部署到Heroku:'NameError:uninitialized constant Devise'

[英]Deploying app to Heroku: 'NameError: uninitialized constant Devise'

我想將我的Rails應用程序部署到Heroku。 當然我還有一些額外的寶石,比如'devise'或'rails_admin'。 我嚴格遵循Rails Girls'教程( http://guides.railsgirls.com/heroku/ )。 運行git push heroku master時,我遇到了一些非常煩人的問題。

Counting objects: 220, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (198/198), done.
Writing objects: 100% (220/220), 94.69 KiB | 0 bytes/s, done.
Total 220 (delta 21), 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.0.0
remote: -----> Installing dependencies using 1.7.12
remote:        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote:        Fetching gem metadata from https://rubygems.org/...........
remote:        Installing i18n 0.7.0
remote:        Installing rake 10.4.2
remote:        Installing minitest 5.5.1
remote:        Installing thread_safe 0.3.4
remote:        Installing builder 3.2.2
remote:        Installing erubis 2.7.0
remote:        Installing mini_portile 0.6.2
remote:        Installing mime-types 2.4.3
remote:        Installing rack 1.6.0
remote:        Installing arel 6.0.0
remote:        Installing coffee-script-source 1.8.0
remote:        Installing execjs 2.2.2
remote:        Installing thor 0.19.1
remote:        Installing hike 1.2.3
remote:        Installing multi_json 1.10.1
remote:        Using bundler 1.7.12
remote:        Installing tilt 1.4.1
remote:        Installing rails_serve_static_assets 0.0.4
remote:        Installing rails_stdout_logging 0.0.3
remote:        Installing sass 3.4.10
remote:        Installing tzinfo 1.2.2
remote:        Installing json 1.8.2
remote:        Installing mail 2.6.3
remote:        Installing rack-test 0.6.3
remote:        Installing coffee-script 2.3.0
remote:        Installing sprockets 2.12.3
remote:        Installing rails_12factor 0.0.3
remote:        Installing activesupport 4.2.0.rc3
remote:        Installing rdoc 4.2.0
remote:        Installing uglifier 2.7.0
remote:        Installing rails-deprecated_sanitizer 1.0.3
remote:        Installing globalid 0.3.0
remote:        Installing activemodel 4.2.0.rc3
remote:        Installing jbuilder 2.2.6
remote:        Installing sdoc 0.4.1
remote:        Installing activejob 4.2.0.rc3
remote:        Installing activerecord 4.2.0.rc3
remote:        Installing nokogiri 1.6.6.2
remote:        Installing pg 0.18.1
remote:        Installing loofah 2.0.1
remote:        Installing rails-dom-testing 1.0.5
remote:        Installing rails-html-sanitizer 1.0.1
remote:        Installing actionview 4.2.0.rc3
remote:        Installing actionpack 4.2.0.rc3
remote:        Installing actionmailer 4.2.0.rc3
remote:        Installing sprockets-rails 2.2.4
remote:        Installing railties 4.2.0.rc3
remote:        Installing coffee-rails 4.1.0
remote:        Installing jquery-rails 4.0.1
remote:        Installing rails 4.2.0.rc3
remote:        Installing sass-rails 5.0.1
remote:        Installing turbolinks 2.5.3
remote:        Your bundle is complete!
remote:        Gems in the groups development and test were not installed.
remote:        It was installed into ./vendor/bundle
remote:        Post-install message from rdoc:
remote:        Depending on your version of ruby, you may need to install ruby rdoc/ri data:
remote:        <= 1.8.6 : unsupported
remote:        = 1.8.7 : gem install rdoc-data; rdoc-data --install
remote:        = 1.9.1 : gem install rdoc-data; rdoc-data --install
remote:        >= 1.9.2 : nothing to do! Yay!
remote:        Bundle completed (35.01s)
remote:        Cleaning up the bundler cache.
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        rake aborted!
remote:        NameError: uninitialized constant Devise
remote:        /tmp/build_8bd0cbc64dad003f3588b01ead189e3c/config/initializers/devise.rb:3:in '<top (required)>'
remote:        /tmp/build_8bd0cbc64dad003f3588b01ead189e3c/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0.rc3/lib/rails/engine.rb:652:in 'block in load_config_initializer'
remote:        /tmp/build_8bd0cbc64dad003f3588b01ead189e3c/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.0.rc3/lib/active_support/notifications.rb:166:in 'instrument'
remote:        /tmp/build_8bd0cbc64dad003f3588b01ead189e3c/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0.rc3/lib/rails/engine.rb:651:in 'load_config_initializer'
remote:        /tmp/build_8bd0cbc64dad003f3588b01ead189e3c/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0.rc3/lib/rails/engine.rb:616:in 'block (2 levels) in <class:Engine>'
remote:        /tmp/build_8bd0cbc64dad003f3588b01ead189e3c/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0.rc3/lib/rails/engine.rb:615:in 'each'
remote:        /tmp/build_8bd0cbc64dad003f3588b01ead189e3c/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0.rc3/lib/rails/engine.rb:615:in 'block in <class:Engine>'
remote:        /tmp/build_8bd0cbc64dad003f3588b01ead189e3c/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0.rc3/lib/rails/initializable.rb:30:in 'instance_exec'
remote:        /tmp/build_8bd0cbc64dad003f3588b01ead189e3c/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0.rc3/lib/rails/initializable.rb:30:in 'run'
remote:        /tmp/build_8bd0cbc64dad003f3588b01ead189e3c/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0.rc3/lib/rails/initializable.rb:55:in 'block in run_initializers'
remote:        /tmp/build_8bd0cbc64dad003f3588b01ead189e3c/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0.rc3/lib/rails/initializable.rb:44:in 'each'
remote:        /tmp/build_8bd0cbc64dad003f3588b01ead189e3c/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0.rc3/lib/rails/initializable.rb:44:in 'tsort_each_child'
remote:        /tmp/build_8bd0cbc64dad003f3588b01ead189e3c/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0.rc3/lib/rails/initializable.rb:54:in 'run_initializers'
remote:        /tmp/build_8bd0cbc64dad003f3588b01ead189e3c/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0.rc3/lib/rails/application.rb:352:in 'initialize!'
remote:        /tmp/build_8bd0cbc64dad003f3588b01ead189e3c/config/environment.rb:5:in '<top (required)>'
remote:        /tmp/build_8bd0cbc64dad003f3588b01ead189e3c/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0.rc3/lib/rails/application.rb:328:in 'require'
remote:        /tmp/build_8bd0cbc64dad003f3588b01ead189e3c/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0.rc3/lib/rails/application.rb:328:in 'require_environment!'
remote:        /tmp/build_8bd0cbc64dad003f3588b01ead189e3c/vendor/bundle/ruby/2.0.0/gems/railties-4.2.0.rc3/lib/rails/application.rb:443:in 'block in run_tasks_blocks'
remote:        /tmp/build_8bd0cbc64dad003f3588b01ead189e3c/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.2.4/lib/sprockets/rails/task.rb:64:in 'block (2 levels) in define'
remote:        Tasks: TOP => environment
remote:        (See full trace by running task with --trace)
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote: 
remote:  !     Push rejected, failed to compile Ruby app
remote: 
remote: Verifying deploy...
remote: 
remote: !   Push rejected to powerful-taiga-2060.
remote: 
To https://git.heroku.com/powerful-taiga-2060.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/powerful-taiga-2060.git`

這是我的Gemfile:

source 'https://rubygems.org'

gem 'rails', '4.2.0.rc3'
group :development do
  gem 'sqlite3'
end
group :production do
  gem 'pg'
  gem 'rails_12factor'
end
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc

group :development, :production, :test do
  gem 'byebug'
  gem 'web-console', '~> 2.0'
  gem 'spring'
  gem 'bootstrap-generators', '~> 3.3.1'
  gem 'simple_form', :git => 'git://github.com/plataformatec/simple_form.git'
  gem 'rails_admin'
  gem 'mocha'
  gem 'nifty-generators'
  gem 'jquery-turbolinks'
  gem 'devise'
end

問題必須是rake assets:precompile 誰能幫助我? 這個問題確實減慢了我的Rails冒險。

沒有你的寶石

group :development, :production, :test do

是基於Heroku日志安裝的。 嘗試將它們放在組外。

編輯:從“:development,:production,:test:”組中刪除Devise,因為Heroku不會在開發或測試組中安裝任何內容:

gem 'devise'

之后,轉到項目的根目錄並執行

git add .

將更改放入隊列中。 然后跑

git commit -m "adds devise to gemfile"

將更改添加到提交日志中。 然后跑

git push heroku master

一切都應該有效。

前一段時間我也遇到了這個問題:

git push origin master
To https://github.com/Joey-project/project.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/Joey-project/project.git'

我認為發生這種情況的主要原因之一是因為不應該將他/她的分支推送到更新的遠程分支。

一般的解決方案是使用類似的東西:

git fetch origin; git merge origin/master

代碼推送到heroku不工作給了我一些很好的見解如何解決它!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM