Deploying app to Heroku: 'NameError: uninitialized constant Devise'
Deploying app to Heroku: 'NameError: uninitialized constant Devise'
我想将我的 Rails 应用程序部署到 Heroku。当然,我还有一些额外的 gem,比如 'devise' 或 'rails_admin'。我严格遵守 Rails 少女教程 (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 冒险。
不久前我也遇到了这个问题,发生了以下情况:
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'
我认为发生这种情况的主要原因之一是因为不应该将 his/her 分支推送到更新的远程分支。
一般的解决方案是使用类似的东西:
git fetch origin; git merge origin/master
code push to heroku not working 也给了我一些关于如何解决它的深刻见解!
编辑:从“:development, :production, :test:”组中删除 Devise,因为 Heroku 不会在开发或测试组中安装任何东西:
gem 'devise'
之后,进入项目的根目录并执行
git add .
将更改放入队列。然后 运行
git commit -m "adds devise to gemfile"
将更改添加到您的提交日志。然后运行
git push heroku master
一切都应该正常。
None 个
中的宝石
group :development, :production, :test do
是根据 Heroku 日志安装的。尝试将它们放在组之外。
我想将我的 Rails 应用程序部署到 Heroku。当然,我还有一些额外的 gem,比如 'devise' 或 'rails_admin'。我严格遵守 Rails 少女教程 (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 冒险。
不久前我也遇到了这个问题,发生了以下情况:
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'
我认为发生这种情况的主要原因之一是因为不应该将 his/her 分支推送到更新的远程分支。
一般的解决方案是使用类似的东西:
git fetch origin; git merge origin/master
code push to heroku not working 也给了我一些关于如何解决它的深刻见解!
编辑:从“:development, :production, :test:”组中删除 Devise,因为 Heroku 不会在开发或测试组中安装任何东西:
gem 'devise'
之后,进入项目的根目录并执行
git add .
将更改放入队列。然后 运行
git commit -m "adds devise to gemfile"
将更改添加到您的提交日志。然后运行
git push heroku master
一切都应该正常。
None 个
中的宝石group :development, :production, :test do
是根据 Heroku 日志安装的。尝试将它们放在组之外。