10

After 24 hours of trying to find the problem with my app. I finally found the problem.

I ran

rake assets:precompile RAILS_ENV=production

and i kept on getting this error.

/Users/vezu/.rvm/rubies/ruby-1.9.3-p194/bin/ruby /Users/vezu/.rvm/gems/ruby-1.9.3-p194@global/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
database configuration does not specify adapter

Tasks: TOP => environment
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [/Users/vezu/.rvm/rubies/ruby-1.9.3-p194/bi...]

My database.yml file looks like this

development:
  adapter: postgresql
  host: localhost
  encoding: unicode
  database: ndoda_development
  pool: 5
  username:
  password:

test:
  adapter: postgresql
  encoding: unicode
  database: ndoda_test
  pool: 5
Benjamin
  • 2,108
  • 2
  • 26
  • 46

7 Answers7

30

The simple solution was to add one simple line to my application.rb

config.assets.initialize_on_precompile = false

And everything works.

Benjamin
  • 2,108
  • 2
  • 26
  • 46
10

This should work: rake assets:precompile RAILS_ENV=development

It tries to load up your production environment, when your database.yml doesn't include it.

Duke
  • 7,070
  • 3
  • 38
  • 28
  • A note for anyone using Asset Sync. Setting the RAILS_ENV to development will prevent Asset Sync from syncing after compilation. – Undistraction Oct 30 '13 at 19:54
7

Do this:

development:
  adapter: postgresql
  host: localhost
  encoding: unicode
  database: ndoda_development
  pool: 5
  username:
  password:

test:
  adapter: postgresql
  encoding: unicode
  database: ndoda_test
  pool: 5

# Add the below...

production:
  adapter: postgresql
  host: localhost
  encoding: unicode
  database: ndoda_production
  pool: 5
  username:
  password:

Heroku will overwrite your database.yml with its own version, regardless of what you put in there. However, your rake task running in the Production environment requires a variable, so give it a dummy one.

As noted above, you can also add 'config.assets.initialize_on_precompile = false' to your production.rb. If set, Heroku requires it be set to 'false'.

Leo Ajc
  • 133
  • 1
  • 3
  • Its worth noting that starting with Rails 4 Heroku now no longer overwrites your database.yml – D-Rock Jul 08 '16 at 17:21
2

This solution stopped working with rails 4, here is the updated one: just pass a dummy database as mentioned in this article:

https://iprog.com/posting/2013/07/errors-when-precompiling-assets-in-rails-4-0

The command is: bundle exec rake RAILS_ENV=production DATABASE_URL=postgresql://user:pass@127.0.0.1/dbname assets:precompile

Yazan Khalaileh
  • 589
  • 6
  • 15
1

What worked for me was this:

rake assets:precompile RAILS_ENV=production

Access your server via ssh and type that command in, it should do the trick.

Breno
  • 5,952
  • 1
  • 20
  • 25
1

Make sure you have some dummy production entry in your local config/database.yml file

production:
  <<: *default
  database: your_local_database_name

I've come across the same error in 2016 with Rails 4.2.6 and Capistrano 3.4. We were precompiling the assets during the deploy script just before uploading them together with the code, but rake assets:precompile needs some production entry, even if it's just a dummy one. Source: https://github.com/TalkingQuickly/capistrano-3-rails-template/issues/12

Hugo Sequeira
  • 474
  • 4
  • 10
-2

call rake assets:precompile:all

grosser
  • 14,707
  • 7
  • 57
  • 61