问题
Just upgraded to RC1 of RM 3.2 on MacOS Lion and couldn't run the application anymore. Running with rvm. On startup the mysql2 gem reported it couldn't find libmysqlclient.18.dylib on a dlopen.
Solved it. Posting the solution here so it will help somebody save some time.
Using Apple's Property List Editor create an entry in ~/.MacOS/environment.plist call LD_LIBRARY_PATH and set the value to /usr/local/mysql/lib or whereever your MySQL libraries live.
Logout and log back in and RubyMine and the mysql2 gem are happy again.
回答1:
I got around this by adding this to the environment variables section of the RubyMine server instance.
1) Open Run/Debug Configurations for your server
2) Click on the "..." next to "Environment Variables"
3) Add "DYLD_LIBRARY_PATH" as the key and "/usr/local/mysql/lib/" as value (path from using .dmg MySQL install)
回答2:
There have been several solutions suggested, but I think the best solution is the last one I suggest:
1) Editing Environment Variables in the Run/Debug Configuration
This works but you have to keep doing for every single configuration, which is a pain. It also doesn't fix the problem if you are running outside of RubyMine.
2) Editing the .MacOS/environment.plist
This seems to not be supported anymore in later versions of OS X.
3) Setting the DYLD_LIBRARY_PATH environment variable in the .profile/.bashrc
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/mysql/lib/
This fixed the problem on the console, but RubyMine doesn't seem to load the environment from .profile/.bashrc.
4) Symlink the libmysqlclient.18.dylib into /usr/local/lib
This is what Homebrew typically does, which is to create a symlink for the dylib that cannot be loaded.
ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
You only need to do this once and you're done.. and it works globally, in the console and in RubyMine.
回答3:
Using Apple's Property List Editor create an entry in ~/.MacOS/environment.plist call LD_LIBRARY_PATH and set the value to /usr/local/mysql/lib or whereever your MySQL libraries live.
Logout and log back in and RubyMine and the mysql2 gem are happy again.
@Aaron Chambers, couldn't add as an answer at that time. Thanks.
来源:https://stackoverflow.com/questions/6596303/rubymine-3-2-failing-to-find-libmysqlclient-18-dylib-on-macos-lion