Rails - Error installing Gem - mysql

Im newbie starting to learn ruby/rails. While i was trying to setup WeBRICK to run, an error related to the libmysql.dll appeared, so ive downloaded an dll from an older version of mysql and tried again, but the error kept. Then i read that the problem was that my computer is 64bit and the gem mysql2 installed apparently is 32bit, that way i uninstalled that gem and tried to do the following workaround:
1) download mysql connector 32 bits
2) gem install mysql --platform=ruby -- --with-mysql-dir=C:/mysql-connector-c-noinstall-6.0.2-win32
the problem now is that im getting the following error:
ERROR: While executing gem ... (Errno::EEXIST)
File exists - C:
So, now i cant even install the mysql2 gem
Can you guys help me please?

It's not recommended to run ruby on rails on windows. mac or linux will be better.
if you can't change your OS. you can try this:
http://eric.cloud-mes.com/2012/04/1/install-Ruby-1.9.3-and-Rails-3.2.3-on-Windows-7.html

Related

Having issues attaching ruby to mysql using the mysql2 gem

Rails version 6.0.4.6
Ruby Version 2.7.5p203
mySql version 8
OS Window 10
I am having issues getting the mysql2 gem to work. The latest error I have is not being able to locate "mysql2 x64-mingw32" file. I installed the gem using this command:
gem install mysql2 --platform=ruby -- --with-mysql-dir="C:\Program Files\MySQL\Connector C++ 8.0"
--with_mysql-lib="C:\Program Files\MySQL\Connector C++ 8.0\lib64" --with_mysql_include="C:\Program Files\MySQL\Connector C++ 8.0\include"
It appears to have been installed correctly but still will not work. I have run bundle install. I have also tried deleting the gem.lock file and the running bundle install.
If anyone has had success in getting ruby to work with MySQL on a Windows machine, please let me know how you did it.
After many trails, it appears the Ruby just doesn't play well with Windows OS. While I expect that some do use Ruby on Windows, it appears the support is lacking, and the community is small.
I installed a Linux terminal on my machine and had much better luck.
Just posting to keep other from pulling their hair out.

How to install gem MySQL on Mac OS 10.6.6

Ruby already installed on Mac. So i just installed rails.
ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
rails 2.3.11
gem 1.3.5
When i trying : gem install mysql i get this error:
89-235-235-64:~ vitali$ gem install mysql
WARNING: Installing to ~/.gem since /Library/Ruby/Gems/1.8 and
/usr/bin aren't both writable.
WARNING: You don't have /Users/vitali/.gem/ruby/1.8/bin in your PATH,
gem executables will not run.
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
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 /Users/vitali/.gem/ruby/1.8/gems/mysql-2.8.1 for inspection.
Results logged to /Users/vitali/.gem/ruby/1.8/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
89-235-235-64:~ vitali$
Dont understand what to do. gem install mysql installing without MySQl itself or I should download and install MySQL as prorgamm? If yes, from what resource, what version, how to instal? Please help me, im newbie on mac. Big thanks!
You're almost certainly going to need MySQL installed to have the MySQL gem installed (even better is the mysql2 gem, which Rails also works with - just use mysql2 instead of mysql in your database.yml file).
I find the best way to get MySQL on my Mac whenever I format it (which, admittedly, is rarely) is to use Homebrew. So, if you don't have Homebrew installed, I'd start with that... and once that's done, it should be a matter of running sudo brew install mysql, and running the instructions it provides after the installation is done.

Setting up Mysql for Ruby on Rails in Windows

I'm on Windows, and I have a working Rails 2.3.8 app on Ruby 1.8.6 with MySQL 5.0 and the mysql gem version 2.8.1. It all works.
I just installed Ruby 1.9.1, installed gems for rails(2.3.8) and mysql. BUT NOW when I run ruby script/server:
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
I ALREADY INSTALLED IT!
One thing that might be a problem:
When I run "gem list" in my working ruby (v1.8.6) install, it lists "mysql (2.8.1)". BUT when I run "gem list" in the new ruby install (v1.9.1), it lists "mysql (2.8.1 x86-mingw32)". If that's the cause, how do I fix it? If it's not, what on earth is keeping Rails from recognizing the installed mysql gem?
Thanks in advance. I'm sure this is a common upgrade path, so I can't be the only one with this problem...
Finally got some solid info.
Apparently the mysql gem sucks, and shouldn't be relied on going forward.
That's why Rails 3.0.0 officially endorses the mysql2 gem instead (gem install mysql2), which unfortunately is not supported under Windows yet, though the gem's developer seems to be working on it.
As I try to get my app to Rails 3, I'm just going to make the easy switch to sqlite3 until there's a good mysql gem for windows.

Rails 3 Mysql Problems

