Heroku Invalid database_url with mongohq - ruby-on-rails

Im trying to deploy my application in heroku. My app uses mongohq for the database. I have added the respective add-on to my app.
When deploying the app i get this error.
Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
** Notice: The native BSON extension was not loaded. **
For optimal performance, use of the BSON extension is recommended.
To enable the extension make sure ENV['BSON_EXT_DISABLED'] is not set
and run the following command:
gem install bson_ext
If you continue to receive this message after installing, make sure that
the bson_ext gem is in your load path.
rake aborted!
Invalid DATABASE_URL
(erb):9:in `rescue in <main>'
(erb):6:in `<main>'
/tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application/configuration.rb:106:in `database_configuration'
/tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/railtie.rb:174:in `block (2 levels) in <class:Railtie>'
/tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
/tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
/tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:28:in `block in on_load'
/tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:27:in `each'
/tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/lazy_load_hooks.rb:27:in `on_load'
/tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0/lib/active_record/railtie.rb:173:in `block in <class:Railtie>'
/tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
/tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
/tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
/tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
/tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
/tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
/tmp/build_3o2y20a7ewhl/config/environment.rb:5:in `<top (required)>'
/tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
/tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `block in require'
/tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
/tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in `require'
/tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:189:in `require_environment!'
/tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:249:in `block in run_tasks_blocks'
/tmp/build_3o2y20a7ewhl/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.0.0/lib/sprockets/rails/task.rb:54:in `block (2 levels) in define'
Tasks: TOP => environment
(See full trace by running task with --trace)
!
! Precompiling assets failed.
!
! Push rejected, failed to compile Ruby/Rails app
It looks like is trying to write the DATABASE_URL in database.yml but i don't use one. I just use monogoid.yml and set the proper ENV var MONGOHQ_URL.
Do i need to setup any configuration so heroku can detect i'm using mongo as my database?
EDIT:
My mongoid.yml file looks like this.
production:
sessions:
default:
uri: <%= ENV['MONGOHQ_URL'] %>
I have read that article, i'm following those steps.

In case anyone is going through the same, i had in my application.rb a reference to active record that i needed to take away:
#require "active_record/railtie"
Also double check your environments files, in some cases you could have some active_record configuration code.
Hope it helps.

Related

Rails - Ruby 3.1.1 will not load on CentOS but okay on OSX

