I am trying to upgrade my app and this is the error I am getting while deploying the app:
Error loading the 'mysql2' Active Record adapter. Missing a gem it depends on? can't activate mysql2 (< 0.6.0, >= 0.4.4), already activated mysql2-0.3.21. Make sure all dependencies are added to Gemfile.
here is my Gemfile:
https://github.com/BI-CTSICN/sparc-request/blob/master/Gemfile
gem 'mysql2', '~> 0.3.18'
gem 'rails', '~> 5.1', '>= 5.1.4'
I am using ruby 2.4.2
Your mysql2 version you use (0.3.21, checked in Gemfile.lock) is too old, required one is newer than 0.4.4.
Upgrade your mysql2 gem by changing version in Gemfile and running bundle update mysql2. Of course before that check what changed between versions and then run your tests to check if upgrade didn't break anything.
Just lock the mysql2 gem version not work for me. The only thing that work was match the rails gem version with mysql2 gem version, comparing both by it's release date.
Ex: I'm updating now my rails version from 5.1 to 5.2, so I want to put mysql 0.5.3 on my application (the most recent version). But I can put only the 0.4.10 version, because of it's release date match with rails 5.2.0.rc2 version that I installed right now (both are from march, 2018, with one day of difference).
I don't know why this working, but I guess that's a incompatibility problem between the rails and mysql2 versions that I tried to install.
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"
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).
Any help would be greatly appreciated, when I run the "generate model" command I get the following message:
WARNING: This version of mysql2 (0.2.18) isn't compatible with Rails 3.1 as the ActiveRecord adapter was pulled into Rails itself.
WARNING: Please use the 0.3.x (or greater) releases if you plan on using it in Rails >= 3.1.x
Is there a way to update the mysql2 version so it works with rails 3.1? or perhaps i could downgrade rails from 3.1 to 3.0?
You need to run
gem update mysql2
or add
gem "mysql2", "~> 0.3.11"
to your Gemfile and run bundle install
I had the same problem even after upgrading. It kept refusing to use 0.3.11 and defaulted back to the earlier version.
Finally figured out that in the Gemfile I had it written "< 0.3" instead of "> 0.3".
Kind of obscure (and dumb), but maybe it'll help someone.
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 built my Rails 3 app using sqlite and now I'm trying to switch over to MySQL.
I created a new MySQL db, changed database.yml accordingly, and I added an older version of the mysql2 gem to my gemfile (gem 'mysql2', '< 0.3') which is supposed to play nicer with Rails 3.
I can start the dev server fine. When I visit a page, I get a Mysql2::Error (Table 'twitter_quiz_development.users' doesn't exist). Which is fine--I still need to add the schema to the new db. This is where I run into trouble:
rake db:schema:load returns this nasty error.
The solution found here did not work for me. gem pristine --all return this.
I'm running Ubuntu 11 if that helps.
It appears that the error has to do with JSON but I have no idea how to solve this. Thanks.
The issue(s) you are experiencing could be due to 3 things:
The version of Ruby you are using
The use of the SystemTimer gem with Ruby 1.9
The JSON gem
I've elaborated below...
The first thing I would suggest is to upgrade your version of Ruby 1.9. The latest stable is:
ruby 1.9.2p180 (2011-02-18 revision 30909)
I would highly recommend using Ruby Version Manager (RVM) to install and manage Rubies.
In terms of using the JSON gem, have a look at:
http://ruby.about.com/od/tasks/a/The-Json-Gem.htm
To quote:
On Ruby 1.8.7, you'll need to install a gem. However, in Ruby 1.9.2, the json gem is bundled with the core Ruby distribution. So, if you're using 1.9.2, you're probably all set. If you're on 1.8.7, you'll need to install a gem.
Before you install the JSON gem, first realize that this gem is distrubuted in two variants. Simply installing this gem with gem install json will install the C extension variant. This requires a C compiler to install, and may not be available or appropriate on all systems. Though if you can install this version, you should.
If you can't install the C extension version, you should gem install json_pure instead. This is the same gem implemented in pure Ruby. It should run everywhere that Ruby code runs, on all platforms and on a variety of interpreters. However, it's considerably slower than the C extension version.
Edit:
Looks like you should avoid using the SystemTimer gem with Ruby 1.9. See this for more info: http://isitruby19.com/systemtimer
To quote a comment made on that page by Phillipe:
I am the (co)-author of this gem. Short story : Using this gem in Ruby 1.9 is useless and does not make any sense!
System Timer is trying to work around some limitation of the "green thread" model used in Ruby 1.8 (MRI). See http://ph7spot.com/musings/system-timer for more details.
It is then irrelevant in a Ruby 1.9 which abandoned the green thread model and embraced native threads (kind of since there is still a global interpreter lock).
Cheers,
- Philippe
Your gem pristine --all looks like it errored out with the SystemTimer gem before it got to the json gem. Is that gem used in the Rails app in question?
Are you using RVM? If so, I'd manually remove the SystemTimer and json gems and their binaries (if any) from ~/.rvm/gems/ruby-whatever-version/ (in the gem and bin subdirectories).
Try to update to the latest version of the JSON gem (1.5.1) by adding this to your Gemfile:
gem "json", "1.5.1"
And then run bundle install to install SystemTimer and the later version of the json gem.