HELP! Please! I'm pulling my hair out! Ok, I'm just trying to get jruby to work with postgresql. With postgresql server running, and webrick running, I create a project, with: rails new myproj I edit the file database.yml to be: development: adapter: jdbcpostgresql database: db/development.pg username: postgres password: XXXXXXXX host: localhost (replacing XXXXXXXX for my real password, same for test & prod). Then in a terminal window, in my project directory, I type: $ sudo jruby -S rake db:create Error message I get back is: rake aborted! Please install the jdbcpostgresql adapter: `gem install activerecord-jdbcpostgresql-adapter` (no such file to load -- active_record/connection_adapters/jdbcpostgresql_adapter) But, I've already installed it with: $ sudo jruby -S gem install jdbc-postgres activerecord-jdbcpostgresql-adapter Successfully installed jdbc-postgres-9.1.901 Successfully installed activerecord-jdbcpostgresql-adapter-1.2.2 2 gems installed I stop webrick, do the install above, restart webrick, rake gives same error. => Booting WEBrick => Rails 3.2.3 application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server [2012-05-05 20:02:58] INFO WEBrick 1.3.1 [2012-05-05 20:02:58] INFO ruby 1.8.7 (2012-02-22) [java] [2012-05-05 20:03:03] INFO WEBrick::HTTPServer#start: pid=2089 port=3000 $ jruby -S rake db:create --trace output is attached to this post. I know postgresql is running because: $ sudo /etc/init.d/postgresql stop * Stopping PostgreSQL 9.1 database server I can then start it back up with: $ sudo /etc/init.d/postgresql start * Starting PostgreSQL 9.1 database server I've also ensured that I uncomment the following line in /etc/postgresql/9.1/main/postgresql.conf: listen_addresses = 'localhost' After renaming the default rails index.html in the public folder, creating a controller, and setting up index.html.erb in the views directory localhost:3000 in firefox gives me the test page correctly. So I know this part works. here's some extra info. I'm on Ubuntu 12.04, Gnome 3.4, Which ruby gives: /usr/bin/ruby ruby -v gives: ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux] jruby -v gives: jruby 1.6.7 (ruby-1.8.7-p357) (2012-02-22 3e82bc8) (OpenJDK 64-Bit Server VM 1.6.0_24) [linux-amd64-java] java -version gives: java version "1.6.0_24" OpenJDK Runtime Environment (IcedTea6 1.11.1) (6b24-1.11.1-4ubuntu2) OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode) irb is working, gives: irb(main):001:0> puts ((11.to_s * 2).to_i/2) 555 => nil irb(main):002:0> But why is rake not working with postgresql?
on 2012-05-06 20:40
on 2012-05-06 21:34
On Sun, 2012-05-06 at 20:40 +0200, Charlie Sager wrote: > HELP! Please! I'm pulling my hair out! How are you starting webrick - are you using Sudo as well - I think you might be using sudo/root for part of your commands and your regular account for the others - webrick and that is causing you grief > password: XXXXXXXX > active_record/connection_adapters/jdbcpostgresql_adapter) > I stop webrick, do the install above, restart webrick, rake gives same > > > here's some extra info. I'm on Ubuntu 12.04, Gnome 3.4, > java -version gives: > But why is rake not working with postgresql? > > Attachments: > http://www.ruby-forum.com/attachment/7367/trace-fo... > > -- Bob Lehman Email: blehman12@comcast.net Mobile: (503)888-1471
on 2012-05-06 21:38
On Sun, May 6, 2012 at 11:40 AM, Charlie Sager <lists@ruby-forum.com> wrote: > Ok, I'm just trying to get jruby to work with postgresql. > rails new myproj Why not e.g. `jruby -S rails new myproj -d postgresql` ? That would create an appropriate database.yml file, eliminating the two errors I see in the example below :-) as well as making sure you're using the intended jruby executable. > adapter: jdbcpostgresql > database: db/development.pg Once you've created the project, `jruby -S bundle install` should take care of the requirements (particularly if you're using rvm - recommended). HTH, -- Hassan Schroeder ------------------------ hassan.schroeder@gmail.com http://about.me/hassanschroeder twitter: @hassan
on 2012-05-07 02:54
Thank you so much Hassan! I used your suggestion of:
jruby -S rails new myproj -d postgresql
My database.yml file still needed a little tweaking as I was getting a
new error msg:
Couldn't create database for {"adapter"=>"postgresql",
"encoding"=>"unicode", "database"=>"myproj_development",
"username"=>"postgres", "password"=>"XXXXXXXX"}
It wasn't until I setup a new user in postgresql that rake was
successful:
su - postgres
createuser myproj -P -d -R -e
Enter password for new role:
Enter it again:
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) n
my database.yml file then became:
development:
adapter: postgresql
encoding: unicode
database: myproj_development
username: myproj
password: XXXXXXXX
(same for test & prod)
jruby -S rake db:create
just comes back to the prompt with no errors now.
When I
su - postgres
psql
\l
I see both databases that rake created, myproj_development, and
myproj_test. I deleted these and tried rake again - it works!
Thanks for your help! I can continue on my journey.
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.