(ArgumentError) - in `initialize': wrong number of arguments (4 for 0)

Greetings all,

Please forgive the double posting, I just thought it would be better to
list this issue separately, with a more communicative subject (please
reply to this one).

I’ve just started learning Ruby (and Geo Ruby), and am trying to create
overlays for Google Maps.

I found a [seemingly] great tutorial for doing this @
http://blog.newsplore.com/2009/02/22/spincloud-lab

…and it uses Ruby - cool, eh?

Have everything installed properly (as far as I
can tell - gem list gives me the whole bundle including: mysql (2.8.1)).
MySQL working fine.

I get this error when trying to run the script (attached) from a shell:

Command:
$ ruby ./Desktop/gen_encpolygons.rb

Returns:
./Desktop/gen_encpolygons.rb:11:in initialize': wrong number of arguments (4 for 0) (ArgumentError) from ./Desktop/gen_encpolygons.rb:11:innew’
from ./Desktop/gen_encpolygons.rb:11:in `generate_js_border_overlay’
from ./Desktop/gen_encpolygons.rb:95

I’ve googled extensively for similar argument errors, and I’m not
finding any good matches (or solutions).

…so I opened an irb session to try a little test:

Command:
Mysql::new(‘localhost’, ‘root’, ‘’, ‘my_database’)

Returns:
NameError: uninitialized constant Mysql
from (irb):1

Then I checked for the gem:

require ‘mysql’
=> true

Any help is greatly appreciated.

Best,
Micah

Greetings,

Does anyone have any ideas about this? I am still stuck.

Thanks,
Micah

On Fri, Mar 11, 2011 at 11:37 AM, Micah W. [email protected]
wrote:

Does anyone have any ideas about this? I am still stuck.

About “this”? It’s a popular (or at least widely-used) four-letter
English
word, though the exact meaning is pretty context-dependent.

HTH!

Am 11.03.2011 20:53, schrieb Hassan S.:

On Fri, Mar 11, 2011 at 11:37 AM, Micah W. [email protected] wrote:

Does anyone have any ideas about this? I am still stuck.

About “this”? It’s a popular (or at least widely-used) four-letter English
word, though the exact meaning is pretty context-dependent.

HTH!

Maybe he comes from another language and means the “self” keyword?

Vale,
Marvin

Andrew W. wrote in post #986975:

I think it’s more likely he meant to put this question on the other
thread
he started recently, which you can find
herehttp://www.ruby-forum.com/topic/1226240#new
.

Yeah, sorry about that. I don’t know what happened.

I just wish I could get as many helpful replies as I received to the
mis-post.

Additional info (eratta):
System info:
MacBook Pro
OS X 10.5.8
2.6 GHz Intel Core 2 Duo
MAMP v. 1.9.4

irb:

require ‘geo_ruby’
=> true

require ‘mysql’
=> true

I have gems v1.3.6 installed.
mysql (2.8.1)
GeoRuby (1.3.4)

Best,
Micah

I think it’s more likely he meant to put this question on the other
thread
he started recently, which you can find
herehttp://www.ruby-forum.com/topic/1226240#new
.

On Sun, Mar 13, 2011 at 9:51 AM, Micah W. [email protected]
wrote:

What happens if you run the snippet below as a standalone script?

start snippet

require ‘rubygems’
require ‘mysql’

puts “checking – #{Mysql.class.name}”
borderDB = Mysql::new(‘localhost’, ‘root’, ‘’, ‘test’)
puts “checking – #{borderDB.class.name}”

end snippet

On Sun, Mar 13, 2011 at 12:57 PM, Micah W. [email protected]
wrote:

I don’t think this is a script problem, but everything seems to check
out with the MySQL, and the other gems.

If a simple Mysql.new fails, I’d be real tempted to delete that gem and
reinstall. Have you possibly done an OS upgrade since you originally
installed it? Or switched to rvm?

Hassan S. wrote in post #987216:

On Sun, Mar 13, 2011 at 9:51 AM, Micah W. [email protected]
wrote:

