unable to run rake db:migrate with docker compose - docker-compose

I am new to docker and was trying to follow this tutorial learn docker
I am getting following error while trying to run
docker-compose run web rake db:create
I tried removing entrypoint of DockerFile but it is the same results. Could anyone point me what I am doing wrong ?
/usr/local/bundle/gems/thor-0.20.0/lib/thor/base.rb:507:in `handle_argument_error': ERROR: "rails server" was called with arguments ["db:create"] (Thor::InvocationError)
Usage: "rails server [puma, thin etc] [options]"
from /usr/local/bundle/gems/thor-0.20.0/lib/thor/command.rb:34:in `rescue in run'
from /usr/local/bundle/gems/thor-0.20.0/lib/thor/command.rb:21:in `run'
from /usr/local/bundle/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
from /usr/local/bundle/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
from /usr/local/bundle/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform'
from /usr/local/bundle/gems/railties-5.1.4/lib/rails/command.rb:44:in `invoke'
from /usr/local/bundle/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
from /myapp/bin/rails:9:in `require'
from /myapp/bin/rails:9:in `<top (required)>'
from /usr/local/bundle/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
from /usr/local/bundle/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
from /usr/local/bundle/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
from /usr/local/bundle/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
from /usr/local/bundle/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
from /usr/local/bundle/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
from /usr/local/bundle/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
from /myapp/bin/spring:15:in `require'
from /myapp/bin/spring:15:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'

Better late than never. After cloning the git repo you want to replace the Dockerfile with the Dockerfile from the tutorial page learn docker

I was also facing the same issue, I updated my docker file and replaced ENTRYPOINT statement with CMD and sample docker file I used to setup my rails application is mentioned below:
FROM ruby:3.1.1-slim
WORKDIR /usr/src/app
RUN apt-get update && \
apt-get install ruby-full build-essential -y && \
apt-get install libpq-dev -y
COPY . .
RUN gem install bundler:2.3
RUN gem update --system
RUN bundle install
RUN if [ -f tmp/pids/server.pid ]; then rm tmp/pids/server.pid; fi
EXPOSE 3000
CMD ["rails", "server", "-b", "0.0.0.0"]
After that I created this docker compose:
version: '3'
services:
api:
container_name: api
build: .
restart: always
tty: true
volumes:
- ".:/usr/src/app"
ports:
- "3000:3000"
depends_on:
- postgres
postgres:
image: postgres:15-alpine
container_name: postgres
restart: always
volumes:
- "data:/data/db"
environment:
- POSTGRES_PASSWORD=password
volumes:
data:
and after docker compose up
Running:
docker compose run api bin/rails db:create
worked for me.

Related

Installing and Running Postgres

So, I'm running Windows 11 on a Surface Pro 6. Hopefully that gives some background for the issue for any veterans in the constant battle of installing software on Windows.
The core of the issue is that my computer does not understand that PostgreSQL is installed on my machine, b also does, but also refuses to use it.
If you're interested here is the very long stack trace telling you that it doesn't understand postgres is running. This is, by the way, after restarting the server; it does say it is running. I've also ensured that it's an environment variable.
root#DESKTOP-5NH2GGL:/mnt/c/Users/jason/COSI 166/brandeis_class_hub# service postgresql status
12/main (port 5432): online
root#DESKTOP-5NH2GGL:/mnt/c/Users/jason/COSI 166/brandeis_class_hub# rails test
/root/.rbenv/versions/3.1.2/bin/ruby: warning: shebang line ending with \r may cause problems
/root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/postgresql_adapter.rb:87:in `rescue in new_client': FATAL: role "root" does not exist (ActiveRecord::ConnectionNotEstablished)
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/postgresql_adapter.rb:77:in `new_client'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:656:in `public_send'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:656:in `new_connection'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:700:in `checkout_new_connection'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:679:in `try_to_checkout_new_connection'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:640:in `acquire_connection'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:341:in `checkout'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:181:in `connection'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_adapters/abstract/connection_handler.rb:211:in `retrieve_connection'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_handling.rb:313:in `retrieve_connection'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.4/lib/active_record/connection_handling.rb:280:in `connection'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.4/lib/active_record/internal_metadata.rb:17:in `enabled?'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.4/lib/active_record/tasks/database_tasks.rb:399:in `schema_up_to_date?'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.4/lib/active_record/migration.rb:635:in `block in load_schema_if_pending!'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.4/lib/active_record/migration.rb:634:in `all?'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.4/lib/active_record/migration.rb:634:in `load_schema_if_pending!'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.4/lib/active_record/migration.rb:655:in `block in maintain_test_schema!'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.4/lib/active_record/migration.rb:909:in `suppress_messages'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.4/lib/active_record/migration.rb:660:in `method_missing'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/activerecord-7.0.4/lib/active_record/migration.rb:655:in `maintain_test_schema!'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.4/lib/rails/test_help.rb:17:in `<main>'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:35:in `require'
from /mnt/c/Users/jason/COSI 166/brandeis_class_hub/test/test_helper.rb:3:in `<main>'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from /mnt/c/Users/jason/COSI 166/brandeis_class_hub/test/channels/application_cable/connection_test.rb:1:in `<main>'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.4/lib/rails/test_unit/runner.rb:47:in `block in load_tests'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.4/lib/rails/test_unit/runner.rb:47:in `each'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.4/lib/rails/test_unit/runner.rb:47:in `load_tests'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.4/lib/rails/test_unit/runner.rb:40:in `run'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.4/lib/rails/commands/test/test_command.rb:33:in `perform'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.4/lib/rails/command/base.rb:87:in `perform'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.4/lib/rails/command.rb:48:in `invoke'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/railties-7.0.4/lib/rails/commands.rb:18:in `<main>'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from /root/.rbenv/versions/3.1.2/lib/ruby/gems/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
from bin/rails:4:in `<main>'
I have been pitched that maybe I need to make a user profile, but I'm not quite sure how to go about that. If there's something that I'm missing, I'm more than happy to figure it out.
In the code I presented above, I attempted to run rails test. Since it doesn't understand Postgres is on my computer and running, it fails.

Rake db:create fails to connect to server

I am having some troubles creating my database.
My postgresql is running for sure.
Here's the database.yml:
development:
<<: *default
database: name_of_database
User: username
Password: tototo
I get the message:
Called from /usr/local/bundle/gems/activesupport-4.2.5.1/lib/active_support/dependencies.rb:240:in `load_dependency'
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
/usr/local/bundle/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
/usr/local/bundle/gems/activerecord-4.2.5.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
[...]
/usr/local/bundle/bin/rake:17:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"name_of_database", "User"=>"username", "Password"=>"tototo"}
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
[...]
/usr/local/bundle/gems/rake-12.0.0/lib/rake/application.rb:77:in `run'
/usr/local/bundle/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/usr/local/bundle/bin/rake:17:in `load'
/usr/local/bundle/bin/rake:17:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"name_of_database"}
I created the user giving it every rights.
I can connect to postgresql with the client using the IDs.
And I have an other project succeeding to connect to postgres.
Does someone have an idea to fix this?
Thanks.
Your postgres server might not had started try this
$sudo service postgresql restart
Then go to your rails project
$rake db:setup
$rake db:seed
$rake db:migrate

Error deploying Rails 5 app with Sinatra 2.0.0beta2 to Amazon Linux AMI

I'm running into an exception with Sinatra 2.0.0 beta 2 with Rails 5 deploying to the Amazon Linux AMI v 2.1.6. I've posted the issue in the Sinatra Github repro but it's been suggested I post it here.
Edit: I ran into this using Elastic Beanstalk but as #neal reports, this also happens with Capistrano deploying to EC2.
Steps to reproduce the issue follow:
Make a new Rails 5 application in a clean directory
$ gem install rails
$ rails --version
(confirm Rails 5.0.0.1)
$ rails new test-app
Add this line to the gemfile:
gem 'sinatra', '2.0.0.beta2'
Create a new Elastic Beanstalk Web environment of type “64bit Amazon Linux 2016.03 v2.1.6 running Ruby 2.3 (Puma)”, Web server. Use all defaults except change the instance size to t2.small (anything smaller doesn’t have enough memory to deploy)
Add two new environment variables to the Elastic Beanstalk environment using the Web console
SECRET_KEY_BASE = (set a value for this)
RAILS_ENV = production
Deploy the application to this new environment, for example with the eb command line tools.
Deploy it again
Tail the logs through the Elastic Beanstalk console
RESULT:
-------------------------------------
/var/log/puma/puma.log
-------------------------------------
=== puma startup: 2016-08-26 02:39:12 +0000 ===
=== puma startup: 2016-08-26 02:39:12 +0000 ===
[15926] - Worker 0 (pid: 15929) booted, phase: 0
[15926] - Gracefully shutting down workers...
/opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/sinatra-2.0.0.beta2/lib/sinatra/main.rb:11:in `expand_path': No such file or directory - getcwd (Errno::ENOENT)
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/sinatra-2.0.0.beta2/lib/sinatra/main.rb:11:in `block in <class:Application>'
from (eval):1:in `run?'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/sinatra-2.0.0.beta2/lib/sinatra/main.rb:26:in `block in <module:Sinatra>'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/cluster.rb:120:in `fork'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/cluster.rb:120:in `block in spawn_workers'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/cluster.rb:116:in `times'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/cluster.rb:116:in `spawn_workers'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/cluster.rb:426:in `run'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/launcher.rb:172:in `run'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/lib/puma/cli.rb:74:in `run'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/puma-3.6.0/bin/puma:10:in `<top (required)>'
from /opt/rubies/ruby-2.3.1/bin/puma:23:in `load'
from /opt/rubies/ruby-2.3.1/bin/puma:23:in `<top (required)>'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/cli/exec.rb:63:in `load'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/cli/exec.rb:63:in `kernel_load'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/cli/exec.rb:24:in `run'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/cli.rb:304:in `exec'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/cli.rb:11:in `start'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/exe/bundle:27:in `block in <top (required)>'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/lib/bundler/friendly_errors.rb:98:in `with_friendly_errors'
from /opt/rubies/ruby-2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.12.1/exe/bundle:19:in `<top (required)>'
from /opt/rubies/ruby-2.3.1/bin/bundle:23:in `load'
from /opt/rubies/ruby-2.3.1/bin/bundle:23:in `<main>'
[15926] === puma shutdown: 2016-08-26 02:41:17 +0000 ===
[15926] - Goodbye!
=== puma startup: 2016-08-26 02:41:20 +0000 ===
=== puma startup: 2016-08-26 02:41:20 +0000 ===
[16296] - Worker 0 (pid: 16299) booted, phase: 0
This isn't just an elastic bean stalk issue, I can confirm it also happens when deploying a rails 5 app using capistrano / EC2 Ubuntu / nginx

cannot load such file -- sqlite3/sqlite3_native after deploying rails app to a new Debian server

I've started our deployment process to a production server based on Debian Squeeze.
We've been developing this Rails application in a MacOS.
Rails is version 3.2.8
Ruby is version 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.2.0]
We have installed rvm since the beggining and the application works flawlessly in my computer.
In order to understand what would be required and then make a script with Capistrano, I started with:
Installed successfully Ruby.
Installed successfully Rails.
Installed SQLite3. (I won't use it in production)
Installed successfully RVM.
Copied the whole app directory and ran bundle install inside it.
Then, ran rake about just to make sure that everything is ok getting the following error:
rake aborted!
cannot load such file -- sqlite3/sqlite3_native
/root/rails_app/depot/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.6/lib/sqlite3.rb:6:in `require'
/root/rails_app/depot/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.6/lib/sqlite3.rb:6:in `rescue in <top (required)>'
/root/rails_app/depot/vendor/bundle/ruby/1.9.1/gems/sqlite3-1.3.6/lib/sqlite3.rb:2:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/bundler-1.2.2/lib/bundler/runtime.rb:68:in `require'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/bundler-1.2.2/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/bundler-1.2.2/lib/bundler/runtime.rb:66:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/bundler-1.2.2/lib/bundler/runtime.rb:66:in `block in require'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/bundler-1.2.2/lib/bundler/runtime.rb:55:in `each'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/bundler-1.2.2/lib/bundler/runtime.rb:55:in `require'
/usr/local/rvm/gems/ruby-1.9.3-p327#global/gems/bundler-1.2.2/lib/bundler.rb:128:in `require'
/root/rails_app/depot/config/application.rb:7:in `<top (required)>'
/root/rails_app/depot/Rakefile:5:in `require'
/root/rails_app/depot/Rakefile:5:in `<top (required)>'
/root/rails_app/depot/vendor/bundle/ruby/1.9.1/gems/rake- 0.9.2.2/lib/rake/rake_module.rb:25:in `load'
/root/rails_app/depot/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/root/rails_app/depot/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
/root/rails_app/depot/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `block in load_rakefile'
/root/rails_app/depot/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/root/rails_app/depot/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/root/rails_app/depot/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `block in run'
/root/rails_app/depot/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/root/rails_app/depot/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/root/rails_app/depot/vendor/bundle/ruby/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.3-p327/bin/rake:19:in `load'
/usr/local/rvm/gems/ruby-1.9.3-p327/bin/rake:19:in `<main>'
/usr/local/rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `eval'
/usr/local/rvm/gems/ruby-1.9.3-p327/bin/ruby_noexec_wrapper:14:in `<main>'
Every other command like, rails server or rails console shows the same error.

Rails 3.2 + pg gem : load path issue

I have two rails applications, "old" one and new one, created with
$ rails new blog -d postgresql
when i try to start the server, it works on "old" application without problems:
$ rails s -p 2000
=> Booting WEBrick
=> Rails 3.2.8 application starting in development on http://0.0.0.0:2000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-09-17 16:28:48] INFO WEBrick 1.3.1
[2012-09-17 16:28:48] INFO ruby 1.9.3 (2012-04-20) [x86_64-linux]
[2012-09-17 16:28:48] INFO WEBrick::HTTPServer#start: pid=9377 port=2000
but it fails for "new" application :/
$ rails s -p 2000
/usr/local/share/gems/gems/pg-0.14.1/lib/pg.rb:4:in `require': cannot load such file -- pg_ext (LoadError)
from /usr/local/share/gems/gems/pg-0.14.1/lib/pg.rb:4:in `<top (required)>'
from /usr/local/share/gems/gems/bundler-1.1.5/lib/bundler/runtime.rb:68:in `require'
from /usr/local/share/gems/gems/bundler-1.1.5/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /usr/local/share/gems/gems/bundler-1.1.5/lib/bundler/runtime.rb:66:in `each'
from /usr/local/share/gems/gems/bundler-1.1.5/lib/bundler/runtime.rb:66:in `block in require'
from /usr/local/share/gems/gems/bundler-1.1.5/lib/bundler/runtime.rb:55:in `each'
from /usr/local/share/gems/gems/bundler-1.1.5/lib/bundler/runtime.rb:55:in `require'
from /usr/local/share/gems/gems/bundler-1.1.5/lib/bundler.rb:119:in `require'
from /home/alex/tmp/RoR/blog/config/application.rb:7:in `<top (required)>'
from /usr/local/share/gems/gems/railties-3.2.8/lib/rails/commands.rb:53:in `require'
from /usr/local/share/gems/gems/railties-3.2.8/lib/rails/commands.rb:53:in `block in <top (required)>'
from /usr/local/share/gems/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
from /usr/local/share/gems/gems/railties-3.2.8/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
it's possible to fix if i copy or symlink pg_ext.so to module path:
# ln -s /usr/local/share/gems/gems/pg-0.14.1/ext/pg_ext.so /usr/local/share/gems/gems/pg-0.14.1/lib
or i can directly add requirement to boot.rb:
require 'rubygems'
require 'pg'
But it's not acceptable solution and i'm wondering why it works for first application and why it doesn't work for new one ? I've spent all day comparing config files but had no success.
I had the same problem after upgrading to Fedora 18.
pg_ext is built when running gem update.
A pre-requisite for that is that postgresql-devel is installed.