Forum: Ruby on Rails rails server error (rails 3) in windows

D58a293c2b3963822349885c0a80d3a9?d=identicon&s=25 jack cognac (cognacjack)
on 2012-03-20 05:54
Hey all,

I'm trying to learn RoR with absolutely no programming experience
following the ruby on rails essentials tutorial on lynda.com. I'm still
very early in the video series and I created a new project using the
command:

rails new simple_cms -d mysql

but when I try to launch the web server, this happens:
C:\Users\j\Sites\simple_cms>rails server
C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:in
`require': 193: %1 is not a valid Win32 application.   -
C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/1.9/mysql2.so
(LoadError)
    from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:in
`<top (required)>'
    from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2.rb:9:in
`require'
    from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2.rb:9:in
`<top (required)>'
    from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.1/lib/bundler/runtime.rb:68:in
`require'
    from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.1/lib/bundler/runtime.rb:68:in
`block (2 levels) in require'
    from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.1/lib/bundler/runtime.rb:66:in
`each'
    from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.1/lib/bundler/runtime.rb:66:in
`block in require'
    from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.1/lib/bundler/runtime.rb:55:in
`each'
    from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.1/lib/bundler/runtime.rb:55:in
`require'
    from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.1.1/lib/bundler.rb:119:in
`require'
    from C:/Users/j/Sites/simple_cms/config/application.rb:7:in
`<top (required)>'
    from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:53:in
`require'
    from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:53:in
`block in <top (required)>'
    from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:50:in
`tap'
    from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-3.2.2/lib/rails/commands.rb:50:in
`<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

C:\Users\j\Sites\simple_cms>

Some version info just in case:
C:\Users\j\Sites\simple_cms>ruby -v
ruby 1.9.3p125 (2012-02-16) [i386-mingw32]

C:\Users\j\Sites\simple_cms>ruby -v
ruby 1.9.3p125 (2012-02-16) [i386-mingw32]

C:\Users\j\Sites\simple_cms>mysql --version
mysql  Ver 14.14 Distrib 5.5.21, for Win64 (x86)

I've already searched the web looking for solutions, but none of them
seem to work. Any help would be greatly appreciated, thank you.
E7bf84a8c8f5143e8d90bc3caba15b14?d=identicon&s=25 Javier Quarite (Guest)
on 2012-03-20 06:04
(Received via mailing list)
Have you add mysql gem?
(maybe you have added it but just in case )


Javier
E7bf84a8c8f5143e8d90bc3caba15b14?d=identicon&s=25 Javier Quarite (Guest)
on 2012-03-20 06:05
(Received via mailing list)
sorry my bad, I've seen it :)

It seems that its a windows problem
D58a293c2b3963822349885c0a80d3a9?d=identicon&s=25 jack cognac (cognacjack)
on 2012-03-20 15:01
Javier Quarite wrote in post #1052402:
> Have you add mysql gem?
> (maybe you have added it but just in case )
>
>
> Javier

I'm pretty sure I did, "gem install mysql", correct?
E7bf84a8c8f5143e8d90bc3caba15b14?d=identicon&s=25 Javier Quarite (Guest)
on 2012-03-20 15:09
(Received via mailing list)
Yes, have you installed it using rails installer?

or something else?
E7cff3cfd41c495e1012227d7dc24202?d=identicon&s=25 Luis Lavena (luislavena)
on 2012-03-20 18:24
(Received via mailing list)
On Tuesday, March 20, 2012 1:54:25 AM UTC-3, Ruby-Forum.com User wrote:
> but when I try to launch the web server, this happens:
> C:\Users\j\Sites\simple_cms>rails server
>
>
C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:in
> `require': 193: %1 is not a valid Win32 application.   -
>
Most likely this is caused by an incorrect version of "libmysql.dll"
that
you have in your system.

Some version info just in case:
>
Ruby 32bits can't be matched or use 64bits version of MySQL dlls.

Please read this:
http://blog.mmediasys.com/2011/07/07/installing-my...

You can skip the steps that involve installing MySQL itself, but not the
ones about using MySQL Connector/C (32bits) and link mysql gem to it.

It is recommended that once you compile the gem, copy the libmysql.dll
provided inside MySQL Connector/C to your Ruby bin directory and ensure
Ruby bin directory is *before* MySQL one in the PATH (you can check that
with "SET PATH" from the console)

Also, once you do this, ensure you're pointing to the right version in
your
Gemfile, or bundler will complain and ask you to bundle install, which
you
should avoid.

Always install gems outside bundler when you need to provide additional
compilation flags, the do "bundle check" to ensure it picks the manually
installed gem.

Also, remove the previous installed version.

Hope that helps.
--
Luis Lavena
248724dab57e9b2d20b1a4131e0f92a2?d=identicon&s=25 Chris Cox (ce_cox)
on 2014-01-21 11:41
Hi Guys
Struggled some time with this, but found the issue appears to be the
line
in the mysql2.rb file:

require mysql/mysql

Removing this works better however the server doesn't start normally.
When I copied the mysql.rb file from the mysql folder to

C:\Ruby\lib\ruby\gems\1.9.1\gems\mysql2-0.3.14\lib

and renamed mysql2.rb to something else server starts fine.
On further investigation I found anothe copy of mysql.rb in

C:\Ruby\lib\ruby\gems\1.9.1\gems\mysql-2.9.1-x86-mingw32\lib

Which is used if you remove the one you just copied into
mysql2-0.3.14\lib.

The mysql.rb file has the line :

require 'mysql/mysql_api'
248724dab57e9b2d20b1a4131e0f92a2?d=identicon&s=25 Chris Cox (ce_cox)
on 2014-01-21 19:04
Further to the above I decided to start again with a clean install using
railsinstaller.

Went through similar issues but on renaming mysql2.rb and not having an
old mysql.rb file in the path, I found it was erroring on line 72 of
runtime.rb
which when I commented out :
          #Kernel.require file

Server started ok
D50f52512bb303123a1c9827bb1a92bd?d=identicon&s=25 p val (Guest)
on 2014-01-23 08:56
(Received via mailing list)
it's not that necessary to use mysql so early if u're just learning RoR.
just start a new project without mysql options:

rails new project_name
316c03a99e8ed311e5462d94f085fc2e?d=identicon&s=25 John Ivanoff (Guest)
on 2014-01-23 22:07
(Received via mailing list)
I aggree. SQLITE will work fine. the only difference will be your
config/database.yml
When you do rails new project_name rails will set up the yml properly.

I wrote a post back 2010 on setting up rails 2 sqlite on XP
http://blog.johnivanoff.com/2010/09/ruby-192-rails...

Might help.

John
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.