I have a rails app that runs fine on my development iMac (Ventura). I pushed to production CentOS7. It bundled up fine but when trying to to assets precompile I get the error below. I have tried, removing lock file and re-bundling, updating bundler, did gem update and did yum update on server. I get the following when doing rake assets:clean precompile and I see similar error in apache log as well. I am running rails 7.0.4.2 and ruby 3.1.1. I need some guidance on how to resolve.
rake assets:clean precompile
rake aborted!
LoadError: cannot load such file -- Version
<internal:/usr/local/rvm/rubies/ruby-3.1.1/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
<internal:/usr/local/rvm/rubies/ruby-3.1.1/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
/usr/local/rvm/gems/ruby-3.1.1/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
/admin/bin/rails/catering_bk/config/initializers/active_admin.rb:290:in `block in <top (required)>'
/usr/local/rvm/gems/ruby-3.1.1/gems/activeadmin-2.13.1/lib/active_admin.rb:68:in `setup'
/admin/bin/rails/catering_bk/config/initializers/active_admin.rb:1:in `<top (required)>'
/usr/local/rvm/gems/ruby-3.1.1/gems/railties-7.0.4.2/lib/rails/engine.rb:667:in `load'
/usr/local/rvm/gems/ruby-3.1.1/gems/railties-7.0.4.2/lib/rails/engine.rb:667:in `block in load_config_initializer'
/usr/local/rvm/gems/ruby-3.1.1/gems/activesupport-7.0.4.2/lib/active_support/notifications.rb:208:in `instrument'
/usr/local/rvm/gems/ruby-3.1.1/gems/railties-7.0.4.2/lib/rails/engine.rb:666:in `load_config_initializer'
/usr/local/rvm/gems/ruby-3.1.1/gems/railties-7.0.4.2/lib/rails/engine.rb:620:in `block (2 levels) in <class:Engine>'
/usr/local/rvm/gems/ruby-3.1.1/gems/railties-7.0.4.2/lib/rails/engine.rb:619:in `each'
/usr/local/rvm/gems/ruby-3.1.1/gems/railties-7.0.4.2/lib/rails/engine.rb:619:in `block in <class:Engine>'
/usr/local/rvm/gems/ruby-3.1.1/gems/railties-7.0.4.2/lib/rails/initializable.rb:32:in `instance_exec'
/usr/local/rvm/gems/ruby-3.1.1/gems/railties-7.0.4.2/lib/rails/initializable.rb:32:in `run'
/usr/local/rvm/gems/ruby-3.1.1/gems/railties-7.0.4.2/lib/rails/initializable.rb:61:in `block in run_initializers'
/usr/local/rvm/gems/ruby-3.1.1/gems/railties-7.0.4.2/lib/rails/initializable.rb:50:in `each'
/usr/local/rvm/gems/ruby-3.1.1/gems/railties-7.0.4.2/lib/rails/initializable.rb:50:in `tsort_each_child'
/usr/local/rvm/gems/ruby-3.1.1/gems/railties-7.0.4.2/lib/rails/initializable.rb:60:in `run_initializers'
/usr/local/rvm/gems/ruby-3.1.1/gems/railties-7.0.4.2/lib/rails/application.rb:372:in `initialize!'
/admin/bin/rails/catering_bk/config/environment.rb:5:in `<top (required)>'
<internal:/usr/local/rvm/rubies/ruby-3.1.1/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
<internal:/usr/local/rvm/rubies/ruby-3.1.1/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
/usr/local/rvm/gems/ruby-3.1.1/gems/zeitwerk-2.6.6/lib/zeitwerk/kernel.rb:38:in `require'
/usr/local/rvm/gems/ruby-3.1.1/gems/railties-7.0.4.2/lib/rails/application.rb:348:in `require_environment!'
/usr/local/rvm/gems/ruby-3.1.1/gems/railties-7.0.4.2/lib/rails/application.rb:511:in `block in run_tasks_blocks'
/usr/local/rvm/gems/ruby-3.1.1/gems/sprockets-rails-3.4.2/lib/sprockets/rails/task.rb:61:in `block (2 levels) in define'
/usr/local/rvm/gems/ruby-3.1.1/bin/ruby_executable_hooks:22:in `eval'
/usr/local/rvm/gems/ruby-3.1.1/bin/ruby_executable_hooks:22:in `<main>'
Tasks: TOP => environment
(See full trace by running task with --trace)
As noted above. I tried
Remove lock file and bundle again.
gem update
yum update
Also to note this is also an older app that was upgraded to be in compliance with Veracode. It works perfectly on OSX, so the issue must be within CentOS.

Why are my Heroku pipeline review apps failing to build with the error: ActiveSupport::EncryptedFile::MissingKeyError

