MySQL and MySQL2 gem builds on host but doesn't build via Capistrano or SSH
I'm trying to deploy a Rails app that uses Bundler via Capistrano.
Running cap deploy:cold
gives this:
** [out :: (my host)] Installing mysql2 (0.2.6)
** [out :: (my host)] with native extensions
*** [err :: (my host)] /usr/lib64/ruby/site_ruby/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)
*** [err :: (my host)]
*** [err :: (my host)] /usr/bin/ruby extconf.rb
*** [err :: (my host)] checking for rb_thread_blocking_region()... no
*** [err :: (my host)] checking for mysql_query() in -lmysqlclient... no
*** [err :: (my host)] checking for main() in -lm... yes
*** [err :: (my host)] checking for mysql_query() in -lmysqlclient... no
*** [err :: (my host)] checking for main() in -lz... yes
*** [err :: (my host)] checking for mysql_query() in -lmysqlclient... no
*** [err :: (my host)] checking for main() in -lsocket... no
*** [err :: (my host)] checking for mysql_query() in -lmysqlclient... no
*** [err :: (my host)] checking for main() in -lnsl... yes
*** [err :: (my host)] checking for mysql_query() in -lmysqlclient... no
*** [err :: (my host)] checking for main() in -lmygcc... no
*** [err :: (my host)] checking for mysql_query() in -lmysqlclient... no
*** [err :: (my host)] *** extconf.rb failed ***
*** [err :: (my host)] Could not create Makefile due to some reason, probabl开发者_运维问答y lack of
*** [err :: (my host)] necessary libraries and/or headers. Check the mkmf.log file for more
*** [err :: (my host)] details. You may need configuration options.
Just install the mysql-dev packages or something right? Not quite because the gems (mysql and mysql2) both build on the machine with Bundler without any issues, plus the other gems install without any issue.
What does Capistrano do that is different?
It's possible that it doesn't have the shell environment loaded the same way as logging in directly, so it can't find the mysqlclient libraries.
Usually it will want to be able to find mysql_config which can provide it that information. If you can figure out how to pass --with-mysql-config=/path/to/mysql_config
into the builder, I suspect it might help. I've done it before like this: gem install mysql2 -- --with-mysql-config=/path/to/mysql_config
I'm not sure how to get bundler to do that, but I hope this information helps
精彩评论