To install MySQL gem:
$ export ARCHFLAGS="-arch i386 -arch x86_64"
$ gem install mysql -- --with-mysql-config=/usr/local/bin/mysql_config
returns an error:
ERROR: While executing gem ... (NoMethodError)
undefined method `spec' for nil:NilClass
How can I fix it?
Info:
$ brew list
git
mysql
readline
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-10
- GEM PATHS:
- /Library/Ruby/Gems/1.8
- /Users/horace/.gem/ruby/1.8
- /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- "gem" => "--no-ri --no-rdoc"
- REMOTE SOURCES:
- http://rubygems.org/
$ which mysql
/usr/local/bin/mysql
$ gem list
*** LOCAL GEMS ***
brewbygems (0.3.1)
sqlite3-ruby (1.3.2)
Thanks!
EDIT:
Output from dtruss: http://clomputing.com/temp/dtruss-gem-install-mysql.txt
For Ubuntu (Maverick) it is needed to install
sudo apt-get install libmysqlclient-dev
and after that run
sudo gem install mysql
for other diestribution, first
sudo apt-get install libmysqlclient-dev
and check where mysql_config is http://packages.ubuntu.com/
and run
sudo gem install mysql --with-mysql-config=path/to/mysql_config
Maybe try running it with strace and see what the problem is?
strace gem install mysql --with-mysql-config=/usr/local/bin/mysql_config
or if you're on Mac OS X
dtruss gem install mysql --with-mysql-config=/usr/local/bin/mysql_config
Related
I have installed mysql2 in mac m1 using the below command
gem uninstall mysql2
gem install mysql2 -v '0.3.21' -- --srcdir=/usr/local/Cellar/mysql/8.0.28_1/bin/include --with-mysql-include=/usr/local/Cellar/mysql/8.0.28_1/include/mysql --with-mysql-lib=/usr/local/Cellar/mysql/8.0.28_1/lib --with-cppflags=-I/usr/local/opt/openssl#1.0/include --with-opt-dir=/usr/local/opt/openssl#1.0 --platform=ruby
Installation works but when I starts rails s , I get the below error
/gems/mysql2-0.3.21/lib/mysql2.rb:31:in `require': cannot load such file -- mysql2/mysql2 (LoadError)
I am using Rails 3.2.22.5 and ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin21]
I downgraded the openssl to 1.0 to install ruby 2.3.0 using rosetta
I already installed mysql8 using brew install mysql .
Above is working in my another project which is running on Rails 4.2 and Ruby 2.3.1 but dont know why its not working here.
I also tried to downgrade mysql8 to 5.7 and then install mysql2 using the below
gem install mysql2 -v 0.3.21 -- --with-mysql-config=/usr/local/Cellar/mysql#5.7/5.7.37/bin/mysql_config --srcdir=/usr/local/Cellar/mysql#5.7/5.7.37/bin/include --with-ldflags=-L/usr/local/opt/mysql#5.7/lib --with-cppflags=-I/usr/local/opt/mysql#5.7/include --platform=ruby
But same error, installation complete but getting load error in rails s
Any help to fix this error will be appreciated.
I am able to solve this issue by downgrading mysql to 5.7 and then installing mysql-client#5.7
Below are the steps:
#stop mysql
brew services stop mysql
# install mysql5.7
brew install mysql#5.7
#Link mysql5.7
brew unlink mysql
brew link mysql#5.7 --force
# install mysqlclient
brew install mysql-client#5.7
#uninstall old mysql versions if already installed
gem uninstall mysql2
#install mysql2
gem install mysql2 -v 0.3.21 -- --with-mysql-config=/usr/local/bin/mysql_config --with-ldflags=-L/usr/local/Cellar/openssl#1.0/1.0.2u/lib --with-cppflags=-I/usr/local/Cellar/openssl#1.0/1.0.2u/include
Try this way, it's work for me
brew install openssl zstd mysql
LIBRARY_PATH=$(brew --prefix zstd)/lib/:$(brew --prefix openssl)/lib/ gem install mysql2
i have git clone git://github.com/jalagrange/excel_test_app.git
I got the below error while the bundle install, This does not happen with other my applications.
following error
Installing mysql2 (0.3.6) with native extensions
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
C:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... yes
checking for main() in -llibmysql... no
*** 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.
gemfile
source 'http://rubygems.org'
gem 'rails', '3.1.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
gem "spreadsheet"
gem "carrierwave"
gem "mini_magick"
gem 'flash_cookie_session'
gem "pry"
gem "haml"
gem 'fog'
# To use Delayed_job
gem 'daemons'
gem 'delayed_job_active_record'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> 3.1.0"
gem 'uglifier'
end
gem 'jquery-rails'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
group :test do
# Pretty printed test output
gem 'turn', :require => false
end
group :development, :test do
gem "mysql2", "0.3.6"
gem "letter_opener"
gem "pry"
end
this question and answer not working for my problem..
gem install: Failed to build gem native extension (can't find header files)
problem solved,
i have run bundle update..
thx all..
Run the following command and install the bundle again
sudo apt-get install libmysql-ruby libmysqlclient-dev
sudo apt-get install libmysqlclient-dev
then
gem install mysql2 -v=X.X.x
where x.x.x is the version that you need
then bundle install
2018.11.05 => Depreciated.
After an apt search libmysqlclient-dev you will get the new package you will need to continue installing mysql2.
In my case it results default-libmysqlclient-dev
apt install default-libmysqlclient-dev
gem install mysql2 -v 0.4.6
=> then you can restart thebundle installenter code here cmd.
Environment (Mac OS X 10.7.2 - Lion):
$ ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10]
$ rails -v
Rails 3.1.3
$ mysql -v
Server version: 5.1.44
I try running the following but I'm greeted with the same error every time even after applying fixes from all over the web:
$ rails server
dyld: lazy symbol binding failed: Symbol not found: _mysql_get_client_info
Referenced from: /Users/pressplay/.rvm/gems/ruby-1.9.3-p0/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Expected in: flat namespace
dyld: Symbol not found: _mysql_get_client_info
Referenced from: /Users/pressplay/.rvm/gems/ruby-1.9.3-p0/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
Expected in: flat namespace
Trace/BPT trap: 5
Failed attempts at fixing include:
sudo install_name_tool -change libmysqlclient.16.dylib /Applications/MAMP/Library/lib/mysql/libmysqlclient.16.dylib ~/.rvm/gems/ruby-1.9.3-p0/gems/mysql2-0.3.11/lib/mysql2/mysql2.bundle
sudo ln -s /Applications/MAMP/Library/lib/mysql/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
if you are using rvm/without rvm(just use sudo) then please use the following command which solve the issues.
rvmsudo ARCHFLAGS="-arch x86_64" gem install mysql2 -- --with-mysql-config=/usr/local/mysql/bin/mysql_config --with-opt-lib=/usr/local/mysql/lib
Uninstalling mysql2 gem and then installing gem with sudo solved it for me.
gem uninstall mysql2
sudo gem install mysql2
I can just add that you first need to uninstall the mysql2 gem and then reinstall with the instructions above.
sudo gem uninstall mysql2
Here's the deal:
$ gem -v
1.3.7
$ gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.9.2 (2010-08-18 patchlevel 0) [x86_64-darwin10.4.0]
- INSTALLATION DIRECTORY: /Users/harriett/.rvm/gems/ruby-1.9.2-p0#rails3tutorial
- RUBY EXECUTABLE: /Users/harriett/.rvm/rubies/ruby-1.9.2-p0/bin/ruby
- EXECUTABLE DIRECTORY: /Users/harriett/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-10
- GEM PATHS:
- /Users/harriett/.rvm/gems/ruby-1.9.2-p0#rails3tutorial
- /Users/harriett/.rvm/gems/ruby-1.9.2-p0#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
$ sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/Applications/MAMP/Library/bin/mysql_config
Building native extensions. This could take a while...
Successfully installed mysql-2.8.1
1 gem installed
$ gem list mysql
* LOCAL GEMS *
Why doesn't it show up?
Naturally, when I require "mysql" in a ruby program I get:
`require': no such file to load -- mysql (LoadError)
Your Ruby install is being managed by RVM. See "DO NOT use sudo..." on the RVM site.
Try installing it without sudo and it should show up in your gemlist.
I successfully installed MySql x86_64 in Snow Leopard and Ruby and Ruby Gems seems to be installed properly:
$ which mysql
/usr/local/mysql/bin/mysql
$ which ruby
/usr/bin/ruby
$ which gem
/usr/bin/gem
$ mysql
Your MySQL connection id is 404
Server version: 5.1.37 MySQL Community Server (GPL)
$ ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0]
$ gem -v
1.3.5
Unfortunatly I get an error installing mysql gem:
$ sudo gem update --system
...
$ sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --with-mysql-config=/usr/local/mysql/bin/mysql_config
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h
Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.8.1 for inspection.
I think you should try to uninstall the old mysql gem first before recompiling
sudo gem uninstall mysql
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Installing the Xcode that's bundled with the Snow Leopard fixed the problem.
For me, it was adding the UNIX Tools option (if I recalled the name accurately), which include the headers. When I installed XCode originally, I didn't include this component because I didn't think that I would be writing UNIX code. Little did I know...
If you've installed MySQL 5 using MacPorts, then use the command:
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/opt/local/bin/mysql_config5
I had this problem when I updated to Lion. In this case, I when to the app store and downloaded the latest Xcode. Then I uninstalled and reinstalled the database.
The issue had to do with a broken link during the update. Ruby likes to be in /System while Apple places ruby in /Developer.
was stuck with same problem:
Tried most of the solution's: At the end
Edit the app/config/database.yml, change the adapter to mysql2
production:
adapter: mysql2
database: commissi_production
username: root
password: root
host: localhost
& run on terminal
gem install activerecord-mysql2-adapter
Solved the problem.