开发者

Got "undefined method `split'" when installing gem dm-mysql-adapter

I'm trying to install the gem dm-mysql-adapter with the following command:

gem install dm-mysql-adapter -- --with-mysql-config=/usr/bin/mysql
--with-mysql-lib=/usr/lib/mysql

and got this result:

Building native extensions.  This could take a while...
ERROR:  Error installing dm-mysql-adapter:
  ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb --with-mysql-config=/usr/bin/mysql
--with-mysql-lib=/usr/lib/mysql
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
  --with-opt-dir
  --without-opt-dir
  --with-opt-include
  --without-opt-include=${opt-dir}/include
  --with-opt-lib
  --without-opt-lib=${opt-dir}/lib
  --with-make-prog
  --without-make-prog
  --srcdir=.
  --curdir
  --ruby=/usr/local/bin/ruby
  --with-mysql-config
extconf.rb:43:in `': undefined method `split' for nil:NilClass
(NoMethodError)


Gem files will remain installed in
/usr/local/lib/ruby/gems/1.9.1/gems/do_mysql-0.10.2 for inspection.
Results logged to
/usr/local/lib/ruby/gems/1.9.1/gems/do_mysql-0.10.2/ext/do_mysql/gem_make.out

Has anyone experience the sam开发者_如何学运维e problem? What should I do to fix this? Thanks!


I had this exact same problem. I'm on OS X 10.6 with the latest MySQL 5.1 package from dev.mysql.com.

Anyway, it turns out the fix was really simple, I just needed to add the mysql bin directory to my path:

$ export PATH=$PATH:/usr/local/mysql/bin

Then, from the same command prompt (because the path only gets changed for that session), I installed the gem with the following command:

sudo sudo env ARCHFLAGS="-arch x86_64" gem install dm-mysql-adapter

I appreciate that this question is 3 months old, but this page is the top hit for 'can't install dm-mysql-adapter on osx', and hopefully this will help somebody out.


On Mac Big Sur (11.6.2), first running

brew install mysql

and then runnimg the gem command worked for me.


In my case I had to install mysql-client first. At the end of install brew tells where /bin is - you may need to replace it

brew install mysql-client
export PATH=$PATH:/usr/local/opt/mysql-client/bin
gem install mysql2


I got a similar error when running gem install mysql2 -v 0.5.4 on Manjaro.

I solved it by running sudo pacman -S mysql

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