SQLite Gem Error Using RVM On Lion
On a clean install of Lion with RVM you may get the error "dyld: lazy symbol binding failed: Symbol not found: _STR2CSTR" from the server. Here is how to fix it.
On my new iMac with a fresh install of Lion, I installed RVM and updated Rails but when I tried launching an app I was greeted by the error:
dyld: lazy symbol binding failed: Symbol not found: _STR2CSTR
I came across the Stack Overflow thread about it but here is an all-in-one fix.
1. Make Copies
Note: On my machine RVM installed itself into /usr/local/rvm (not using sudo either) instead of ~/.rvm
You will want to backup two files from your RVM's sqlite3 gem folder:
[.]rvm/gems/ruby-1.9.2-p290/gems/sqlite3-ruby-1.2.4/lib/sqlite3_api.bundle and [.]rvm/gems/ruby-1.9.2-p290/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/sqlite_api_wrap.c
cp [.]rvm/gems/ruby-1.9.2-p290/gems/sqlite3-ruby-1.2.4/lib/sqlite3_api.bundle [.]rvm/gems/ruby-1.9.2-p290/gems/sqlite3-ruby-1.2.4/lib/sqlite3_api.bundle.bak
cp [.]rvm/gems/ruby-1.9.2-p290/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/sqlite_api_wrap.c [.]rvm/gems/ruby-1.9.2-p290/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/sqlite_api_wrap.c.bak
2. Fix The Source Files
Then you want to replace STR2CSTR with StringValuePtr in one of the source files.
#run this inside the rvm/gems/ruby-1.9.2-p290/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/ folder
perl -p -i.b -e 's/STR2CSTR/StringValuePtr/g' *.c
make
3. Replace Old Bundle File
Replace the compiled sqlite3_api.bundle file with the old one:
# run this inside folder mentioned in 2
mv sqlite3_api.bundle ../../lib`
Now you should be able to restart the rails server and not see the error message anymore.
