Forums General

PostgreSQL with RubyStack: Postgres Gem Problem

Subscribe to PostgreSQL with RubyStack: Postgres Gem Problem 9 post(s), 2 voice(s)

 
Avatar ehsanul 6 post(s)

I started the Rubyconsole and tried the following commands:

bash-3.2$ cd /home/ehsanul/newapp
bash-3.2$ rake—trace db:create

Part of the result and trace:

(in /home/ehsanul/newapp)
  • Invoke db:create (first_time)
  • Invoke environment (first_time)
  • Execute environment
  • Execute db:create
    rake aborted!
    no such file to load—postgres
    /home/ehsanul/rubystack/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’
    /home/ehsanul/rubystack/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require’

I know my adapter in database.yml is set correctly to “postgresql”. And I knew I had the postgres gem installed, which I checked by doing gem list from the linux terminal (outside of rubyconsole), which showed me this:

ehsanul@ehsanul-laptop:~$ gem list

  • LOCAL GEMS *

actionmailer (2.1.1, 2.0.2)
actionpack (2.1.1, 2.0.2)
activerecord (2.1.1, 2.0.2)
activeresource (2.1.1, 2.0.2)
activesupport (2.1.1, 2.0.2)
postgres (0.7.9.2008.01.28)
rails (2.1.1, 2.0.2)
rake (0.8.3)

Postgres is obviously there. So then I tried the same command in the rubyconsole:

bash-3.2$ gem list

  • LOCAL GEMS *

actionmailer (2.0.2)
actionpack (2.0.2)
activerecord (2.0.2)
activeresource (2.0.2)
activesupport (2.0.2)
capistrano (2.1.0)
cgi_multipart_eof_fix (2.5.0)
daemons (1.0.9)
fastthread (1.0.1)
gem_plugin (0.2.3)
gruff (0.2.9)
highline (1.4.0)
hoe (1.3.0)
mongrel (1.1.3)
mongrel_cluster (1.0.5)
mysql (2.7)
needle (1.3.0)
net-sftp (1.1.0)
net-ssh (1.1.2)
rails (2.0.2)
rake (0.8.1)
RedCloth (3.0.4)
rmagick (2.2.0)
rubyforge (0.4.4)

Now the problem is clear, the gem really isn’t accessible by rubyconsole for some reason. But how do I add the postgres gem in such a way that it is recognized within rubyconsole? I tried installing from rubyconsole, it made no difference.

 
Avatar beltran Administrator 370 post(s)

Hi ehsanul,

BitNami RubyStack is independent of your system. When you tiped gem list in your terminal (outside of rubyconsole) you are seeing the system installed gems and you have installed postgres gem. It is necessary to install the postgres gem into the rubyconsole. Probably this gem needs to specify the folders where is postgresql installed. You can find more info about how to install this gem at http://wiki.rubyonrails.org/rails/pages/PostgreSQL

I hope it helps

 
Avatar ehsanul 6 post(s)

Thanks for replying beltran
You said, “It is necessary to install the postgres gem into the rubyconsole.”

Well, I realized that when I tried gem list from the two different consoles. My question is, how do I install it into the rubyconsole? I’m new to rails, and obviously to the rubyconsole as well, so I have no idea.

Thanks for the link, but I saw that page a few days ago, and it did help me with some earlier problems. But not this one. I’ve tried specifying the postgresql folders to install the gem there by running a command like:

$ gem install postgres -—with-pgsql-include-dir=/opt/PostgreSQL/8.3/include - with-pgsql-lib-dir=/opt/PostgreSQL/8.3/lib

Or even:

$ gem install postgres——with-pgsql-include-dir=/usr/include—with-pgsql-lib-dir=/usr/lib

But this didn’t help. Rubyconsole is unable to find the gem.

 
Avatar ehsanul 6 post(s)

Sorry, those commands should be:

$ gem install postgres—with-pgsql-include-dir=/opt/PostgreSQL/8.3/include – -with-pgsql-lib-dir=/opt/PostgreSQL/8.3/lib

Or even:

$ gem install postgres—with-pgsql-include-dir=/usr/include—with-pgsql-lib-dir=/usr/lib

 
Avatar beltran Administrator 370 post(s)

Hi ehsaul,

The rubyconsole it is similar to you console, only that this console preload the Stack environment variables. For example, if you execute “which ruby” in a simple terminal you can realize that you are using the ruby system command and if you execute:

$ cd <rubystack_installation_directory>
$ ./rubyconsole -> This command start the rubyconsole
$ which ruby

You can see that you are using the ruby Stack command. It occurs the same with “gem” or another command. So if you want to install the postgres gem in your RubyStack you only should execute these commands:

$ cd <rubystack_installation_directory>
$ ./rubyconsole
$ gem install postgres

Maybe it is necessary to include other options as you said in the previous post. The “gem install” command try to download from a gem repository the gem, why did you say that “Rubyconsole is unable to find the gem”? What is the exact error?

Cheers

 
Avatar ehsanul 6 post(s)

Nevermind, I did a lot of different things and finally figured it out, plus a few more problems. But finally, Rubystack is working with PostgreSQL (as far as I can tell for now), and I’m happy. :)

Thanks anyway.

 
Avatar beltran Administrator 370 post(s)

I’m glad to hear this :)

 
Avatar ehsanul 6 post(s)

Thanks for that explanation beltran, had not seen it before posting the last time. Yes, I knew how to get into the rubyconsole and I did gem install postgres from there. And it would tell me that it had installed. But it wasn’t there, and it wasn’t working. I tried the command gem environment, and it showed me the default installation directory of the installation was correct. But when I check in that directory, all the other gems besides postgres was there, but no postgres.

So I did a file search for “postgres-0.7.9.2008” which was part of the filename of the postgres gem. I found out that it had been installed, but in a subtly different directory. The default directory for installation is ”/home/ehsanul/rubystack/ruby/lib/ruby/gems/1.8”, but I found the postgres gem installed in ”/home/ehsanul/rubystack/ruby/lib/ruby/1.8/gems” (this is veryyy slightly different, hard to catch), all by itself, with no other gems there. I have no idea why rubyconsole installed it there when the gem environment command clearly shows the correct default installation directory. So outside the rubyconsole, I ran the following command:

$ sudo gem install postgress—install-dir /home/ehsanul/rubystack/ruby/lib/ruby/gems/1.8

This solved my problem. Hopefully, this may help someone else having the same problem.

 
Avatar ehsanul 6 post(s)

The error was “no such file to load – postgres” .. it could not find the postgres gem

Forums General