I have searched everywhere and no ones solutions solve my problem. I have built rails apps using SQLite but not MySQL. For this particular project, I need MySQL. When I attempt to boot the server I get an error, so I attempt to install the gems for MySQL and get another error. Does anyone have any insight? Thank you!
rails server
Could not find gem 'mysql2 (>= 0)' in any of the gem sources listed in your Gemfile.
sudo gem install mysql2
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
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/mysql2-0.2.7 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/ext/mysql2/gem_make.out
I had this problem. You need to install the mysql gem with native extensions.
The line you're probably looking for is this:
$ ARCHFLAGS="-arch x86_64" gem install mysql2 --version '~> 0.2.7' -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Full write up on getting it going here: http://softwaregravy.com/mysql-on-os-x-rails-3-0-7/
Related
I need to setup ruby on rails with MySQL
I already have installed MYSQL
when I do Bundle install it shows following error.
Fetching mysql2 0.3.21
Installing mysql2 0.3.21 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
I am using Cent-os 8
anyone can help
Thanks
Run first this command gem 'mysql2', '~> 0.3.21' in terminal and when finish then try bundle again
I know may be this is a popular problem but i try many solutions and not get to finish
I try to install mysql in rails with
gem install mysql2
And I get the result
Building native extensions. This could take a while...
Successfully installed mysql2-0.3.18
1 gem installed
But when i try to execute the command
bundle show mysql2
I get
Could not find gem 'mysql2'.
All these command execute in my application root directory
What is the problem ?
bundle show lists the names and versions of all gems that are required by your Gemfile, so at first you should add mysql2 gem to it:
gem 'mysql2'
I am unable to install the "mysql2" gem on my CentOS linux machine.
I recently install mysql following the following tutorial: http://www.rackspace.com/knowledge_center/article/installing-mysql-server-on-centos
When I try to download "mysql2" gem I get the following log:
[root#vc2cmmka035538n ruby]# gem install mysql2
ERROR: Could not find a valid gem 'mysql2' (>= 0) in any repository
ERROR: Possible alternatives: mysql
Environment info:
Rails 3.2.3
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
gem -v 1.8.24
From their github page, quoted
This gem links against MySQL's libmysqlclient C shared library. You may need to install a package such as libmysqlclient-dev, mysql-devel, or other appropriate package for your system.
So, you might wanna install those packages first. Then you can even manually compile the gem if you still face the problem.
https://github.com/brianmario/mysql2
If mysql repo is disabled on your system, here is the link about installing them
http://dev.mysql.com/doc/mysql-repo-excerpt/5.6/en/linux-installation-yum-repo.html
I'm running Ubuntu 14 and when I try to run rails server but I get this error:
Could not find gem 'mysql2 (>= 0) ruby' in the gems available on this machine.
Run bundle install to install missing gems.
So I run the bundle install and then I get the following error.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby2.1 extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.1.0/gems/mysql2-0.3.16 for inspection.
Results logged to /var/lib/gems/2.1.0/extensions/x86_64-linux/2.1.0/mysql2-0.3.16/gem_make.out
An error occurred while installing mysql2 (0.3.16), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.16'` succeeds before bundling.
So I run gem install mysql2 -v '0.3.16' and it installs successfully however when I run bundle install again it gives me the same error:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby2.1 extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.1.0/gems/mysql2-0.3.16 for inspection.
Results logged to /var/lib/gems/2.1.0/extensions/x86_64-linux/2.1.0/mysql2-0.3.16/gem_make.out
An error occurred while installing mysql2 (0.3.16), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.16'` succeeds before bundling.
Start again from scratch and this time you should install RVM as it is really good at handling all this stuff for you.
http://rvm.io/rvm/install
Make sure you get all the dependencies first, this code will check to see what you have and don't have:
for name in {bash,awk,sed,grep,ls,cp,tar,curl,gunzip,bunzip2,git,svn} ; do which $name ; done
Its also worth looking at the prerequisites page: http://rvm.io/rvm/prerequisites
You can run the below code to install rvm with Ruby 2.1.1 and Rails:
\curl -sSL https://get.rvm.io | bash -s stable --rails
Then To start using RVM:
/bin/bash --login
Its definitely worth using RVM it will make your life much easier when managing your ruby versions, gems etc, just make sure you read through the webpage so that you know how to use it.
When I try rake db:migrate, I get the following error:
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
rake aborted!
no such file to load -- mysql
And when I try to "gem install mysql"
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
Can't find header files for ruby.
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1 for inspection.
I checked the rubygems folder and mysql gem has been installed. Any ideas? Cheers
This should sort it out on Ubuntu:
sudo aptitude install libmysqlclient-dev build-essential
Then install the gem again. You may need to delete the /usr/lib/ruby/gems/1.8/gems/mysql-2.8.1 folder if it craps out.
I hope that helps.
The gem hasn't actually been installed. You are missing either the ruby development files, mysql developer files, or linux build essentials. Since you are asking, I'll assume you are on a linux distribution with a package manager; install the corresponding packages.
As Sleepycat suggested, most probably you need the dev libraries for MySQL.
On Fedora / CentOS this should solve your problem:
yum install mysql-devel
gem install mysql