Trying to start a new Rails 3 beta 4 app with mysql.... Running OS X Snow Leopard. WIth previous versions of Rails I have no problem with MySQL. But now when I start the Rails 3 app I get the following error when I click "About Your Application Environment" on the Rails index.html startup screen:
undefined method `init' for Mysql:Class
Change your Gemfile to use 'mysql2', it's a more modern driver and has nicer features as other people have mentioned.
New Rails applications use the mysql2 gem by default.
I ran into the same issue (RoR 3, OSX 10.6, mysql 2.8.1 gem).
You can use irb to rule out RoR:
irb
require 'rubygems'
require 'mysql'
db = Mysql.connect('hostname', 'username', 'password', 'database')
If the above doesn't work, you may want to try removing the mysql gem and reinstalling it. I came across a post saying bundle install might mess up the install without displaying errors.
sudo gem uninstall mysql
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Verify things work via irb, then start up rails again.
I ended up switching from the mysql gem to the ruby-mysql gem, worked.
For simple usage, which is typical (connecting, querying, iterating over results), I found mysql2 gem which is much faster than mysql or ruby-mysql gems and auto-casts values to proper types. And it installes perfectly on Snow Leopard while I couldn't get mysql gem to work.
More info at http://github.com/brianmario/mysql2
I think I have found the solution for the problem. In my case the problem was that the mysql gem hasn't been properly installed using the bundler . when I did this:
bundle install mysql (noobish mistake)
all gems went to mysql directory, but later on I have checked the docs of the bundler gem
and did this:
bundle install bundler_files ( to know where the gems are in the future)
everything looked almost ok except that when mysql gem was installing i got some errors.
I noticed that it was because of my folder path "/home/pawel/Aptana Studio Workspace/myrails_app"
If you have spaces in your folder path this gem wont install properly and later on when you modify the path to one without spaces and try to install the mysql gem IT WONT DISPLAY ANY ERRORS, but the installation will be corrupted, because you will have some extra folders there with some files etc. so
DELETE THE GEM FOLDER CREATED BY BUNDLER AND REINSTALL GEMS WITH THIS COMMAND:
bundle install
That solved the problem.
you can try switching to the mysql2 gem which should resolve all that issues for you. see: https://github.com/brianmario/mysql2/
I think what happens is that the mysql gem isn't able to load the mysql dynamic library (supposed to be supplied by the native MySQL installation). To test whether this is happening, do this
$ irb
1.9.2p320 :001 > require 'mysql_api'
=> true
1.9.2p320 :002 >
If it isn't able to load this low level mysql_api, (which actually supplies the functionality to the mysql gem), it will give you some potentially useful errors. Usually it is not able to find the dynamic library. To remedy this, I found a couple of solutions:
From http://wonko.com/post/how-to-install-the-mysqlruby-gem-on-mac-os-x-leopard, do this
For system-wide install
sudo env ARCHFLAGS="-arch i386" gem install mysql -- \
--with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib \
--with-mysql-include=/usr/local/mysql/include
or local install
env ARCHFLAGS="-arch i386" gem install mysql -- \
--with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib \
--with-mysql-include=/usr/local/mysql/include
and then from http://alexbraunstein.com/2011/08/12/library-loaded-libmysqlclient-18-dylib/ put in .bash_profile:
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH
I has the same issue after upgrading to Snow Leopard. On installing the MySQL gem, I got a bunch of errors about the documentation, then, on running the server:
undefined method `init' for Mysql:Class
I was also having some similar, but unrelated issues with other gems, particularly those that had C components that needed compiling such as RedCloth and hpricot:
Unable to compile native extensions
These errors were to do with native extensions in base 64 architecture. The solution was threefold:
I reinstalled XCode 4. The upgrade to Snow Leopard had broken my C compiler, so some gems were failing to compile. This took me a step closer, but didn't fix the issue.
I blew away and reinstalled RVM. It appeared to be installing gems in one directory, and finding them in another. This fixed every native architecture base64 error, but the MySQL gem was still failing.
I removed and downgraded MySQL to version 5.1. This fixed the MySQL gem issue.
All is now well again.

problems with mysql for ruby on rails

ah...it is not easy to get started ruby on rails to me..
I am trying to use mysql for ruby on rails development.
When I execute "gem install mysql", I get following error.
error: while generating documentation for mysql-2.8.3-x86-mswin32...message: unhandled special: special: type=17...bla bla...
how do I install mysql for ruby on rails!??!
If you are on windows and want to avoid mysql issues, just use v 2.1.2, just before they removed the mysql connector and put it into the mysql gem. It's better like that, but I ran into MANY issues installing this on the Windows XP machine at my work.
Make sure that your version of gems is the latest.
You should be able to update it using:
gem update --system
Going by your error it failed to generate the documentation for the Gem, though it could have installed it as it was. Firstly check to see if it did install, use:
gem list --local
And check to see if the MySQL driver is in the list already.
If it isn't the make sure you're installing the correct version of the driver, either mswin32, or ruby should do.
That's an error concerning rdoc generation. If you execute the following command you'll get no error:
gem install --no-rdoc mysql
I believe there are some problems generating rdoc for the Japanese localized version of the docs. Anyway, the mysql gem gets installed.
You can easily install the MySQL gem
either install the MySQL in ruby file where all gems are install or you can follow the path:
C:\Ruby192\lib\ruby\gems\1.9.1\gems
execute the below command:
gem install MySQL
hope this helps you!