I have a simple MySQL table:
% mysql -u rampion dev -e 'describe person'
+-------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | UNI | NULL | auto_increment |
| uid | varchar(256) | NO | PRI | NULL | |
+-------+--------------+------+-----+---------+----------------+
And a simple DataMapper script I want to run:
# temp.rb
require 'rubygems'
require 'datamapper'
DataMapper::Logger.new($stdout, :debug)
DataMapper.setup(:default, "mysql://rampion@localhost/dev")
class Person
include DataMapper::Resource
property :id, Serial
property :uid, String
end
DataMapper.finalize
p Person.first_or_create(:uid => 'Steve')
But when I run it, I get dynamic linker errors:
% ruby temp.rb
~/.rvm/gems/ruby-1.8.7-p334/gems/dm-validations-1.0.2/lib/dm-validations.rb:33: warning: already initialized constant OrderedHash
DataObjects::URI.new with arguments is deprecated, use a Hash of URI components (~/.rvm/gems/ruby-1.8.7-p334/gems/dm-do-adapter-1.0.2/lib/dm-do-adapter/adapter.rb:215:in `new')
dyld: lazy symbol binding failed: Symbol not found: _mysql_init
Referenced from: ~/.rvm/gems/ruby-1.8.7-p334/gems/do_mysql-0.10.12/lib/do_mysql/do_mysql.bundle
Expected in: flat namespace
dyld: Symbol not found: _mysql_init
Referenced from: ~/.rvm/gems/ruby-1.8.7-p334/gems/do_mysql-0.10.12/lib/do_mysql/do_mysql.bundle
Expected in: flat namespace
zsh: trace trap ruby temp.rb
I have LD_LIBRARY_PATH
set to /usr/local/mysql/lib
, which is where I have MySQL installed, and it seems to have _mysql_init
defined in there:
% grep '_mysql_init' $LD_LIBRARY_PATH/libmysqlclient.18.dylib
Binary file /usr/local/mysql/lib/libmysqlclient.18.dylib matches
I have no idea what I need to do to fix this.
sudo aptitude reinstall libmysqlclient-dev; gem install mysql2
. – Belfordbundle install
will get you back to where you want to be. Ideally you can bump from Ruby 1.8.7 as well. – Sapotagem pristine --all
should rebuild the gems to match the current environment. You might want to rungem up
to refresh the gem code to the last version that'd run on 1.8.7 to pull in fixes. I'd strongly recommend upgrading from 1.8.7 to at least 1.9.3-p551, which is the current/last of the 1.9 line. You'll gain speed and security patches/fixes. See rvm.io/rvm/upgrading about upgrading RVM to its latest rev; Keeping it up to date is a really good idea even if you're going to let Ruby lag. – Zakaria