teaching myself rails deploying first app to heroku -failure to upload - sqlite3 and postgre glitch

拥有回忆 提交于 2019-12-06 08:16:10

The right configuration in your case has already been posted in other answers and I attach it here for your convenience.

group :production do
  gem 'pg'
end

group :development, :test do
  gem 'sqlite3'
end

However, keep in mind that when you run bundle install, bundler will try to install all gems for all environments. Later, it will load only the gems for the specified environment at runtime.

This is the reason why on your local machine it is trying to install pg as well.

You have two possibilities to solve the compilation error:

  1. Install libpq, the library required by the pg gem to compile. You don't need to install the full PostgreSQL client or stack, libpq is enough to pass compilation. On MacOSX you might want to install it using homebrew.

  2. Tell bundler to skip unnecessary groups when running install.

    bundle install --without production
    

As a side note, please keep in mind that SQLite and PostgreSQL are two different databases. It's always a good idea to use a development environment as similar as possible to the production one. My personal suggestion is to install PostgreSQL on your local machine and use it both on development and production.

Again, homebrew is your friend.

$ brew install postgresql

You'll want to install Postgres locally. It appears that you're on a Mac, so the easiest way would be to use the installer here:

http://www.postgresql.org/download/macosx/

Then stick with this in your Gemfile:

gem 'pg'

So this is what worked: 1) Install postgresql on the machine

2) For permanent fix - Go to the .bash_rc file and add the following: export PATH = "/Library/PostgreSQL/9.1/bin/":$PATH OR just to install the missing files and run the bundle command one time type this in the root of the app: PATH=$PATH:/Library/PostgreSQL/9.1/bin/ bundle install or PATH=$PATH:/Library/PostgreSQL/9.1/bin/ gem install pg

3) Now the pg gem is installed

This post was helpful: http://excid3.com/blog/installing-postgresql-and-pg-gem-on-mac-osx/

Try

group :production do
  gem 'pg'
end

group :development do
  gem 'sqlite3'
end

I think the reason for the error that the pg is not installed on your system, so you can not install the gem.

Although heroku not advised to use a different database, I have worked like this:

group :test, :development do
  gem 'sqlite3'
end

group :production do
  gem 'pg'
end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!