ActiveRecord (not Rails!)

I'm learning to use activerecord (not rails).

Two gems are necessary for this: the activerecord gem and the mysql adpater (I'm using MySQL). I installed both gems (I think successfully).

When I inspect the directory where all my local gems are installed, I get this:

~/.rvm/gems/ruby-1.9.2-p290/gems marcc$ ls total 0 drwxr-xr-x 28 marcc staff 952B Aug 15 19:47 . drwxr-xr-x 7 marcc staff 238B Jul 25 11:58 .. drwxr-xr-x 8 marcc staff 272B Jul 25 12:07 abstract-1.0.0 drwxr-xr-x 6 marcc staff 204B Jul 25 12:07 actionmailer-3.0.9 drwxr-xr-x 6 marcc staff 204B Jul 25 12:07 actionpack-3.0.9 drwxr-xr-x 6 marcc staff 204B Jul 25 12:07 activemodel-3.0.9 drwxr-xr-x 6 marcc staff 204B Jul 25 12:07 activerecord-3.0.9 drwxr-xr-x 6 marcc staff 204B Jul 25 12:07 activeresource-3.0.9 drwxr-xr-x 5 marcc staff 170B Jul 25 12:07 activesupport-3.0.9 drwxr-xr-x 12 marcc staff 408B Jul 25 12:07 arel-2.0.10 drwxr-xr-x 9 marcc staff 306B Jul 25 12:07 builder-2.1.2 drwxr-xr-x 14 marcc staff 476B Jul 25 12:08 bundler-1.0.15 drwxr-xr-x 14 marcc staff 476B Jul 25 12:07 erubis-2.6.6 drwxr-xr-x 8 marcc staff 272B Jul 25 12:07 i18n-0.5.0 drwxr-xr-x 7 marcc staff 238B Jul 25 12:07 mail-2.2.19 drwxr-xr-x 12 marcc staff 408B Jul 25 12:07 mime-types-1.16 drwxr-xr-x 13 marcc staff 442B Aug 15 19:47 mysql-2.8.1 drwxr-xr-x 9 marcc staff 306B Jul 25 12:07 polyglot-0.3.1 drwxr-xr-x 13 marcc staff 442B Jul 25 12:07 rack-1.2.3 drwxr-xr-x 5 marcc staff 170B Jul 25 12:07 rack-mount-0.6.14 drwxr-xr-x 14 marcc staff 476B Jul 25 12:07 rack-test-0.5.7 drwxr-xr-x 3 marcc staff 102B Jul 25 12:08 rails-3.0.9 drwxr-xr-x 6 marcc staff 204B Jul 25 12:08 railties-3.0.9 drwxr-xr-x 12 marcc staff 408B Jul 25 11:58 rake-0.8.7 drwxr-xr-x 14 marcc staff 476B Jul 25 12:08 rdoc-3.8 drwxr-xr-x 9 marcc staff 306B Jul 25 12:07 thor-0.14.6 drwxr-xr-x 11 marcc staff 374B Jul 25 12:07 treetop-1.4.9 drwxr-xr-x 8 marcc staff 272B Jul 25 12:07 tzinfo-0.3.29

When I run the gem list command, I get this:

~ marcc$ gem list

*** LOCAL GEMS ***

abstract (1.0.0) actionmailer (3.0.9) actionpack (3.0.9) activemodel (3.0.9) activerecord (3.0.9) activeresource (3.0.9) activesupport (3.0.9) arel (2.0.10) builder (2.1.2) bundler (1.0.15) erubis (2.6.6) i18n (0.5.0) mail (2.2.19) mime-types (1.16) polyglot (0.3.1) rack (1.2.3) rack-mount (0.6.14) rack-test (0.5.7) rails (3.0.9) railties (3.0.9) rake (0.8.7) rdoc (3.8) thor (0.14.6) treetop (1.4.9) tzinfo (0.3.29)

As you can see, the mysql-2.8.1 gem directory is there but the mysql gem is not listed when I do gem list.

Why is that?

Post the output of:

$ gem environment

7stud -- wrote in post #1017100:

Post the output of:

$ gem environment

Here goes: ~ marcc$ gem environment RubyGems Environment:   - RUBYGEMS VERSION: 1.6.2   - RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [x86_64-darwin11.0.0]   - INSTALLATION DIRECTORY: /Users/marcc/.rvm/gems/ruby-1.9.2-p290   - RUBY EXECUTABLE: /Users/marcc/.rvm/rubies/ruby-1.9.2-p290/bin/ruby   - EXECUTABLE DIRECTORY: /Users/marcc/.rvm/gems/ruby-1.9.2-p290/bin   - RUBYGEMS PLATFORMS:     - ruby     - x86_64-darwin-11   - GEM PATHS:      - /Users/marcc/.rvm/gems/ruby-1.9.2-p290      - /Users/marcc/.rvm/gems/ruby-1.9.2-p290@global   - GEM CONFIGURATION:      - :update_sources => true      - :verbose => true      - :benchmark => false      - :backtrace => false      - :bulk_threshold => 1000   - REMOTE SOURCES:      - http://rubygems.org/

Also, if that can help, I get the following info from error logs:

~/.rvm/gems/ruby-1.9.2-p290/gems/mysql-2.8.1/ext/mysql_api marcc$ ls total 248 drwxr-xr-x 6 marcc staff 204B Aug 15 19:47 . drwxr-xr-x 3 marcc staff 102B Aug 15 19:47 .. -rw-r--r-- 1 marcc staff 2.5K Aug 15 19:47 extconf.rb -rw-r--r-- 1 marcc staff 1.7K Aug 15 19:47 gem_make.out -rw-r--r-- 1 marcc staff 45K Aug 15 19:47 mkmf.log -rw-r--r-- 1 marcc staff 67K Aug 15 19:47 mysql.c ~/.rvm/gems/ruby-1.9.2-p290/gems/mysql-2.8.1/ext/mysql_api marcc$ cat mkmf.log find_library: checking for mysql_query() in -lmysqlclient... -------------------- no

"/usr/bin/gcc-4.2 -o conftest -I/Users/marcc/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/x86_64-darwin11.0.0 -I/Users/marcc/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/Users/marcc/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -I. -I/usr/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long -fno-common -pipe conftest.c -L. -L/Users/marcc/.rvm/rubies/ruby-1.9.2-p290/lib -L/usr/local/lib -L. -lruby.1.9.1-static -lpthread -ldl -lobjc " ld: warning: directory not found for option '-L/usr/local/lib' checked program was: /* begin */ 1: #include "ruby.h" 2: 3: int main() {return 0;} /* end */

"/usr/bin/gcc-4.2 -o conftest -I/Users/marcc/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/x86_64-darwin11.0.0 -I/Users/marcc/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/Users/marcc/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -I. -I/usr/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long -fno-common -pipe conftest.c -L. -L/Users/marcc/.rvm/rubies/ruby-1.9.2-p290/lib -L/usr/local/lib -L. -lruby.1.9.1-static -lmysqlclient -lpthread -ldl -lobjc " conftest.c: In function ‘t’: conftest.c:5: error: ‘mysql_query’ undeclared (first use in this function) conftest.c:5: error: (Each undeclared identifier is reported only once conftest.c:5: error: for each function it appears in.) checked program was: /* begin */ 1: #include "ruby.h" 2: 3: /*top*/ 4: int main() {return 0;} 5: int t() { void ((*volatile p)()); p = (void ((*)()))mysql_query; return 0; } /* end */

"/usr/bin/gcc-4.2 -o conftest -I/Users/marcc/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/x86_64-darwin11.0.0 -I/Users/marcc/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/Users/marcc/.rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -I. -I/usr/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long -fno-common -pipe conftest.c -L. -L/Users/marcc/.rvm/rubies/ruby-1.9.2-p290/lib -L/usr/local/lib -L. -lruby.1.9.1-static -lmysqlclient -lpthread -ldl -lobjc " ld: warning: directory not found for option '-L/usr/local/lib' ld: library not found for -lmysqlclient collect2: ld returned 1 exit status checked program was: /* begin */ 1: #include "ruby.h" 2: 3: /*top*/ 4: int main() {return 0;} 5: int t() { mysql_query(); return 0; } /* end */

... and much more ....

Do you have mysql installed? mysql and the ruby mysql adapter are different things.

Also, if you post your question plus the 'gem environment' output in the Ruby forum, they will be able to pinpoint what is going on very quickly.

7stud -- wrote in post #1017182:

Do you have mysql installed? mysql and the ruby mysql adapter are different things.

Yes of course! And I have a database ready to be used with an activerecord application.

7stud -- wrote in post #1017183:

Also, if you post your question plus the 'gem environment' output in the Ruby forum, they will be able to pinpoint what is going on very quickly. Your question is really a rubygems question, so posting it in the main Ruby forum is more appropriate.

I posted there without any success, which is why I tried this topic list.

Do you have installed the libmysqlclient?

If not, install the libmysqlclient and reinstall the mysql gem.

What would you call "success"? I responded to your ruby-list posting but didn't see any response to my suggestions :slight_smile: