I am trying to run the "Redmine" project management application written in Rails.
https://github.com/redmine/redmine
I downloaded it from Github and now while trying to run it (by double clicking on the rails file, I get this error in terminal:
Could not find gem 'mysql (~> 2.8.1) ruby' in the gems available on this machine
I have mysql 2.9.1 already installed.
I am new to the whole Rails thingy. I just installed it to be able to run this application.
So any advice on helping me run this app would be greatly appreciated.
Thanks
could it be that it doesnt work with the latest mysql version? make sure you stick this in your Gemfile in Rails app.
gem 'mysql', '~> 2.8.1'
also make sure its under test, or development if you want to run that locally.
group :test, :development do
gem 'mysql', '~> 2.8.1'
end
Probably easiest will be to tell Redmine to use your version of mysql:
Go to
\YourRedMineInstallFolder\apps\redmine\htdocs
open the Gemfile & Gemfile.lock and change/add this line at end or in mysql area.
gem "mysql", "~> 2.9.1"
Then go to the services and restart all redmine services specially ones with "..thin" in their name(This is pretty important).
Related
I'm fairly new when it comes to commandline or Rails, but work on a rails project where I'm doing the frontend.
I've installed all gems that are needed for the project, but lately some errors occur when doing a rake:db migrate or today when trying to deploy the current version via cap production deploy
The problem I'm facing seems to have todo with the mysql2 gem. At least that is what the console says.
When running cap production deploy I get this error:
rake stdout: Nothing written
rake stderr: rake aborted!
Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile.
and further down this …
Gem::LoadError: can't activate mysql2 (~> 0.3.10), already activated mysql2-0.4.2. Make sure all dependencies are added to Gemfile.
What do I have todo here? When I do gem list I see that mysql2 is installed.
Thank you,
Matt
Rails used to have the mysql2 gem locked down to ~>0.3 in the codebase.
So that is what it looks for but your Gemfile will simply state
gem "mysql2"
Pretty sure they've updated this in the latest release of rails 4 so either:
Update to the latest version of rails 4 or use a specific version of the mysql2 gem
gem "mysql2", "~> 0.3.20"
Please install the postgresql adapter: gem install activerecord-postgresql-adapter (pg is not part of the bundle. Add it to Gemfile.)
So I followed the instructions here: How to handle Ruby on Rails error: "Please install the postgresql adapter: `gem install activerecord-postgresql-adapter'"
First of all, that doesn't fix my issue (causes other errors that I'd need to debug), but regardless, why should I have to install the PG interface for ruby exactly? I'm on mysql!
Edit: I've been told Heroku doesn't support MySQL. Was this a recent change? I was using mysql just about 3 months back for my Heroku site without any issues at all.
I don't want to presume anything but if you were able to work with heroku before, you probably had something like this in your Gemfile:
group :production do
gem 'pg'
....
end
group :development do
gem 'rspec-rails'
gem 'sqlite3'
....
end
This would ensure that rails is using mysql (or sqlite3 if you copy the example verbatim) in the development environment and postgres ('pg') on the production environment hosted by heroku. Give this a shot and see if it solves your problem. I hope it does.
I have a problem that seems very related to that in another post, but I don't understand the solution that was arrived at. I am new to Rails, and have put together a Rails 3 app. I am developing in Windows am trying to deploy it to my (shared) Redhat Linux server via git and capistrano, and using Passenger to serve the pages. The deployment process goes fine, but when I try to look at the webpage I get a Passenger error:
!!! Missing the mysql gem. Add it to your Gemfile: gem 'mysql', '2.8.1'.
In fact, I have added the corresponding line to my Gemfile, and doing a 'gem list' on the server shows that it is there.
In this post, the user helpfully noted exactly the same problem and observed that the Gemfile.lock has the gem for Windows, i.e.
mysql (2.8.1-x86-mingw32).
This is exactly the same in my Gemfile.lock, and so I imagine the same issue is happening for me; one can see that this is the gem in vendor/cache and vendor/bundle.
However, I don't understand how the proposed fix from that post is supposed to work. I can edit the mysql line in Gemfile.lock to be mysql (2.8.1), but then I get a different Passenger error that says
Can't find mysql-2.8.1 in any of the sources.
How can I fix this?
In case someone encounters the same problem, here are some things I did that made it work. I don't understand enough of what was going on to know exactly what did the trick.
First, in the Gemfile, I specified that we wanted both ruby and windows versions of the relevant gems.
gem 'sqlite3-ruby', "~> 1.2.5", :platforms => [:mswin, :ruby_18]
gem 'mysql', "2.8.1", :platforms => [:mswin, :ruby_18]
Then on the production server, after using "cap deploy", I removed the gem mysql-2.81-x86-mingw32 from both vendor/bundle and vendor/cache. My production server lets me 'gem install mysql' and 'gem install sqlite3-ruby' but puts it elsewhere in my home directory; I copied these into vendor/bundle and vendor/cache. I edited the Gemfile.lock to change the line 'mysql (2.8.1-x86-mingw32)' to 'mysql (2.8.1)'. 'bundle install' on the production server then seems to install the linux native gems (at least it says 'building native extensions').
After all this, it seems to work.
Run the command bundle install. I'm sure this will fix your issue.
Also, do not edit or move over the Gemfile.lock. Let bundler take care of that.
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.
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.