The error:
rake aborted!
Gem::LoadError: Specified 'postgresql' for database adapter, but the
gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its
version is at the minimum required by ActiveRecord).
My Gemfile includes:
group :production do
gem 'pg', '~> 0.18.4'
gem 'rails_12factor', '~> 0.0.3'
end
I've already updated the bundler using "--without production" and all, but still getting the same error...
Add pg in gemfile
group :production do
gem 'pg', '~> 0.21'
gem 'rails_12factor'
end
#Terminal
>$ bundle install
>$ git add .
>$ git commit -m 'pg added'
>$ git push heroku master
Make sure Gemfile.lock updated and has pg.
ensure its version is at the minimum required by ActiveRecord
I have just pushed it into Heroku for testing using pg version 0.20.0
group :production do
gem 'pg', '~> 0.20.0'
gem 'rails_12factor'
end
Once you make this update in your group production of your Gemfile, ensure you run bundle install --without production (to update Gemfile.lock file), do a git add/commit cycle, then re-deploy to Heroku.
and then
heroku run rake db:migrate
Related
I have a Gemfile with spring defined in :development like so:
source 'https://rubygems.org'
# Rake and rails
gem 'rake', '~> 10.4.2'
gem 'rails', '4.1.13'
group :production do
gem 'unicorn', '~> 4.8.3'
end
group :development, :staging do
gem 'spring'
end
However it's being installed on the server whenever I deploy.
The command which is issued by capistrano looks like this: cd /home/app_user/apps/ag/releases/20150921131835 && bundle install --gemfile /home/app_user/apps/ag/releases/20150921131835/Gemfile --path /home/app_user/apps/ag/shared/bundle --deployment --without development test
I do not understand why? How can I get rid of spring?
My bundler version is 1.10.6
As Yury Lebedev mentioned in a comment, you haven't excluded the staging group in the without flag, therefore gems defined as staging also installed (including spree in your case).
I am trying to use postgresql with Ruby on Rails on Heroku but got an error
Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError)
Please help me to solve this issue.
This worked for me
gem 'pg', '~> 0.20'
Thanks to Piers C
Got this answer from
Heroku and Rails: Gem Load Error with Postgres, however it is Specified in GEMFILE
In your Gemfile
group :production do
gem 'pg'
end
Then run bundle install and try to deploy on Heroku.
If you want to use PostgreSQL on all environments and not only in production (recommended) add the gem outside the :production group and remove other database adapters such as sqlite.
As a side note, you may also want to add the rails_12factor gem as suggested by Heroku.
Add pg in gemfile
gem 'pg', '~> 0.20'
then bundle update & commit Gemfile & Gemfile.lock to heroku.
simple include like gem 'pg' will not work.
I added the following version into my gemfile, and it is solved.
gem "pg", "~> 0.18"
I am new to programming and using RAILS on Cloud9 IDE. I am having difficulty trying to push my app into Heroku. I get the error:...
Push rejected, no Cedar-supported app detected
remote: HINT: This occurs when Heroku cannot detect the buildpack
remote:
NOTE: The tutorial I am following tells me at Heroku setup section:
Heroku uses the PostgreSQL database (pronounced “post-gres-cue-ell”,
and often called “Postgres” for short), which means that we need to
add the pg gem in the production environment to allow Rails to talk to
Postgres:17
group :production do
gem 'pg', '0.17.1'
gem 'rails_12factor', '0.0.2’
end
Question: How do I ADD the pg gem in the production environment (I suspect that the push rejected error is due to this)
There should be a file in your application called Gemfile
open it up and add:
group :production do
gem 'pg', '0.17.1'
gem 'rails_12factor', '0.0.2'
end
save the file, commit and try again.
In your Gemfile
group :production do
gem 'pg', '0.17.1'
gem 'rails_12factor'
end
and also remove gem 'sqlite3' OR
group :development, :test do
gem 'sqlite3'
end
Because heroku can't install the sqlite3 gem. But you can tell bundler that it shouldn't be trying to except when developing.
Then run bundle install and try to deploy on Heroku.
I'm trying to push an Enki gem blog to Heroku and I'm getting an error
Could not find jquery-rails-2.0.0 in any of the sources
However, in the Gemfile I had
`gem 'jquery-rails'`
and I've never had a problem pushing an Enki blog with this setup before. Here's the full error message
Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment
Fetching gem metadata from https://rubygems.org/.......
Could not find jquery-rails-2.0.0 in any of the sources
!
! Failed to install gems via Bundler.
!
! Heroku push rejected, failed to compile Ruby/rails app
After I got the error message I added this to the gemfile
gem 'jquery-rails-2.0.0'
I got this error message
Could not find gem 'jquery-rails-2.0.0 (>= 0) java' in the gems available on this machine.
I then tried to do
gem install jquery-rails
It gave me
Successfully installed jquery-rails-2.0.2
1 gem installed
Installing ri documentation for jquery-rails-2.0.2...
Installing RDoc documentation for jquery-rails-2.0.2...
But the push didn't work, same error
-----> Heroku receiving push
-----> Ruby/Rails app detected
-----> Installing dependencies using Bundler version 1.2.0.rc
Running: bundle install --without development:test --path vendor/bundle --binstubs bin/ --deployment
Fetching gem metadata from https://rubygems.org/.......
Could not find jquery-rails-2.0.0 in any of the sources
!
! Failed to install gems via Bundler.
!
! Heroku push rejected, failed to compile Ruby/rails app
this is the gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.6'
gem 'heroku'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
group :production do
gem 'thin'
end
platforms :jruby do
gem 'activerecord-jdbcsqlite3-adapter'
gem 'trinidad'
gem 'jruby-openssl'
end
gem 'jquery-rails'
#gem 'jquery-rails-2.0.0'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug'
# Bundle the extra gems:
gem 'RedCloth', '~> 4.2.9', :require => 'redcloth'
gem 'ruby-openid', :require => 'openid'
gem 'rack-openid', :require => 'rack/openid'
gem 'aaronh-chronic', :require => 'chronic' # Fixes for 1.9.2
gem 'coderay'
gem 'lesstile'
gem 'formtastic'
gem 'will_paginate', '~> 3.0.2'
gem 'exception_notification', '~> 2.5.2'
gem 'open_id_authentication'
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
group :test do
gem 'database_cleaner'
gem 'cucumber-rails', :require => false
gem 'cucumber-websteps', :require => false
gem 'factory_girl'
gem 'rspec'
gem 'nokogiri', '~> 1.5.0'
gem 'webrat'
end
group :development, :test do
gem 'rspec-rails'
end
I was getting this same error and fixed it using:
bundle update jquery-rails
In looking into it, it appears that jquery-rails 2.0.0 was yanked from rubygems: http://d.pr/i/cLms/1ReBI4U8 for whatever reason. So you (and I) likely happened to install jquery-rails when that gem was the most current version.
It's also wise to note that deleting your Gemfile.lock can be dangerous and not recommended in most cases. This causes all the latest versions of every gem without a version number in your Gemfile to be downloaded. If gems have been updated with API-breaking changes (happens more often than you might think), your app could break. But it also might not. Just be careful, run test cases if you have them. This has caused me more than one headache.
You can read a bit more about how bundler, Gemfile, and Gemfile.lock work (as well as guidance on how to properly upgrade certain gems) here: http://viget.com/extend/bundler-best-practices
Worked for me:
delete the Gemfile.lock
removed the rails version from the line => gem 'rails' (jquery was already without a v number)
run the command "bundle install"
run also "bundle update jquery-rails" to make sure everything is updated
IMPORTANT, commit the new .lock file => run the "git add ." and "git commit ..."
push everything
Update:
I am going through mhartl's Rails Tutorials and had to update jquery-rails, '2.0.1' in the Gemfile, to get the bundle update jquery-rails going.
Thanks,
Jatin
i had similar issue by changing in Gemfile jquery-rails-2.0.0 to 2.0.1 will solved my problem.
Michael,
I had to remove the version number from my jquery gem from 2.0.0 and let it pull the latest for this to work. I am on rails 3.2.8.rc2 and running on the cedar stack of heroku. Best of luck!
Mark
I have a small web app, which uses a bunch of gems. Some of them are only used for test and development environments. Now, when I try to start unicorn on the production server using the following command, it fails.
unicorn_rails -E production -D -c config/unicorn.rb
The error I see in the log files is:
Refreshing Gem list
Could not find gem 'spork (>= 0.9.0.rc2, runtime)' in any of the gem sources listed in your Gemfile.
Try running `bundle install`.
I've pasted my gemfile below:
source 'http://rubygems.org'
gem 'rails', '3.0.1'
gem 'unicorn'
gem 'mongoid', '>= 2.0.0.beta.19'
gem 'devise'
gem 'cancan'
gem 'haml', '>= 3.0.0'
gem 'bson'
gem 'bson_ext'
gem 'formtastic'
gem 'bluecloth'
group :production do
gem 'capistrano'
end
group :development do
gem 'haml-rails'
gem 'hpricot', '0.8.2'
gem 'ruby_parser', '2.0.5'
gem 'less'
gem 'rspec-rails', '>= 2.0.1'
end
group :development,:test do
gem 'spork', '>=0.9.0.rc2'
gem 'mongoid-rspec'
end
group :test do
gem 'factory_girl_rails'
gem 'autotest'
gem 'cucumber-rails'
gem 'cucumber'
gem 'capybara'
gem 'shoulda'
gem 'database_cleaner'
gem 'test_notifier'
gem 'rspec', '2.0.1'
gem 'launchy'
end
Bundler is supposed to detect the right environment and ignore the other gems, right? Right now, I am deleting all the lines which are not in the default group on the server to get this working, but that's an ugly hack.
After a lot of digging I found the fix for this issue. All I had to do was run bundle install --without development test before starting the server. This adds a .bundle/config file in the rails root with the line BUNDLE_WITHOUT: test:development . Now whenever you run bundle install or start the server it'll ignore those groups.
From the documentation
The Bundler CLI allows you to specify
a list of groups whose gems bundle
install should not install with the
--without option. To specify multiple groups to ignore, specify a list of
groups separated by spaces.
bundle install --without test bundle
install --without development test
After running bundle install --without
test, bundler will remember that you
excluded the test group in the last
installation. The next time you run
bundle install, without any --without
option, bundler will recall it.
Also, calling Bundler.setup with no
parameters, or calling require
"bundler/setup" will setup all groups
except for the ones you excluded via
--without (since they are obviously not available).
In my case it was installing gems from jenkins env. So i had to set my own bundle_without variable in capistrano.
Gemfile
group :test, :development, :jenkins do
gem 'test-unit', '1.2.3'
gem 'rspec-rails'
end
deploy.rb
set :bundle_without, [:development, :test, :jenkins]
You haven't defined a production group =)