Incorrect MySQL client library version - sql

I created a new rails project calling
rails new simple_cms
Then when in the directory I run
rails s
I get the follow errors
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/l
ib/mysql2/mysql2.rb:2:in `require': Incorrect MySQL client library version! This
gem was compiled for 6.0.0 but the client library is 5.5.24. (RuntimeError)
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-
x86-mingw32/lib/mysql2/mysql2.rb:2:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-
x86-mingw32/lib/mysql2.rb:9:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-
x86-mingw32/lib/mysql2.rb:9:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/
lib/bundler/runtime.rb:68:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/
lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/
lib/bundler/runtime.rb:66:in `each'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/
lib/bundler/runtime.rb:66:in `block in require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/
lib/bundler/runtime.rb:55:in `each'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/
lib/bundler/runtime.rb:55:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/
lib/bundler.rb:119:in `require'
from c:/development/ruby/simple_cms/config/application.rb:7:in `<top (re
quired)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3
/lib/rails/commands.rb:53:in `require'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3
/lib/rails/commands.rb:53:in `block in <top (required)>'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3
/lib/rails/commands.rb:50:in `tap'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.3
/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
I have seen other people with this error but they tend to be linux users and I am running windows. I have attempted to reinstall both rails (railsinstaller.org) and mysql 5.5. I have used both the 32bit version as well as the 64bit version

There seem to be several questions on here already about this. Did you try their solutions?
Probably the most clear is this:
mysql2 gem compiled for wrong mysql client library
The pertinent part is here:
At the time of building this gem, the necessary DLL files where available
in the following download:
http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick
And put lib\libmysql.dll file in your Ruby bin directory, for example
C:\Ruby\bin

This will remove the gem and its dependencies. Then reinstalling will re-compile itself and all dependencies.
gem uninstall mysql2
bundle install

I had this error in a new project I was working on which suddenly stopped working in a windows machine that already had working rails projects, so it was clearly not an installation problem.
What caused the problem was a bundle update command, which decided to redownload mysql2 gem (for unknown reasons) and ignored my Gemfile line gem 'mysql2', '~> 0.2.6'.
The problem was that bundle update got mysql version 0.2.18, as shown in Gemfile.lock, in the following line:
mysql2 (0.2.18-x86-mingw32)
I'm note sure what the symbol means, but I replaced the following line in my gemfile
gem 'mysql2', '~> 0.2.6'
for
gem 'mysql2', '0.2.6'
And now everything works fine, including bundle update.

Related

How do I use cocoapods 0.33.1 on Yosemite?

Because of the breaking changes cocoapods 0.34.x introduces, I need to continue using 0.33.1 following my upgrade to Yosemite.
Unfortunately, running pod install produces this output:
$ pod install
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- xcodeproj/prebuilt/universal.x86_64-darwin14-2.0.0/xcodeproj_ext (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0/lib/xcodeproj/ext.rb:6:in `rescue in <top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0/lib/xcodeproj/ext.rb:3:in `<top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/2.0.0/gems/xcodeproj-0.17.0/lib/xcodeproj.rb:30:in `<top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/lib/cocoapods.rb:2:in `<top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/bin/pod:32:in `<top (required)>'
from /usr/bin/pod:23:in `load'
from /usr/bin/pod:23:in `<main>'
I have Xcode 6.1 and latest command line tools. The answer to the following question no longer works: Can't get to work CocoaPods and Yosemite
Alright, it seems the easiest solution is to install a Ruby environment manager. This allows the appropriate Ruby version to be loaded when cocoapods asks for it. I haven't dug too deep, but it seems the version CP is looking for is incompatible. (???) Anyway, installing rbenv immediately solved my problem.
I chose rbenv but there's another called RVM. rbenv did a good job explaining the differences between the two, however.

Rails console uninitialized constant MiniTest::Test (NameError) error

I use Rails. 3.2.16, with Rspec.
Recently when I run rails console I get the following error:
.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/minitest/unit.rb:28:in `const_missing': uninitialized constant MiniTest::Test (NameError)
from .rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/test/unit/testcase.rb:8:in `<module:Unit>'
from .rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/test/unit/testcase.rb:4:in `<module:Test>'
from .rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/test/unit/testcase.rb:3:in `<top (required)>'
from .rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-3.2.16/lib/active_support/test_case.rb:1:in `<top (required)>'
from .rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/console/app.rb:2:in `<top (required)>'
from .rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/application.rb:312:in `initialize_console'
from .rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/application.rb:152:in `load_console'
from .rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/commands/console.rb:27:in `start'
from .rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/commands/console.rb:8:in `start'
from .rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/railties-3.2.16/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
When I run rails server there are no problems.
Since I use Rspec, I don't have minitest in my Gemfile. However when I run gem list I can see:
minitest (5.3.3, 5.3.2, 4.7.5, 4.3.2)
And I am not sure why this suddenly happens.
Additional note
#user3364461 may have a related issue:
With RVM and last bundler (1.6.2) ruby 2.1.1, and rails 4.1. Happen
when I've updated some gem (Axlsx-rails, minitest, arel) If I force
minitest 5.3.2, it's the same bug with arel :
Could not find minitest-5.3.3 in any of the sources Run bundle install
to install missing gems.