I am using Heroku Pipeline. My staging app is the parent app for my review apps so the environment variables are the same.
My staging app builds every time, no issues there. But, all of my review apps fail to build. The issue seems to be that the review app is missing the encryption key.
I've run heroku config:set RAILS_MASTER_KEY=##### -a my-app-staging-pr-99 to set the master key for the review app, but I still get the same build error.
Note:
- I'm using Rails 5.2.3 with credentials
- I have config.read_encrypted_secrets = true in my production.rb
- I have my `secret_key_base set in my credentials.yml
See the logs below:
Logs:
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
ActiveSupport::EncryptedFile::MissingKeyError: Missing encryption key to decrypt file with. Ask your team for your master key and write it to /tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/config/master.key or put it in the ENV['RAILS_MASTER_KEY'].
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/encrypted_file.rb:96:in `handle_missing_key'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/encrypted_file.rb:37:in `key'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/encrypted_file.rb:41:in `read'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/encrypted_configuration.rb:21:in `read'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/encrypted_configuration.rb:33:in `config'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/encrypted_configuration.rb:38:in `options'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/core_ext/module/delegation.rb:271:in `method_missing'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/config/environments/production.rb:102:in `block in <main>'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/railtie.rb:216:in `instance_eval'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/railtie.rb:216:in `configure'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/config/environments/production.rb:1:in `<main>'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/engine.rb:602:in `block (2 levels) in <class:Engine>'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/engine.rb:601:in `each'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/engine.rb:601:in `block in <class:Engine>'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `instance_exec'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `run'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/initializable.rb:61:in `block in run_initializers'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/initializable.rb:50:in `each'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/initializable.rb:50:in `tsort_each_child'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/initializable.rb:60:in `run_initializers'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/application.rb:361:in `initialize!'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/config/environment.rb:5:in `<main>'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/application.rb:337:in `require_environment!'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/railties-5.2.3/lib/rails/application.rb:520:in `block in run_tasks_blocks'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:62:in `block (2 levels) in define'
/tmp/build_0ef8f846f0fdc1456a3e91ed8dc095e6/vendor/bundle/ruby/2.6.0/gems/rake-12.3.2/exe/rake:27:in `<top (required)>'
Tasks: TOP => environment
(See full trace by running task with --trace)
!
! Precompiling assets failed.
!
! Push rejected, failed to compile Ruby app.
! Push failed
app.json
{
"scripts": {
"postdeploy": "rails db:migrate"
}
}
I've been trying to fix this issue for weeks now and I've not been able to figure it out. I'm a newbie, so I apologise if I've missed something obvious here.
One way would be to Add RAILS_MASTER_KEY to environment variables of
your staging app. Then in your review apps, you can inherit it from
staging app.
Generate the key by executing
rake secret
in your project directory
You can use the following command to set the config variable on your staging app
heroku config:set RAILS_MASTER_KEY=<KEY GENERATED BY rake secret> -a my-app-staging
Now in your app.json, you can add
"env": {
"RAILS_MASTER_KEY": {
"required": true
}
In this way, every newly created review app will take its RAILS_MASTER_KEY from staging app.
Hope it helps.

Error: uninitialized constant Sprockets::Helpers when pushing to Heroku

I just installed carrierwave and have set my rails 4 app up to store images on Amazon s3 through fog. The app was working and deploying to Heroku with Carrierwave (but images were getting purged with dyno). After some initial issues I got it working on my localhost (as far as I could tell).
Now I am having trouble pushing the new version to Heroku. I have reset the DATABASE. Precompiled the assets and now trying to migrate the database. Below is the error I'm getting.
Running `rake db:migrate` attached to terminal... up, run.6517
rake aborted!
uninitialized constant Sprockets::Helpers
/app/app/uploaders/image_uploader.rb:12:in `<class:ImageUploader>'
/app/app/uploaders/image_uploader.rb:4:in `<top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:465:in `block (2 levels) in eager_load!'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:464:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:464:in `block in eager_load!'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:462:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:462:in `eager_load!'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/engine.rb:347:in `eager_load!'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
/app/config/environment.rb:5:in `<top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:189:in `require_environment!'
/app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0/lib/rails/application.rb:249:in `block in run_tasks_blocks'
Tasks: TOP => db:migrate => environment
I have tried to include and not include Sprockets in the Uploader file and get the same error either way. I understand that Sprockets is no longer included in the master for Rails 4. I have now installed the sprockets-rails and sprockets-helper gems. I have also tried to require them at the top of the file (I don't understand this completely, but following this suggestion https://github.com/petebrowne/sprockets-helpers). Nothing has worked. Any suggestions about how I can go about resolving this. How do I initialize Sprockets::Helpers. Thanks.
I was making a pretty silly mistake. I had corrected files in my app and as committing the changes to the master, but I kept running the heroku run rake db:migrate command and getting the same error, so I didn't think I have resolved it yet. I had forgotten to push the new version to heroku! Hence the reason for still getting the same error.
Also, in case anyone else has a similar issue. Make sure you have fixed this:
https://github.com/carrierwaveuploader/carrierwave/issues/1020

Unable to deploy on Heroku after migrating rails app from 3.2.3 to rails 4.0.0.rc2

I have recently migrated an existing rails 3.2.3 app to rails 4.0.0.rc2. I have made all the necessary changes and have been able to make it work fine on my local. But when I push this to heroku - "git push heroku master", it says failed to push some refs. The follwoing is the stack trace -
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.rc2/lib/active_record/connection_adapters/postgresql_adapter.rb:825:in initialize'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.rc2/lib/active_record/connection_adapters/postgresql_adapter.rb:825:innew'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.rc2/lib/active_record/connection_adapters/postgresql_adapter.rb:825:in connect'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.rc2/lib/active_record/connection_adapters/postgresql_adapter.rb:542:ininitialize'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.rc2/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in new'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.rc2/lib/active_record/connection_adapters/postgresql_adapter.rb:41:inpostgresql_connection'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.rc2/lib/active_record/connection_adapters/abstract/connection_pool.rb:440:in new_connection'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.rc2/lib/active_record/connection_adapters/abstract/connection_pool.rb:450:incheckout_new_connection'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.rc2/lib/active_record/connection_adapters/abstract/connection_pool.rb:421:in acquire_connection'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.rc2/lib/active_record/connection_adapters/abstract/connection_pool.rb:356:inblock in checkout'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.rc2/lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in checkout'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.rc2/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:inblock in connection'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.rc2/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in connection'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.rc2/lib/active_record/connection_adapters/abstract/connection_pool.rb:546:inretrieve_connection'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.rc2/lib/active_record/connection_handling.rb:79:in retrieve_connection'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.rc2/lib/active_record/connection_handling.rb:53:inconnection'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.rc2/lib/active_record/model_schema.rb:203:in table_exists?'
/tmp/build_uqaojzpp3n68/lib/custom_active_record/domain_constants_pool.rb:13:inevaluate_constants'
/tmp/build_uqaojzpp3n68/app/models/user_type.rb:4:in <class:UserType>'
/tmp/build_uqaojzpp3n68/app/models/user_type.rb:1:in'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:228:in require'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:228:inblock in require'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:213:in load_dependency'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:228:inrequire'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:329:in require_or_load'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:462:inload_missing_constant'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:183:in const_missing'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:494:inload_missing_constant'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:183:in const_missing'
/tmp/build_uqaojzpp3n68/app/models/user.rb:13:in'
/tmp/build_uqaojzpp3n68/app/models/user.rb:1:in <top (required)>'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:228:inrequire'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:228:in block in require'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:213:inload_dependency'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:228:in require'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:329:inrequire_or_load'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:462:in load_missing_constant'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:183:inconst_missing'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/inflector/methods.rb:226:in const_get'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/inflector/methods.rb:226:inblock in constantize'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/inflector/methods.rb:224:in each'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/inflector/methods.rb:224:ininject'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/inflector/methods.rb:224:in constantize'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:534:inget'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:565:in constantize'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/devise-3.0.0.rc/lib/devise.rb:274:inget'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/devise-3.0.0.rc/lib/devise/mapping.rb:77:in to'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/devise-3.0.0.rc/lib/devise/mapping.rb:72:inmodules'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/devise-3.0.0.rc/lib/devise/mapping.rb:89:in routes'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/devise-3.0.0.rc/lib/devise/mapping.rb:156:indefault_used_route'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/devise-3.0.0.rc/lib/devise/mapping.rb:66:in initialize'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/devise-3.0.0.rc/lib/devise.rb:308:innew'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/devise-3.0.0.rc/lib/devise.rb:308:in add_mapping'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/devise-3.0.0.rc/lib/devise/rails/routes.rb:208:inblock in devise_for'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/devise-3.0.0.rc/lib/devise/rails/routes.rb:207:in each'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/devise-3.0.0.rc/lib/devise/rails/routes.rb:207:indevise_for'
/tmp/build_uqaojzpp3n68/config/routes.rb:55:in block in <top (required)>'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0.rc2/lib/action_dispatch/routing/route_set.rb:316:ininstance_exec'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0.rc2/lib/action_dispatch/routing/route_set.rb:316:in eval_block'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0.rc2/lib/action_dispatch/routing/route_set.rb:294:indraw'
/tmp/build_uqaojzpp3n68/config/routes.rb:1:in <top (required)>'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:222:inload'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:222:in block in load'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:213:inload_dependency'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:222:in load'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.rc2/lib/rails/application/routes_reloader.rb:40:inblock in load_paths'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.rc2/lib/rails/application/routes_reloader.rb:40:in each'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.rc2/lib/rails/application/routes_reloader.rb:40:inload_paths'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.rc2/lib/rails/application/routes_reloader.rb:16:in reload!'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.rc2/lib/rails/application/routes_reloader.rb:26:inblock in updater'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/file_update_checker.rb:75:in call'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/file_update_checker.rb:75:inexecute'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.rc2/lib/rails/application/routes_reloader.rb:27:in updater'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.rc2/lib/rails/application/routes_reloader.rb:6:inexecute_if_updated'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.rc2/lib/rails/application/finisher.rb:69:in block in <module:Finisher>'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.rc2/lib/rails/initializable.rb:30:ininstance_exec'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.rc2/lib/rails/initializable.rb:30:in run'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.rc2/lib/rails/initializable.rb:55:inblock in run_initializers'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.rc2/lib/rails/initializable.rb:54:in run_initializers'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.rc2/lib/rails/application.rb:215:ininitialize!'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.rc2/lib/rails/railtie/configurable.rb:30:in method_missing'
/tmp/build_uqaojzpp3n68/config/environment.rb:5:in'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:228:in require'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:228:inblock in require'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:213:in load_dependency'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc2/lib/active_support/dependencies.rb:228:inrequire'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.rc2/lib/rails/application.rb:189:in require_environment!'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.rc2/lib/rails/application.rb:249:inblock in run_tasks_blocks'
/tmp/build_uqaojzpp3n68/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.0.0/lib/sprockets/rails/task.rb:54:in `block (2 levels) in define'
Tasks: TOP => environment
(See full trace by running task with --trace)
!
! Precompiling assets failed.
!
! Push rejected, failed to compile Ruby/Rails app
I use postgres on my local also, and its working fine. This app was previously deployed on heroku. I have added ruby 2.0.0 in Gemfile and the logs indicate that they are using ruby 2.0.0. I am not sure how to debug this. Is there any other change required to migrate existing app on heroku to 4.0.
Any help would be appreciated.
Thanks in advance.
Your problem is during slug compilation the environment variables are not available to your app. Try installing the user-env-compile labs feature.

Heroku database configuration specifies nonexistent mysql adapter

I can't seem to overcome the above error on heroku. I am running rails 3 with the mysql2 gem locally just fine, but this seems to break when moving to heroku.
First, I am using ClearDB.
Second, when I deploy and try to run heroku run rake db:migrate, heroku tells me I need to add the mysql gem and the activerecord-mysql-adapter. Why on earth would this happen when I am using mysql2?
Third, when I add mysql and the adapter to my project, and I get past the issue of heroku telling me I need those gems in my project. So, I run rake db:migrate again, and, now I get different error...
rake aborted!
database configuration specifies nonexistent mysql adapter
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_specification.rb:133:in `establish_connection'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/lazy_load_hooks.rb:26:in `block in on_load'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/lazy_load_hooks.rb:25:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/lazy_load_hooks.rb:25:in `on_load'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/railtie.rb:74:in `block in <class:Railtie>'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/initializable.rb:30:in `instance_exec'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/initializable.rb:30:in `run'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/initializable.rb:55:in `block in run_initializers'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/initializable.rb:54:in `each'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/initializable.rb:54:in `run_initializers'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/application.rb:136:in `initialize!'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/railtie/configurable.rb:30:in `method_missing'
/app/config/environment.rb:5:in `<top (required)>'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `block in require'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/application.rb:103:in `require_environment!'
/app/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/application.rb:297:in `block (2 levels) in initialize_tasks'
When I check out my database.yml, I see that heroku has injected postgresql as the adapter, however the error outputed clearly states mysql... If anybody can help me on this issue I would really appreciate it. I don't know what to do with heroku...
Heroku injected postgresql because you failed to specify the heroku config property DATABASE_URL.
I give detailed instructions in this post - https://stackoverflow.com/a/17815729/1626020
But in a nutshell you need to set it using something like this:
heroku config:set DATABASE_URL=mysql2://bb06ca765fb123:71b6d123#us-cdbr-east-04.cleardb.com/heroku_703eded6aebc123?reconnect=true
Remember your database.yml is completely ignored by Heroku. That's right, ignored. The DATABASE_URL is all that matters.
Heroku uses Postgresql.
You could use mysql2 in your dev/test environments and postgresql in production (i.e. on Heroku).
group :development, :test do
gem 'mysql2'
end
group :production do
gem 'pg'
end

Resources