라이브러리가로드되지 않음 : mysql2 gem으로 OS X 10.6에서 'rails server'를 실행하려고 할 때 libmysqlclient.16.dylib 오류
나는 한동안 이것으로 어려움을 겪고있다.
Snow Leopard 시스템에 Rails 3, gem, mysql을 설치했습니다. 첫 번째 프로젝트를 만들고 실행하려고 할 때까지 모든 것이 잘 진행되었습니다.
rails server
이것을 실행하면 다음을 얻습니다.
jontybrook$ rails server
/Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.16.dylib (LoadError)
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
from /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2.rb:7
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:64:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:64:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:62:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:62:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:51:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:51:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.7/lib/bundler.rb:112:in `require'
from /Users/jontybrook/Dropbox/CODING/simple_cms/config/application.rb:7
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/commands.rb:28:in `require'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/commands.rb:28
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/commands.rb:27:in `tap'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.3/lib/rails/commands.rb:27
from script/rails:6:in `require'
from script/rails:6
jontybrook$
내가 알 수있는 한 mysql2 gem에 문제가 있습니다. MySQL이 정상적으로 실행되는 것 같고 Gemfile이 mysql2를 참조하면 database.yml 파일도 정상적으로 보입니다.
오류 언급
Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
그리고 아직
jontybrook$ cd /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2
jontybrook$ ls
client.rb em.rb error.rb mysql2.bundle result.rb
MySQL2. 번들이 있습니까!?
오래된 mysql gem을 사용하면 WEBrick이 정상적으로 부팅됩니다. 그러나 이상적이지 않습니까?
나는 구글이 줄 수있는 모든 것을 시도했다! 도움을 주시면 감사하겠습니다.
나는이 답변 중 어느 것도 나를 위해 일할 수 없었지만, 이것이 나를 위해 일하는 데 사용한 명령입니다. 이렇게하면 mysql을 업데이트 할 때마다 install_name_tool을 사용할 필요가 없습니다.
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
나는 이것을 결국 해결했다!
RVM 아래에 Ruby and Rails를 다시 설치했습니다. Ruby 버전 1.9.2-p136을 사용하고 있습니다.
rvm에서 다시 설치 한 후에도이 오류가 계속 발생했습니다.
결국 그것을 해결 한 마술 명령은 다음과 같습니다.
sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib ~/.rvm/gems/ruby-1.9.2-p136/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
이것이 다른 누군가를 돕기를 바랍니다!
이 수정 프로그램은 저에게 매우 효과적이었습니다.
~ / .profile에 다음을 추가하십시오.
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
http://www.rickwargo.com/2010/12/16/installing-mysql-5-5-on-os-x-10-6-snow-leopard-and-rails-3/
나를 위해 이것은 단지 mysql을 업그레이드했지만 mysql2 gem을 업데이트하지 않았기 때문입니다-gem을 다시 설치하면 문제가 해결됩니다 ...
gem pristine mysql2
I have the same issue. It looks like it's unable to find the libmysqlclient library. A temporary fix that has worked for me is the following:
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/
I am not sure where the config is specifying the load path or what it's set to but my mysql install did not appear to be in it. I'll post again if I find a more permanent solution.
Edit: Actually this fix appears to more accurately address the problem.
Add the below to your ~/.bash_profile
:
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
This worked for me
In OSX El Capitan update when you do this:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
it throws an error like
ln: /usr/lib/libmysqlclient.18.dylib: Operation not permitted
So to avoid this, what you can do is first locate libmysqlclient.18.dylib
using the command
User$ locate libmysqlclient.18.dylib
In my case it returned /usr/local/mysql-5.5.24-osx10.5-x86_64/lib/libmysqlclient.18.dylib
So instead of usr/lib/
we will create symlink to usr/local/lib/
like this :
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/local/lib/libmysqlclient.18.dylib
More details : https://forums.developer.apple.com/thread/7935
following lines works for me. I am using mac 10.7.2 .
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
Just ran into this problem. All I had to do is uninstall mysql2 gem and reinstall it. Hope this works for other people
This is how it worked for me:
I ran the below command
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib ~/.rvm/gems/ruby-1.9.2-p180/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle
My environments:
$ rails -v Rails 3.0.6
$ mysql --version
mysql Ver 14.14 Distrib 5.5.11, for osx10.6 (i386) using readline 5.1
$ ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]
Hope this helps someone.
Thanks, Ogapo! Exporting that alias worked for me, and then I followed the link, and in my case the mysql2.bundle was up in /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle so I adjusted the install_name_tool to modify that bundle rather than one in ~/.rvm and got that working the way it should be done.
So now:
$ otool -L /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
/Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle:
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/libruby.1.dylib (compatibility version 1.8.0, current version 1.8.7)
/usr/local/mysql/lib/libmysqlclient.16.dylib (compatibility version 16.0.0, current version 16.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.1)
hi it worked for me from the recommended link from Fredy Andersen
sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql /lib/libmysqlclient.16.dylib /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
just had to change to my version of mysql, in the command, thanks
I solved this problem by deleting my gemset for my current project and recreating it and rerunning bundle install. I think I caused it by installing a newer version of mysql.
I had this issue when working with Django, I use brew
to install a lot of my Open Source programs and I needed to do the following since I used brew
to install mysql
:
sudo ln -s /usr/local/Cellar/mysql/5.5.20/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
Be sure to replace with your version of the libraries!
bundle install mysql --force
helped me. It reinstalled dependencies which ware gone as a result of brew uninstall mysql
.
Jonty, I'm struggling with this too.
I think there's a clue in here:
otool -L /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
/Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle:
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/libruby.1.dylib (compatibility version 1.8.0, current version 1.8.7)
libmysqlclient.16.dylib (compatibility version 16.0.0, current version 16.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.1)
Notice the path to the dylib is, uh, rather short?
I'm trying to figure out where the gem install instructions are leaving off the dylib path, but it's slow going as I have never built a gem myself.
I'll post more if I find more!
I've had this exact same problem a few days ago. I eventually managed to solve it. I'm not quite sure how, but I'll tell you what I did anyway. Maybe it'll help you.
I started by downloading RVM. If you aren't using it yet, I highly recommend doing so. It basically creates a sandbox for a new separate installation of Ruby, RoR and RubyGems. In fact, you can have multiple installations simultaneously and instantly switch to one other. It works like a charm.
Why is this useful? Because you shouldn't mess with the default Ruby installation in OS X. The system depends on it. It's best to just leave the default Ruby and RoR installation alone and create a new one using RVM that you can use for your own development.
Once I created my separate Ruby installation, I just installed RoR, RubyGems and mysql, and it worked. For the exact steps I took, see my question: Installing Rails, MySQL, etc. everything goes wrong
Again: I don't know for certain this will solve your problem. But it certainly did the trick for me, and in any case using RVM is highly recommendable.
I still found that with the solutions above, it didn't work (for example) with the Rails plugin for TextMate. I got a similar error (when retrieving the database schema).
So what did is, open terminal:
cd /usr/local/lib
sudo ln -s ../mysql-5.5.8-osx10.6-x86_64/lib/libmysqlclient.16.dylib .
Replace mysql-5.5.8-osx10.6-x86_64 with your own path (or mysql).
This makes a symbol link to the lib, now rails runs from the command line, as-well as TextMate plugin(s) like ruby-on-rails-tmbundle.
To be clear: this also fixes the error you get when starting rails server.
This usually happen when you upgrade mysql. The installed mysql2 gem which was built on the old mysql libs cannot work with new libs. Just need to reinstall it.
Uninstall mysql2 with gem uninstall mysql2
. Then install it with gem install mysql2
I've resolved it by creating .rvmrc file in my project folder containg:
rvm use <yourrubie>
then entering my project path
cd ~/myprojectpath
then I run
bundle install
My version of luvlss's command:
Mac OSX 10.10.5
MySQL 5.6.27
Passenger 5.0.21
sudo ln -s /usr/local/mysql-5.6.27-osx10.8-x86_64/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
If you're trying lots of different links, like I did, do some clean-up with:
sudo unlink /usr/lib/libmysqlclient.18.dylib
If you're using OSX and installed mysql using brew, you can:
brew link mysql
If you're having trouble with the version (I had mysql 5.7 running while my gem required 5.6.25), you can
brew unlink mysql
brew switch mysql 5.6.25
Open a Terminal and run the following:
export PATH=$PATH:/usr/local/mysql/bin
It should work.
For me I had to manually uninstall mysql
brew uninstall mysql
rm -rf /usr/local/var/mysql
brew install mysql
'IT story' 카테고리의 다른 글
Python 멀티 프로세싱 PicklingError : 피클 할 수 없습니다 (0) | 2020.05.06 |
---|---|
HTML 속성의 길이에 제한이 있습니까? (0) | 2020.05.06 |
일부 개발자에게는 왜 좋은 UI 디자인이 그렇게 어려운가요? (0) | 2020.05.05 |
ld : 프레임 워크를 찾을 수 없음 (0) | 2020.05.05 |
파일을 특정 개정으로 재설정하거나 되돌리려면 어떻게해야합니까? (0) | 2020.05.05 |