Ruby on Rails + PostgreSQL app fails to start on AWS EC2. Error is: "cannot load such file -- pg_ext (LoadError)"

I began by installing all these dependencies:
sudo yum install ruby19 ruby19-devel gem rubygems19-devel make gcc postgresql9 postgresql9-devel postgresql9-server
Then I switch to the root user and I run
bundle install
and I get the green success message:
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
However, when I cd to the dir and run
rails s -p80
it I get all this and it fails to start (I'm still root because bind won't work to port 80 if I'm not root):
/usr/local/share/gems/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require': cannot load such file -- pg_ext (LoadError)
from /usr/local/share/gems/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require'
from /usr/local/share/gems/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
from /usr/local/share/gems/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require'
from /usr/local/share/gems/gems/pg-0.14.0/lib/pg.rb:4:in `<top (required)>'
from /usr/local/share/gems/gems/bundler-1.2.0/lib/bundler/runtime.rb:68:in `require'
from /usr/local/share/gems/gems/bundler-1.2.0/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
from /usr/local/share/gems/gems/bundler-1.2.0/lib/bundler/runtime.rb:66:in `each'
from /usr/local/share/gems/gems/bundler-1.2.0/lib/bundler/runtime.rb:66:in `block in require'
from /usr/local/share/gems/gems/bundler-1.2.0/lib/bundler/runtime.rb:55:in `each'
from /usr/local/share/gems/gems/bundler-1.2.0/lib/bundler/runtime.rb:55:in `require'
from /usr/local/share/gems/gems/bundler-1.2.0/lib/bundler.rb:128:in `require'
from /home/user/TransForm/config/application.rb:7:in `<top (required)>'
from /usr/local/share/gems/gems/railties-3.2.8/lib/rails/commands.rb:53:in `require'
from /usr/local/share/gems/gems/railties-3.2.8/lib/rails/commands.rb:53:in `block in <top (required)>'
from /usr/local/share/gems/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
from /usr/local/share/gems/gems/railties-3.2.8/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Perhaps there is an easy way to just deploy it correctly from the begining instead of messing around with error craps? I need PostgreSQL. This app works everywhere except this AWS EC2 instance, so I know my Gemfile is correct. Any clues would help.
open irb & type require "pg" does it work? if not, then check that pg_ext exists in /usr/local/share/gems/gems/pg-0.14.0/lib/ directory. you can install manually postgresql gem manually, using
gem install pg
If this still doesn't work, ensure that you are using latest version of ruby & latest version of rubygems using gem environment command.if its the older version, you can install latest ones using rvm
use gem pg
than
bundle install
bundle update
please not use any version of pg
I face this error and solved by this

Error building gem from git branch

I am following the instructions of this question to install a gem from git.
When I try to do I checkout of the branch I get:
mari#Black:~/Documents/apn_on_rails$ git checkout -b rails3 remotes/origin/rails3
fatal: git checkout: branch rails3 already exists
I also tried these instructions to download the branch and that works fine. But I still cannot build the gem. I get:
mari#Black:~/Documents/apn_on_rails$ rake build --trace
rake aborted!
no such file to load -- gemstub
/home/mari/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/mari/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/home/mari/Documents/apn_on_rails/Rakefile:2:in `<top (required)>'
/home/mari/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load'
/home/mari/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/home/mari/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
/home/mari/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `block in load_rakefile'
/home/mari/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/mari/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/home/mari/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `block in run'
/home/mari/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/mari/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/home/mari/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/home/mari/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `load'
/home/mari/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `<main>'
I also tried rake gem but I get the same error. What can I do?
I am using rails 3 and ruby 1.9.2
possibly you already have rails3 branch. Check this with git branch.
If branch already exist try running same command without '-b'. It should work.
I fixed the problem by running gem build apn_on_rails.gemspec instead of rake build or rake gem as suggested in the instructions followed

Unable to get Postgresql database to work with Ruby on Rails 3

Environment
Windows 7 64 bit
Ruby 1.8.7
Rails 3.0.0
pg AdminIII
PostgreSQL 9.0.3
Cygwin
Gemfile
http://i54.tinypic.com/27yzxv4.png
Database Config
http://i53.tinypic.com/288b7ma.png
Steps I have taken
I tried addding "gem 'postgres-pr', :require => 'pg'" to the gemfile
Have tried installing multiple variations of the postgres gem,
postgres-pr
pg
ruby-pg
I continually get this error when trying to run rake db:migrate
rake aborted!
no such file to load -- pg
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler.rb:120:in `require'
/home/Other/rails_projects/test_project/config/application.rb:7
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require'
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `require'
/home/Other/rails_projects/test_project/Rakefile:4
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `load'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `raw_load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2017:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2016:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2000:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
Been at this for a couple days, really need some help. Thanks in advance!
You need to specify the correct platform for the gem. In my Gemfile, I have:
group :development, :test do
gem 'pg', :platforms => :mingw
end
(The group is there because I deploy to a Unix box, where the platform is obviously different). I seem to remember that I also needed the DevKit for this to work.
You need to install pg and add to your Gemfile
gem 'pg'
You may need to upgrade your version of Rails to 3.0.1 - 3.0.9 and also run gem install pg. Then just for good measure re-run bundle install.