Rails: Incorrect MySQL client library version - ruby-on-rails

I am new to Ruby/ RoR (like ... today new)
In trying my first real command:
rails g controller welcome index
This error appears:
.../lib/mysql2.rb:9: in 'require': Incorrect MySQL client library
version! This gem was compiled for 5.5.16 but the client library is
5.1.53 (RunTimeError).
Any step by step help on how to fix this would be most appreciated.
Some background:
I did reinstall MySQL between installing RailsInstaller and running this, for other reasons.
Win 7 x64, running 32 bit MySQL
Ruby/Rails installed today from http://railsinstaller.org

Do you have the development version of MySQL installed that has those libraries? And a C compiler installed?
It may be better to use the ruby native gem (if it still exists) for Windows. That's what we used to do in the Rails 2 days.
Sorry I can't be more help.

Related

check for sqlite3 ... no extconf.rb failed

Please do not just close
I've recently started learning rails and am having trouble with the rails server command when i run it i get the following error message:
C:/Ruby200/lib/ruby/2.0.0/gems/sqlite3-1.3.7-x86-mingw32/lib/sqlite3.rb:in 'require' cannot load such file -- sqlite3/sqlite3_native (LoadError)
this is followed by 16 from messages (I will add them if asked).
My system is Windows XP, Ruby version 2.0.0p195, Rails Version 4.0.0.
I will gladly provide further info upon request.
All the solutions I've found i have tried and it has not worked.
Solutions I've tried:
1) Knapsack solution
2) ruby setup.rb config -- --with-sqlite-include=c:\sqlite-autoconf-3071700
3) ive tried the sqlite-amalgamation download.
4) uninstalling and reinstalling sqlite3, ruby, rails, rubygems, dev tools, etc.
5) running virtual machine with ubuntu 13.04 (rails server command is working as if i said rails new server)
6) and several other command line runs and various downloads.
Its told me many times that its installed sqlite3 version 1.3.7, but I still get the same result.
Please and thank you for your help in advance!!
P.S. Many of the others are based on windows 7 or higher and older versions of ruby and/or rails.

Ruby versions and rails version on site5 is old

I m working on a project which was developed by another developer. Right now my job is to fix the bugs and all the necessary things. After all those things successfully done when i started to work for deployment on site5.com i got to know here that they ve not upgraded the ruby version. Still they are using ruby 1.8.7. There is a tutorial to upgrade the system to rails 3 but m not able to do that. The rails version installed on the server is 2.3.16.
When the code was given to me i bundle installed it with new version 1.9.3 and then i fixed few bugs which was a syntax error because of that syntax deprecation in 1.9.3. Now i ve asked to the client that there may be some compatibility issues if i go with the installation. Now what should i do? Should i go with the installation or suggest him some other hosting website.
since phusion 4 is stable now (allowing multiple rubies), and ruby 1.8 is considered 'legacy' by phusion developers (see their blog), doing any fixes for ruby 1.8.x seems to be a waste of time.
Changing ruby version requirements would break the application on site5, if they're really still on 1.8.x .

Rails project using MySQL gem not starting up on Windows 8

My specs are as follow:
Windows 8 64-bit
Ruby 1.9.3
Rails 3.2.12
I installed rails via the RailsInstaller. I have also installed the mysql2 gem. I created a new project that is pre-configured to use mysql e.g.
rails new project_name -d mysql
I then tried to start up the server/WEBrick via
rails server
And I get the following error:
I've tried this using the mysql2 as well as teh mysql gem. Both times I get the same error. When I use the default sqlite then the project starts up fine and I can view it on localhost:3000.
I'm aware that mysql2 used to be a problem on rails, but since mysql isn't working either I'm of the opinion that it's a Windows 8 specific project, surprise surprise.
I'd deff like to use MySQL rather than SQLite. Thanks for anyone that can point me in the right direction!
As a noted error case,
The SO Post says-
"The problem is with mysql. It is a 64 bit installation. Change it to 32bit and it runs fine."
Apart from that, this error may also be the result of some missing gems.
You should try running bundle install before running your server.
Also make sure that gem mysql is added to your gemfile before you do bundle install.
Please update your MySQL to 64bit version. It will fix the problem. Don't forgot to install the Devkit.

Rails Server broken after PostgreSQL download

Operating System I am using is Mac OSX Mountain Lion.
First I will give some back story on how this cluster F started. I am going through a Ruby on Rails Web development book. I want to use PostgreSQL as my server. Before today I was using sqlite3. I downloaded PostgreSQL 9.1 from there website. I used the DMG installer. Once I was done with the install process it asked me to re-boot because of some sort of memory problem, I did that and it installed without error.
The problem started when I tried to use the "Rails Server" command in the terminal. This is what I got (I tried to strip out the unimportant stuff which would clutter everything up)
/Users/Chris/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/pg-0.12.2/lib/pg.rb:4:in `require': dlopen(/Users/Chris/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/pg-0.12.2/lib/pg_ext.bundle, 9): Library not loaded: /usr/lib/libcrypto.dylib (LoadError)
Referenced from: /usr/lib/libpq.5.dylib
Reason: Incompatible library version: libpq.5.dylib requires version 1.0.0 or later, but libcrypto.0.9.8.dylib provides version 0.9.8 - /Users/Chris/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/pg-0.12.2/lib/pg_ext.bundle
...
from /Users/Chris/.rvm/gems/ruby-1.9.3-p194#rails3tutorial2ndEd/gems/railties-3.2.8/lib/rails/commands.rb:50:in
I have read through the out put and I have done a lot of Google searching, and what I have found is that it's a problem with which version of libcrypto the server is fetching. Or something about the libssl. I have gone through the solutions on google and nothing seems to be working. Hopefully someone has had the same problem I have, and can help me.
Thanks in advance! -Chris
I really recommend you to use Homebrew to install postrgresql. It helps you to install all proper dependencies for version which correctly works with rails.
$ brew install postgresql
Do not forget to follow after install instructions from homebrew
Are you sure you installed PostgreSQL server/rubygem successfully? From the stack trace I think there's a problem about it.
If your PostgreSQL server/rubygem are working well, then switch another webserver, mongrel/thin are both OK, both have better performance than the default rails server(webrick) and easy to use.

Installing PostgreSQL on OSX for Rails development

I've spent several hours over the past few days trying to get PostgreSQL to play nice with RoR on my Mac.
I've followed several tutorials using several different methods such as installing PostgreSQL manually and installing from various 1-click installers
However the all the different methods I tried failed on the last step of installing the pg gem. Very frustrating!
Does anyone here have a tried and tested tutorial for getting this done? (Or would you like to write some instructions here...?)
My environment is this: Macbook running OSX 10.6, PostgreSQL 8.4.1 server
I think I've managed to find a way that works. I'm borrowing heavily from this great post1, but since they are installing a bunch of other stuff at the same time I'm going to write out what I did here for people who are just looking for the PostgreSQL install answer.
1 Editor's note: Link seemed dead when I tried. Is this the one? http://blog.blackwhale.at/?p=175#PostgreSQL Please fix if it is.
Download PostgreSQL for Mac and download the ‘Postgres.app’ installer.
Create a user for your rails development (keep in mind that if you're sharing an application during development you'll probably want the same user between all members your dev team in order to avoid headaches)
sudo -u postgres /Library/PostgreSQL8/bin/createuser
Enter your Mac OS X system user name as role name, and make it a superuser.
Install the pg gem so Rails can talk to PostgreSQL
sudo env PATH=/Library/PostgreSQL8/bin:$PATH gem install pg
Configure your rails app to talk to PostgreSQL. You can either create a new application with:
rails *appname* -d postgresql (for Rails 3 -> rails new *appname* -d postgresql)
Or for an existing app, modify your database.yml file.
This worked for me without any hiccups. If anyone else tries using this method I'd be interested to hear some feedback on how it went for you.
On a 64-bit Mac (Snow Leopard with Core 2 Duo or newer) I had to compile PostgreSQL from source, as rails kept complaining that:
*** Your PostgreSQL installation doesn't seem to have an architecture in common
with the running ruby interpreter (["ppc", "i386", "x86_64"] vs. [])
The architecture mismatch was probably bc I'd compiled rails from source, which defaulted to 64-bit. The binary installer on postgresql.org seemed only a 32-bit version. Setting ARCHFLAGS didn't fix this for me.
Anyhow, if you download the [source][1] from postgresql.org and follow the instructions in the INSTALL file, it's fairly straightforward. You don't have to create a new user if you use your own account. I did have to create the sysctl.conf file to expand shared memory - just google 'postgresql os x sysctl.conf'
Old question, but still maybe i can help someone with this (rather simple) solution:
gem install pg -- --with-opt-include=/opt/local/include/postgresql84/ --with-opt-lib=/opt/local/lib/postgresql84/
Download and Install MacPorts
fire up terminal
sudo port install ruby postgresql83-server rb-postgres rb-gems rb-rails
Thanks to Ganesh for the good awnser, my sudo url looked a bit diffirent :) here is what I havesudo -u postgres /Library/PostgreSQL/9.2/bin/createuser
Ryan Bate's Railscast on PostgreSQL walks you through setting it up on a Mac with Homebrew. Very easy, worked for me on OSX 10.6.8.

Resources