What happens if you run the snippet below as a standalone script?

start snippet

require ‘rubygems’
require ‘mysql’

puts “checking – #{Mysql.class.name}”
borderDB = Mysql::new(‘localhost’, ‘root’, ‘’, ‘test’)
puts “checking – #{borderDB.class.name}”

end snippet

Hi Hassan,

Thanks for the reply.

I get this:
checking – Class
./Desktop/test.rb:5:in initialize': wrong number of arguments (4 for 0) (ArgumentError) from ./Desktop/test.rb:5:innew’
from ./Desktop/test.rb:5

I don’t think this is a script problem, but everything seems to check
out with the MySQL, and the other gems.

See why I’m tearing my hair out?

Thank you again for the reply.

Best,
Micah

Brian C. wrote in post #987315:

You don’t happen to have a file called “mysql.rb” in your working
directory do you?

I made that mistake before - for example, writing a test program for
sinatra and deciding to call it ‘sinatra.rb’ :slight_smile:

Hi Brian,

Thanks for the response.

No, I only have the ruby gem ‘mysql.rb’ with that name.

I don’t think this is a script problem, but everything seems to check
out with the MySQL, and the other gems.

If a simple Mysql.new fails, I’d be real tempted to delete that gem and
reinstall. Have you possibly done an OS upgrade since you originally
installed it? Or switched to rvm?

Hi Hassan,

Thanks for bearing with me on this.

No OS upgrade, haven’t switched, not using the version manager (should I
be?).

I changed line 11 to borderDB = Mysql.real_connect(‘localhost’, ‘root’,
‘root’, ‘my_database’)

and now I get the following error:
./Desktop/gen_encpolygons.rb:11:in generate_js_border_overlay': undefined methodreal_connect’ for Mysql:Class (NoMethodError)
from ./Desktop/gen_encpolygons.rb:95

Yes, mysql.new failed.

So, I think I am going to uninstall the gem, and reinstall it. Would it
be better to use the ‘pure ruby’ gem? What would you guys recommend?

Best,
Micah

On Mon, Mar 14, 2011 at 5:55 PM, Micah W. [email protected]
wrote:

No OS upgrade, haven’t switched, not using the version manager (should I
be?).

It’s useful, but I wouldn’t necessarily start until you figure this out.

So, I think I am going to uninstall the gem, and reinstall it. Would it
be better to use the ‘pure ruby’ gem?

I would just go with a complete reinstall of the standard gem (with the
native extensions) and see what happens. Document the entire – i.e.
both removal and re-installation – process just in case :slight_smile:

Non-ruby-related tip: use the script command to capture all of the
relevant console input and output, e.g.

18:21 ~ $ script /tmp/save-what-i-did
Script started, output file is /tmp/save-what-i-did
18:21 ~ $ pwd
/Users/hassan
18:21 ~ $ exit

Script done, output file is /tmp/save-what-i-did
18:21 ~ $ cat /tmp/save-what-i-did
Script started on Mon Mar 14 18:21:33 2011
18:21 ~ $ pwd
/Users/hassan
18:21 ~ $ exit

Script done on Mon Mar 14 18:21:55 2011
18:22 ~ $

HTH,

Micah W. wrote in post #987225:

What happens if you run the snippet below as a standalone script?

start snippet

require ‘rubygems’
require ‘mysql’

puts “checking – #{Mysql.class.name}”
borderDB = Mysql::new(‘localhost’, ‘root’, ‘’, ‘test’)
puts “checking – #{borderDB.class.name}”

end snippet

Hi Hassan,

Thanks for the reply.

I get this:
checking – Class
./Desktop/test.rb:5:in initialize': wrong number of arguments (4 for 0) (ArgumentError) from ./Desktop/test.rb:5:innew’
from ./Desktop/test.rb:5

I don’t think this is a script problem, but everything seems to check
out with the MySQL, and the other gems.

You don’t happen to have a file called “mysql.rb” in your working
directory do you?

I made that mistake before - for example, writing a test program for
sinatra and deciding to call it ‘sinatra.rb’ :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs