Rails rake assets:precompile for production Rails rake assets:precompile for production ruby-on-rails ruby-on-rails

Rails rake assets:precompile for production


Old question but the accepted answer doesn't really answer the question - and I just found this in a search so I guess it's relevant.

The reason for the error is that gem 'pg' is in the production gem group.
When you run rake assets:precompile the production environment is accessed. So it is trying to load the production environment but you don't have all of the dependencies installed.

Running RAILS_ENV=production bundle exec rails server would probably give you a similar error.

I can think of two different solutions

1) Look to see if you have a .bundle/config file in your app's root. If you do, check if it says WITHOUT :production or similar. Either remove that line or the whole .bundle directory and run bundle again.

2) in Gemfile

gem :development, :production do  gem 'pg'end

while removing the :production group
run bundle again

Sorry to bring up old stuff...