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.
Related
I am trying to run rails server command but it showing mysql2 Load Error. I will place my Error log here
I searched many places.
I tried to install from my bundle itself using "gem install mysql2 --ruby=platform" command using connector c "libmysql.dll" file pasted in ruby/bin but no use.
I actually have MySQL installed on my system long back when I was doing JDBC connections. Its SQL server version 5.0- Is that version causing this error? Or Do I need to uninstall the MySQL from my system and install Latest Version!
And a doubt for me is how is this MySQL Server 5.0 connected to Rails as I no I have no idea about it, because while installation I used Connector C 6.1 for mysql2 installation from the Command Promt!
I tried Ruby on Rails - cannot load such file -- mysql2/2.2/mysql2 (LoadError)
I also tried Error "...cannot load such file -- mysql2/2.0/mysql2 (LoadError)". On Windows XP with Ruby 2.0.0
But I am getting the same error.
I think I have given all the details regarding versions and what I did!
I tried doing this like 50 times but no progress! I hope I will get my problem solved !Thank You!
The following below instructions can help you.
gem uninstall mysql2
Download last MySQL connector from http://cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip
Extract it to C:\connector-6.0.2
gem install mysql2 --platform=ruby -- '--with-mysql-lib="C:\connector-
6.0.2\lib" --with-mysql-include="C:\connector-6.0.2\include" --with-mysql-
dir="C:\connector-6.0.2"'
Or even shorter:
gem install mysql2 --platform=ruby -- --with-opt-dir="C:\connector-6.0.2"
im not using windows. but seems to be duplicate with posts like this (Error "...cannot load such file -- mysql2/2.0/mysql2 (LoadError)". On Windows XP with Ruby 2.0.0)
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.
I setup rails 3.1.0.rc5 on my friends vista machine last week. Everything installed and i can run an application we're working on just fine, however, the rails command does not resolve. To start the server, i had to do the old fashioned: ruby script/rails s style. He has the ruby bin on his path, as ruby -v resolves fine. Any ideas on what to check?
Note i downloaded a 1.9.2 installer from rubyinstaller.org, setup the dev pack, and installed rails through bundler.
It sounds like your path isn't pointing to your rails gem bin.
My first suggestion was going to be use rvm but since you're on windows that won't be an option. RVM suggested pik for windows users, and if it works similar to RVM, you'll save yourself a ton of headaches.
Ok, I'm a noob with rails... so I just set up rails with RVM and created a new project, and when I try to visit a newly created view I'm getting an error 500.
Heres my setup:
OSX 10.6.5
Installed MySQL 64bit
RVM installed ruby 1.8.7 and rails 2.3.8 (no other rails or ruby except for the system ruby) rvm install 1.8.7, rvm use --create 1.8.7#rails2, gem install rails -v=2.3.8
Passenger with Apache gem install passenger, rvmsudo passenger-install-apache2-module
Passenger preference pane
Turned on websharing
I then proceeded to setup a rails project in my development folder called testapp, added it in the passenger preference pane, and then ran script/generate controller Say, defined an action hello, and then created a view in the app/view/say folder called hello.
Now I'm getting a 500 error when visiting myapp.local/say/hello, what am i doing wrong?
UPDATE:
I checked the logs and also tried running using WEBrick instead of passenger and apache. I got thrown back the same errors. I don't think I should post the entire log, should I? But the first error is
no such file to load -- sqlite3
I have not yet setup a db, I was going to use mysql, but I didn't want to install it since I'm not using models yet. Is it a requirement?
UPDATE 2:
So I installed the mysql gem with gem install mysql -- --include=/usr/local/lib (not sure if this is right). I then created a rails app with rails -d mysql myapp. And set the password in the database.yml. I'm getting a new error now:
Unknown database 'myapp_development'
So I have to create a database. Why am I being forced to create a db at all?
Yeah, you need to install sqlite even if you're not using models yet - Rails checks to make sure whatever is specified in database.yml is actually there to use.
Don't access it through passenger, launch it using ruby script/server and check out the error it throws there. Generally those errors are way more descriptive than Passenger because Passenger is probably running your application using the production environment.
Hey Ryan, do you need to Ruby 1.8.7? Why don't you install the latest 1.9.2 and Rails 3? I have the same environment and so far no problems. Here is a link for installing everything you need. Let me know if it helped! http://amerine.net/2010/02/24/rvm-rails3-ruby-1-9-2-setup.html
Salud!
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.