Error: wrong number of arguments(2 for 1) #61

Closed
michaelbarton opened this Issue Apr 25, 2012 · 50 comments

Comments

I get the following error in psych when using YAML.load since upgrading bundler to 1.1.3.

~/.gem/gems/psych-1.3.2/lib/psych.rb:203:in `parse': wrong number of arguments(2 for 1) (ArgumentError)
 from ~/.gem/gems/psych-1.3.2/lib/psych.rb:203:in `parse_stream'
 from ~/.gem/gems/psych-1.3.2/lib/psych.rb:151:in `parse'
 from ~/.gem/gems/psych-1.3.2/lib/psych.rb:127:in `load'
Owner

tenderlove commented Apr 25, 2012

What version of Ruby are you using?

ruby -v :
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]

same issue here with ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0]

That fixed it for me too. I find it strange though that my code worked before I upgraded bundler from 1.0.3 to 1.1.3. This makes me think that perhaps there may be an underlying antagonistic bug between the two.

Owner

tenderlove commented Apr 27, 2012

Does the same error occur on the latest 1.9.3 patch level?

daya commented Apr 27, 2012

Yes it works with ruby-1.9.3-p125 but it doesn't work with jruby-1.6.7 in 1.9 mode.

sample repo
https://github.com/daya/crap

command:
jruby --1.9 -d -S padrino s -p 4000

stacktrace:
https://gist.github.com/dd0c86a2f7264da0a85f

Owner

tenderlove commented Apr 27, 2012

I see. I've changed the C bits, but the Java bits have not changed. We need to fix this in JRuby. In the mean time, you should be able to downgrade psych and it should work.

daya commented Apr 27, 2012

nope downgrading to psych 1.3.1 doesn't fix it

https://gist.github.com/36850817039c07373c80

Owner

tenderlove commented Apr 27, 2012

Yes, the change to the C bits were released with version 1.3.0. You need to downgrade to 1.2.2

Switching to the ruby 1.9.3p194 fixed this for me.

Thank you.

Owner

tenderlove commented Apr 30, 2012

@daya can you try with JRuby from master? I think it's fixed there, but I would like to verify.

Actually I find this kind of thing so unprofessional - to publish a version of a gem that changes a signature for a community running so many different permutations of the software. How about variable args and dealing with prior method invocation styles too?

Owner

tenderlove commented May 1, 2012

Actually the new method signature is a vararg signature. The problem is that people are somehow loading an older version of the c extension that has an arity of 1 alongside a newer version of the ruby code which expects an arity of -1. Please do a bit more research before throwing around words like "unprofessional". Thanks.

Hi Aaron

Forgive my irritation, it was not directed at you personally.  I've been programming in various languages for over 30 years and started with Ruby/Rails about 18 months ago.  Since then I have never had so many issues of incompatibility and broken code without locking down every version of every gem.  Looking at the community messages and blogs, this is a constant issue for everyone  Given the dynamic nature of the Rails community, it doesn't seem as if there is ever a moment in time where everything works.   And sometimes Gem authors take it upon themselves to deprecate things without understanding the consequences  I've virtually ever had this experience in Java, C#, C or C++.  To me, this indicates that something better than bundler is needed to manage the release process.  We are at the end of the line, but it seems like there should be something at the head - a central validation service which can also issue warnings and suggestions about
upcoming changes.  So in that sense,  I do stick to my guns about the word unprofessional.

I would be very interested in the practical aspect of your answer:  "The problem is that people are somehow loading an older version of the c extension that has an arity of 1 alongside a newer version of the ruby
code which expects an arity of -1."     I am just an ordinary developer with an ordinary environment trying to do the right thing.  Do you know how I could have gotten into the situation you describe?  I notice that quite a few others have as well.

  • Peter

From: Aaron Patterson reply@reply.github.com
To: Peter Abramowitsch pabramowitsch@yahoo.com
Sent: Tuesday, May 1, 2012 10:20 AM
Subject: Re: [psych] Error: wrong number of arguments(2 for 1) (#61)

Actually the new method signature is a vararg signature.  The problem is that people are somehow loading an older version of the c extension that has an arity of 1 alongside a newer version of the ruby code which expects an arity of -1.  Please do a bit more research before throwing around words like "unprofessional".  Thanks.


Reply to this email directly or view it on GitHub:
tenderlove#61 (comment)

Owner

tenderlove commented May 1, 2012

Forgive my irritation, it was not directed at you personally. I've been programming in various languages for over 30 years and started with Ruby/Rails about 18 months ago. Since then I have never had so many issues of incompatibility and broken code without locking down every version of every gem. Looking at the community messages and blogs, this is a constant issue for everyone Given the dynamic nature of the Rails community, it doesn't seem as if there is ever a moment in time where everything works. And sometimes Gem authors take it upon themselves to deprecate things without understanding the consequences I've virtually ever had this experience in Java, C#, C or C++. To me, this indicates that something better than bundler is needed to manage the release process. We are at the end of the line, but it seems like there should be something at the head - a central validation service which can also issue warnings and suggestions about upcoming changes. So in that sense, I do stick to my guns about the word unprofessional.

Cool, you should work on that. However, I don't think my issue tracker is the most productive place for fixing Open Source community problems. In other words, please stay on topic. The topic being "fixing bugs in psych". :-)

I would be very interested in the practical aspect of your answer: "The problem is that people are somehow loading an older version of the c extension that has an arity of 1 alongside a newer version of the ruby
code which expects an arity of -1." I am just an ordinary developer with an ordinary environment trying to do the right thing. Do you know how I could have gotten into the situation you describe? I notice that quite a few others have as well.

I don't know. Nobody has actually posted a way to reproduce the error. I cannot reproduce it, so I'm merely guessing from the stack trace. @michaelbarton's response indicates that I may be correct because the arity of this method is -1 in the patchlevel of Ruby he is running. I suspect this to be a bug in bundler, but I have no proof.

I also suspect this may be something to do with Bundler. This issue only occurred for me when I upgraded my version of Bundler; I changed no other part of my code. I suppose the way to reproduce this would be to try a variety of different ruby/bundler/psych versions to see which is the exact combination.

I have had other problems related to psych+bundler (here) and this was fixed by calling "gem 'psych'" before "Bundler.setup" which also suggests to me a possible bundler+psych bug.

I feel like perhaps these problems may continue to manifest while Bundler, Psych and Ruby have become inter-dependent yet move on different release cycles. I am however no Ruby expert though and so my opinion should be taken as such. I do however appreciate the effort taken by @tenderlove to quickly respond to my issue and all of his effort on the psych gem.

wagenet commented May 1, 2012

@pabramowitsch It seems that you must not have tried to do much in the way of dependency management in other languages. Ruby's bundler is one of the best I've encountered and I know people who use other languages that are a bit envious. It's possible that Bundler does have a bug, but that's hardly reason to call it unprofessional. As for complaints about deprecations, that's for you to address with the individual authors, not with @tenderlove who did things properly.

I wasn't the one pointing the finger specifically at Bundler. That was introduced by others on this thread. My original point was that due to the incredibly dynamic nature of this ecosystem, Bundler is not enough to manage the flux. That probably there needs to be some type of centralized management, unit testing, and validation at the distribution end of the RoR equation rather than just using Bundler at the receiving end. Perhaps it needs something like certain other language or protocol platforms that have extensive testing and certification processes. RoR is so widely diffused now that the core of it needs to be rock solid. Yaml or Psych, its descendant are definitely part of that core. Ruby Debug is another area that has had some trying moments very recently. Perhaps even a 4 month release cycle (dare I say it) rather than an instantaneous one is a better model now that we've grown up.

Owner

tenderlove commented May 1, 2012

@michaelbarton would you be able to post a way to reproduce the error with a 1.9.3 patch release that is less than 194? I don't think the JRuby issue that @daya was dealing with is the same bug as what you're experiencing. I think we actually have two different issues here, one with JRuby (which I'm addressing with the JRuby team and by developing a JRuby specific gem), and possibly a bundler issue.

The bundler issue would rear it's head on MRI, so I'd like to get a repro case on MRI. Thanks! :)

wagenet commented May 1, 2012

@pabramowitsch I suggest you spend some time trying to understand a bit more about how Bundler works before saying it's not sufficient. Bundler is exactly targeted to handle these sorts of issues and does quite well in the vast majority of cases. Anyway, this is probably not the place for continued discussion on this front.

Here you go

If I uninstall psych1.3.2 and return to 1.2.2 it works

ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.3.0]

Exception:

=> Rails 3.2.0 application starting in development on http://0.0.0.0:3002
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/psych-1.3.2/lib/psych.rb:203:in parse' /Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/psych-1.3.2/lib/psych.rb:203:inparse_stream'
/Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/psych-1.3.2/lib/psych.rb:151:in parse' /Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/psych-1.3.2/lib/psych.rb:127:inload'
/Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/psych-1.3.2/lib/psych.rb:297:in block in load_file' /Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/psych-1.3.2/lib/psych.rb:297:inopen'
/Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/psych-1.3.2/lib/psych.rb:297:in load_file' /Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/actionpack-3.2.0/lib/sprockets/railtie.rb:42:inblock in class:Railtie'
/Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:30:in instance_exec' /Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:30:inrun'
/Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:55:in block in run_initializers' /Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:54:ineach'
/Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/initializable.rb:54:in run_initializers' /Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/application.rb:136:ininitialize!'
/Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/railtie/configurable.rb:30:in method_missing' /Users/peterabramowitsch/hbm/portal/config/environment.rb:5:in<top (required)>'
/Users/peterabramowitsch/hbm/portal/config.ru:4:in require' /Users/peterabramowitsch/hbm/portal/config.ru:4:inblock in

'
/Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:51:in instance_eval' /Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:51:ininitialize'
/Users/peterabramowitsch/hbm/portal/config.ru:1:in new' /Users/peterabramowitsch/hbm/portal/config.ru:1:in'
/Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:40:in eval' /Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/builder.rb:40:inparse_file'
/Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/server.rb:200:in app' /Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands/server.rb:46:inapp'
/Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/server.rb:301:in wrapped_app' /Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/server.rb:252:instart'
/Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands/server.rb:70:in start' /Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands.rb:55:inblock in <top (required)>'
/Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands.rb:50:in tap' /Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/railties-3.2.0/lib/rails/commands.rb:50:in<top (required)>'
/Users/peterabramowitsch/hbm/portal/script/rails:6:in require' /Users/peterabramowitsch/hbm/portal/script/rails:6:in<top (required)>'
/Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug-ide.rb:123:in debug_load' /Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug-ide.rb:123:indebug_program'
/Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/gems/ruby-debug-ide19-0.4.12/bin/rdebug-ide:87:in <top (required)>' /Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/bin/rdebug-ide:19:inload'
/Users/peterabramowitsch/.rvm/gems/ruby-1.9.3-p0/bin/rdebug-ide:19:in `'
Uncaught exception: wrong number of arguments(2 for 1)

ENVIRONMENT:
pa-hbmi:portal peterabramowitsch$ bundle update
Fetching gem metadata from https://rubygems.org/.........
Using rake (0.9.2.2)
Using i18n (0.6.0)
Using multi_json (1.3.4)
Using activesupport (3.2.0)
Using builder (3.0.0)
Using activemodel (3.2.0)
Using erubis (2.7.0)
Using journey (1.0.3)
Using rack (1.4.1)
Using rack-cache (1.2)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.1.3)
Using actionpack (3.2.0)
Using mime-types (1.18)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.4.4)
Using actionmailer (3.2.0)
Using arel (3.0.2)
Using tzinfo (0.3.33)
Using activerecord (3.2.0)
Using activeresource (3.2.0)
Using archive-tar-minitar (0.5.2)
Using bundler (1.1.3)
Using coffee-script-source (1.3.1)
Using execjs (1.3.1)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using json (1.7.0)
Using rdoc (3.12)
Using thor (0.14.6)
Using railties (3.2.0)
Using coffee-rails (3.2.2)
Using columnize (0.3.6)
Using hbmi_auth_check (1.0.2) from source at ../auth_check
Using jquery-rails (2.0.2)
Using libv8 (3.3.10.4)
Using ruby_core_source (0.1.5)
Using linecache19 (0.5.13)
Using mysql2 (0.3.11)
Installing psych (1.3.2) with native extensions
Using rails (3.2.0)
Using ruby-debug-base19 (0.11.26)
Using ruby-debug-ide19 (0.4.12)
Using sass (3.1.16)
Using sass-rails (3.2.5)
Using therubyracer (0.10.1)
Using uglifier (1.2.4)

Owner

tenderlove commented May 1, 2012

@pabramowitsch can you please post the contents of your Gemfile? Thanks.

source 'https://rubygems.org'

gem 'rails', '3.2.0'

Bundle edge Rails instead:

gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'mysql2'

gem 'hbmi_auth_check', :path => '../auth_check'

Gems used only for assets and not required

in production environments by default.

group :assets do
gem 'sass-rails', '> 3.2.3'
gem 'coffee-rails', '
> 3.2.1'

See https://github.com/sstephenson/execjs#readme for more supported runtimes

gem 'therubyracer'

gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'
gem 'therubyracer'
gem 'psych'

group :development do
gem "linecache19", "0.5.13"
gem "ruby-debug-ide19"
gem "ruby-debug-base19", "0.11.26"
end

source 'https://rubygems.org'

gem 'rails', '3.2.0'

Bundle edge Rails instead:

gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'mysql2'

gem 'hbmi_auth_check', :path => '../auth_check'

Gems used only for assets and not required

in production environments by default.

group :assets do
gem 'sass-rails', '> 3.2.3'
gem 'coffee-rails', '
> 3.2.1'

See https://github.com/sstephenson/execjs#readme for more supported runtimes

gem 'therubyracer'

gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'
gem 'therubyracer'
gem 'psych'

group :development do
gem "linecache19", "0.5.13"
gem "ruby-debug-ide19"
gem "ruby-debug-base19", "0.11.26"
end

source 'https://rubygems.org'

gem 'rails', '3.2.0'

Bundle edge Rails instead:

gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'mysql2'

gem 'hbmi_auth_check', :path => '../auth_check'

Gems used only for assets and not required

in production environments by default.

group :assets do
gem 'sass-rails', '> 3.2.3'
gem 'coffee-rails', '
> 3.2.1'

See https://github.com/sstephenson/execjs#readme for more supported runtimes

gem 'therubyracer'

gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'
gem 'therubyracer'
gem 'psych'

group :development do
gem "linecache19", "0.5.13"
gem "ruby-debug-ide19"
gem "ruby-debug-base19", "0.11.26"
end

source 'https://rubygems.org'

gem 'rails', '3.2.0'

Bundle edge Rails instead:

gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'mysql2'

gem 'hbmi_auth_check', :path => '../auth_check'

Gems used only for assets and not required

in production environments by default.

group :assets do
gem 'sass-rails', '> 3.2.3'
gem 'coffee-rails', '
> 3.2.1'

See https://github.com/sstephenson/execjs#readme for more supported runtimes

gem 'therubyracer'

gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'
gem 'therubyracer'
gem 'psych'

group :development do
gem "linecache19", "0.5.13"
gem "ruby-debug-ide19"
gem "ruby-debug-base19", "0.11.26"
end

Owner

tenderlove commented May 1, 2012

I can't use this gemspec because this line references a path dependency that I don't have:

gem 'hbmi_auth_check', :path => '../auth_check'

Can someone please push even a demo rails app to github that will demonstrate this issue? I need a complete way to reproduce the error otherwise I cannot move forward. :(

Hi Aaron

you can just remove it.  It is a trivial bit of authentication stuff that wouldn't affect your experiments one way or the other

  • Peter

From: Aaron Patterson reply@reply.github.com
To: Peter Abramowitsch pabramowitsch@yahoo.com
Sent: Tuesday, May 1, 2012 2:56 PM
Subject: Re: [psych] Error: wrong number of arguments(2 for 1) (#61)

I can't use this gemspec because this line references a path dependency that I don't have:

gem 'hbmi_auth_check', :path => '../auth_check'

Can someone please push even a demo rails app to github that will demonstrate this issue?  I need a complete way to reproduce the error otherwise I cannot move forward. :(


Reply to this email directly or view it on GitHub:
tenderlove#61 (comment)

Owner

tenderlove commented May 1, 2012

Ok, I've removed it and successfully bundled with your Gemfile. Unfortunately I cannot get the bug to appear:

i suck

Can someone please post a self contained application including ruby version and bundler version information to reproduce this error?

daya commented May 2, 2012

Hi Aron,

this error was reproduced by me with JRuby1.6.7 may be this repo will help https://github.com/daya/crap (sorry for that name but I was frustrated ;) .

Regards,
-daya

Owner

tenderlove commented May 2, 2012

@daya no problem, and thanks for the info! As I said earlier, this should already be addressed in JRuby master, and I'm working on a new gem.

The problem is that some people are experiencing it on MRI, and I need to discover the steps to reproduce the bug on MRI. Thanks.

I've spent the last two nights trying to reproduce this
error on my system. I stuck though because I can't get an
earlier version of ruby to compile for me to test. I'm
trying to install a localised copy of ruby-1.9.3-p0 in a
directory but I keep getting the attached errors when
running make in the ruby dir. If anyone know a way to fix
this I'll see I can continue in reproducing the original
error.

output: https://gist.github.com/379f4c8f8c0578f806be

On Tue, May 01, 2012 at 02:06:12PM -0700, Aaron Patterson
wrote:

@michaelbarton would you be able to post a way to
reproduce the error with a 1.9.3 patch release that
is less than 194? I don't think the JRuby issue that
@daya was dealing with is the same bug as what you're
experiencing. I think we actually have two different
issues here, one with JRuby (which I'm addressing with the
JRuby team and by developing a JRuby specific gem), and
possibly a bundler issue.

The bundler issue would rear it's head on MRI, so I'd like
to get a repro case on MRI. Thanks! :)

--- Reply to this email directly or view it on GitHub:
tenderlove#61 (comment)
-5448164

Owner

tenderlove commented May 3, 2012

@michaelbarton Thank you for trying! Can you install the older version of ruby via RVM? You should be able to specify a patch level (rvm install 1.9.3-p0, then rvm use 1.9.3-p0).

I've never seen the error you've pasted. Where did you get the ruby source? Just via the ruby-lang.org website?

@michaelbarton Thank you for trying! Can you install the
older version of ruby via RVM? You should be able to
specify a patch level (rvm install 1.9.3-p0, then rvm use 1.9.3-p0).

I couldn't get this to work. After some playing around I
instead fired up an Ubuntu EC2 instance and tried it from
scratch. I created this Makefile:

https://gist.github.com/433c6a750101dbf2dc14

This downloads and installs ruby 1.9.3-p0 in a subdirectory.
It then installs bundler and runs it on a simple one line
Gemfile.

This however didn't reproduce the error for me and
everything worked fine. This makes me wonder if the error
could be specific to my system: OSX 10.7 + homebrew.

Perhaps you could try this Makefile and see if you get an
error? If you don't then I wonder if this could be something
specific to me.

I've never seen the error you've pasted. Where did you get
the ruby source? Just via the ruby-lang.org website?

Yes. Though I have had to tinker my the system a little bit
to get some other packages working. This included deleting
all the system gems. As I said above though 1.9.3-p0
installed previously through homwbrew so I should be able to
get this installed on my mac with further work if I need to.

Forget the comment in my last message about running the
Makefile I see that you've already run ruby-1.9.3-p0 with
bundler 1.1.3.

One other idea to possibly try. I originally had problems
while developing this gem before your suggestion to upgrade
my ruby version.

Try the following with ruby-1.9.3-p0

 git clone git://github.com/michaelbarton/scaffolder-annotation-locator.git
 cd scaffolder-annotation-locator
 git reset --hard 0fb5fb6
 sed -i '' 's/~> 1.0/= 1.1.3/' Gemfile
 bundle update
 rake
 rake features
Owner

tenderlove commented May 4, 2012

@michaelbarton thanks for working on this, I really appreciate it! I tried cloning that repo and using your repro steps, but it's still not failing for me. I get a few test failures, but not the exception in this bug report. Here is a gist of the commands I used along with the output. Can you spot any differences between that and your setup?

Again, thanks for looking in to this, I really appreciate your time!

As far as I can tell you have exactly the same conditions as
me. Unless someone else can give you a working repo that
reproduces this, then I think you should probably close this
issue.

Thanks also for your help too.

On Fri, May 04, 2012 at 09:16:35AM -0700, Aaron Patterson
wrote:

@michaelbarton thanks for working on this, I really
appreciate it! I tried cloning that repo and using your
repro steps, but it's still not failing for me. I get
a few test failures, but not the exception in this bug
report. Here is a gist of the commands I used along with
the output
.
Can you spot any differences between that and your setup?

Again, thanks for looking in to this, I really appreciate
your time!

--- Reply to this email directly or view it on GitHub:
tenderlove#61 (comment)
-5514115

davidw commented Jun 26, 2012

This bug took out my production site while I worked to trace it down. Downgrading to 1.2.2 seems to work - at least the site is up, but here is my information. I would not close this. Here is my setup:

gem 'rails', '3.2.2'
bundler (1.0.22)
ruby 1.9.2p318 (2012-02-14 revision 34678) [x86_64-linux]

Here's the error I was getting:

[ pid=15176 thr=18074220 file=utils.rb:176 time=2012-06-26 15:55:12.049 ]: *** Exception ArgumentError in PhusionPassenger::ClassicRails::ApplicationSpawner (wrong number of arguments(2 for 1)) (process 15176, thread #<Thread:0x000000022794d8>):
        from /usr/local/rvm/gems/ruby-1.9.2-p318@service-site/gems/psych-1.3.3/lib/psych.rb:203:in `parse'
        from /usr/local/rvm/gems/ruby-1.9.2-p318@service-site/gems/psych-1.3.3/lib/psych.rb:203:in `parse_stream'
        from /usr/local/rvm/gems/ruby-1.9.2-p318@service-site/gems/psych-1.3.3/lib/psych.rb:151:in `parse'
        from /usr/local/rvm/gems/ruby-1.9.2-p318@service-site/gems/psych-1.3.3/lib/psych.rb:127:in `load'

davidw commented Jun 26, 2012

Here's another data point that seems to support the idea that it's a problem with installing one version then another. Before deploying, I forgot to do apt-get install libyaml-dev, but the install succeeded anyway. After that, I tried gem uninstall psych and then reinstalling it, but the error persisted. In my development environment, I do not have this error despite a very similar software setup.

FWIW I ran into this issue and bumping Ruby from 1.9.2 to the latest 1.9.3 patch fixed it. I think I was using the latest version of Bundler. Sorry, if anyone wants more details I can check at home, just thought this might be helpful.

Okay, I hope this is helpful and not just noisy. Sorry if that's the case. I can reproduce this on my Debian machine.

$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]

$ rails -v
Rails 3.2.3

$ rails new greenfield
[...]

$cd greenfield

$ rails g model Anything
/home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/psych-1.3.4/lib/psych.rb:96: warning: already initialized constant VERSION
/home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/psych-1.3.4/lib/psych.rb:99: warning: already initialized constant LIBYAML_VERSION
invoke active_record
/home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/psych-1.3.4/lib/psych.rb:203:in parse': wrong number of arguments(2 for 1) (ArgumentError) from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/psych-1.3.4/lib/psych.rb:203:inparse_stream'
from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/psych-1.3.4/lib/psych.rb:151:in parse' from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/psych-1.3.4/lib/psych.rb:127:inload'
from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.3/lib/rails/application/configuration.rb:115:in database_configuration' from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.3/lib/active_record/railtie.rb:75:inblock (2 levels) in class:Railtie'
from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.3/lib/active_support/lazy_load_hooks.rb:36:in instance_eval' from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.3/lib/active_support/lazy_load_hooks.rb:36:inexecute_hook'
from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.3/lib/active_support/lazy_load_hooks.rb:43:in block in run_load_hooks' from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.3/lib/active_support/lazy_load_hooks.rb:42:ineach'
from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.3/lib/active_support/lazy_load_hooks.rb:42:in run_load_hooks' from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.3/lib/active_record/base.rb:721:in<top (required)>'
from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.3/lib/rails/generators/named_base.rb:162:in pluralize_table_names?' from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.3/lib/rails/generators/named_base.rb:110:intable_name'
from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.2.3/lib/rails/generators/active_record/model/model_generator.rb:17:in create_migration_file' from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/task.rb:22:inrun'
from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:118:in invoke_task' from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:124:inblock in invoke_all'
from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:124:in each' from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:124:inmap'
from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:124:in invoke_all' from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/group.rb:226:indispatch'
from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:109:in invoke' from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/group.rb:269:inblock in _invoke_for_class_method'
from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/shell.rb:74:in with_padding' from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/group.rb:258:in_invoke_for_class_method'
from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/group.rb:150:in _invoke_from_option_orm' from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/task.rb:22:inrun'
from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:118:in invoke_task' from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:124:inblock in invoke_all'
from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:124:in each' from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:124:inmap'
from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/invocation.rb:124:in invoke_all' from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/group.rb:226:indispatch'
from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/thor-0.14.6/lib/thor/base.rb:389:in start' from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.3/lib/rails/generators.rb:170:ininvoke'
from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.3/lib/rails/commands/generate.rb:12:in <top (required)>' from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:inrequire'
from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in block in require' from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:inload_dependency'
from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in require' from /home/johnny/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.3/lib/rails/commands.rb:29:in<top (required)>'
from script/rails:6:in require' from script/rails:6:in

'

$rvm use 1.9.3-p194

$ rails g model Anything
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/x86_64-linux/psych.so: warning: already initialized constant ANY
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/x86_64-linux/psych.so: warning: already initialized constant UTF8
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/x86_64-linux/psych.so: warning: already initialized constant UTF16LE
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/x86_64-linux/psych.so: warning: already initialized constant UTF16BE
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/stream.rb:12: warning: already initialized constant ANY
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/stream.rb:15: warning: already initialized constant UTF8
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/stream.rb:18: warning: already initialized constant UTF16LE
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/stream.rb:21: warning: already initialized constant UTF16BE
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/sequence.rb:42: warning: already initialized constant ANY
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/sequence.rb:45: warning: already initialized constant BLOCK
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/sequence.rb:48: warning: already initialized constant FLOW
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/scalar.rb:9: warning: already initialized constant ANY
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/scalar.rb:12: warning: already initialized constant PLAIN
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/scalar.rb:15: warning: already initialized constant SINGLE_QUOTED
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/scalar.rb:18: warning: already initialized constant DOUBLE_QUOTED
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/scalar.rb:21: warning: already initialized constant LITERAL
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/scalar.rb:24: warning: already initialized constant FOLDED
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/mapping.rb:16: warning: already initialized constant ANY
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/mapping.rb:19: warning: already initialized constant BLOCK
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/mapping.rb:22: warning: already initialized constant FLOW
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/visitors/visitor.rb:10: warning: already initialized constant DISPATCH
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/scalar_scanner.rb:8: warning: already initialized constant TIME
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/scalar_scanner.rb:11: warning: already initialized constant FLOAT
/home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/parser.rb:33:in <class:Parser>': superclass mismatch for class Mark (TypeError) from /home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/parser.rb:32:inmodule:Psych'
from /home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/parser.rb:1:in <top (required)>' from /home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych.rb:7:inrequire'
from /home/johnny/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych.rb:7:in <top (required)>' from /home/johnny/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/ordered_hash.rb:2:inrequire'
from /home/johnny/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/ordered_hash.rb:2:in <top (required)>' from /home/johnny/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/ordered_options.rb:1:inrequire'
from /home/johnny/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/ordered_options.rb:1:in <top (required)>' from /home/johnny/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/configuration.rb:2:inrequire'
from /home/johnny/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/configuration.rb:2:in <top (required)>' from /home/johnny/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/railtie.rb:2:inrequire'
from /home/johnny/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/railtie.rb:2:in <top (required)>' from /home/johnny/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/engine.rb:1:inrequire'
from /home/johnny/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/engine.rb:1:in <top (required)>' from /home/johnny/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/plugin.rb:1:inrequire'
from /home/johnny/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/plugin.rb:1:in <top (required)>' from /home/johnny/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/application.rb:3:inrequire'
from /home/johnny/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/application.rb:3:in <top (required)>' from /home/johnny/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails.rb:10:inrequire'
from /home/johnny/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails.rb:10:in <top (required)>' from /home/johnny/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/all.rb:1:inrequire'
from /home/johnny/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/all.rb:1:in <top (required)>' from /home/johnny/greenfield/config/application.rb:3:inrequire'
from /home/johnny/greenfield/config/application.rb:3:in <top (required)>' from /home/johnny/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands.rb:24:inrequire'
from /home/johnny/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/commands.rb:24:in <top (required)>' from script/rails:6:inrequire'
from script/rails:6:in `

'

$ rvm use 1.9.3-p0
Using /home/johnny/.rvm/gems/ruby-1.9.3-p0

$ rails g model Anything
invoke active_record
create db/migrate/20120810031410_create_anythings.rb
create app/models/anything.rb
invoke test_unit
create test/unit/anything_test.rb
create test/fixtures/anythings.yml

So it seems to be okay with 1.9.3-p0

It looks like when Bundler loads, it tries to require psych, which could be a different version than what's used by the app noted in the Gemfile. I think this is why we see the initialized constant warns. Also, an app might not require psych at all, but it gets loaded by Bundler anyway. Peep https://github.com/carlhuda/bundler/blob/master/lib/bundler/psyched_yaml.rb

batter commented Mar 5, 2013

I just encountered this issue on my home machine that doesn't get a ton of development usage anymore, and thus had some out of date gems.

Upgrading bundler to the latest release (1.3.1) from the version that I had (1.0.21) seemed to fix the issue. I'm running on ruby-1.9.2-p290 via RVM on a darwin OS btw.

hannesg commented Mar 7, 2013

Hi

I've a minimum testcase:

  • completely clean ruby 1.9.2-p290 ( installed with rvm )

    $> rvm install 1.9.2-p290
    $> rvm use 1.9.2-p290
    
  • gem updated to 1.8.25

    $> gem install rubygems-update -v=1.8.25
    
  • bundler updated to 1.2.1

    $> gem install bundler -v=1.2.1
    
  • set GEM_PATH to "~/.rvm/gems/ruby-1.9.2-p290" so that it doesn't include the global gemset

    $> export GEM_PATH=~/.rvm/gems/ruby-1.9.2-p290
    
  • Gemfile like this:

    source 'https://rubygems.org'
    gem 'psych', '= 1.3.4'
    
  • bundle install --path=./foo

  • command:

    $> ruby -rubygems -rbundler -e "Bundler.setup; Bundler.require; Psych.parse 'one', 'two' "
    psych.rb:96: warning: already initialized constant VERSION
    psych.rb:99: warning: already initialized constant LIBYAML_VERSION
    psych.rb:203:in `parse': wrong number of arguments(2 for 1) (ArgumentError)
    

Observations so far:

  • psych is loaded in psyched_yaml.rb by bundler
  • before that it fails to activate the psych gem as it's not installed globally
  • newer bundler versions ( tested 1.3.1 ) still have this psyched_yaml.rb but don't require it during load up, so they work fine

Cheers'
Hannes

Hi,
I'm running into this issue as well and was able to create a simple rails project that demonstrates the error. Just run rake. All it took was adding an rvmrc file to use 1.9.3-p125. Hope it helps.

Was also having this problem with bundler 1.2.4, went to 1.3.5 and it fixed it. From the redefinition warnings looks like bundler had preloaded psych.

STDERR: /srv/sidekick/shared/bundler-cache/ruby/1.9.1/gems/psych-1.3.4/lib/psych.rb:96: warning: already initialized constant VERSION
/srv/sidekick/shared/bundler-cache/ruby/1.9.1/gems/psych-1.3.4/lib/psych.rb:99: warning: already initialized constant LIBYAML_VERSION
rake aborted!
wrong number of arguments(2 for 1)
/srv/sidekick/shared/bundler-cache/ruby/1.9.1/gems/psych-1.3.4/lib/psych.rb:203:in `parse'
/srv/sidekick/shared/bundler-cache/ruby/1.9.1/gems/psych-1.3.4/lib/psych.rb:203:in `parse_stream'
/srv/sidekick/shared/bundler-cache/ruby/1.9.1/gems/psych-1.3.4/lib/psych.rb:151:in `parse'
/srv/sidekick/shared/bundler-cache/ruby/1.9.1/gems/psych-1.3.4/lib/psych.rb:127:in `load'
/srv/sidekick/shared/bundler-cache/ruby/1.9.1/gems/psych-1.3.4/lib/psych.rb:297:in `block in load_file'
/srv/sidekick/shared/bundler-cache/ruby/1.9.1/gems/psych-1.3.4/lib/psych.rb:297:in `open'
/srv/sidekick/shared/bundler-cache/ruby/1.9.1/gems/psych-1.3.4/lib/psych.rb:297:in `load_file'

Just encountered this myself.

macos 10.8.3
bundler 1.3.5
psych 1.3.4 (in addition to the stdlib's psych 1.2.2 apparently? should this work?)
ruby 1.9.3-p125
rails 3.2.12

I had a working bundle, but I when tried to add gem 'apipie-rails', bundle install gives this error:

Fetching source index from https://rubygems.org/
/Users/mmueller/.rvm/gems/ruby-1.9.3-p125@myproject-rails3-ruby19/gems/psych-1.3.4/lib/psych.rb:96: warning: already initialized constant VERSION
/Users/mmueller/.rvm/gems/ruby-1.9.3-p125@myproject-rails3-ruby19/gems/psych-1.3.4/lib/psych.rb:99: warning: already initialized constant LIBYAML_VERSION
Resolving dependencies..............

ArgumentError: wrong number of arguments(2 for 1)
An error occurred while installing rake (10.0.4), and Bundler cannot continue.
Make sure that `gem install rake -v '10.0.4'` succeeds before bundling.

The "already initialized constant" warnings seem like a red flag. The ArgumentError occurs only after adding gem 'apipie-rails' to my Gemfile. It appears to be trying to install rake 10.0.4 for some reason, although rake 10.0.4 is already installed in my bundle. The stack trace indicates that the exception happens in psych, however:

ArgumentError: wrong number of arguments(2 for 1)
/Users/mmueller/.rvm/gems/ruby-1.9.3-p125@myproject-rails3-ruby19/gems/psych-1.3.4/lib/psych.rb:203:in `parse'
/Users/mmueller/.rvm/gems/ruby-1.9.3-p125@myproject-rails3-ruby19/gems/psych-1.3.4/lib/psych.rb:203:in `parse_stream'
/Users/mmueller/.rvm/gems/ruby-1.9.3-p125@myproject-rails3-ruby19/gems/psych-1.3.4/lib/psych.rb:151:in `parse'
/Users/mmueller/.rvm/gems/ruby-1.9.3-p125@myproject-rails3-ruby19/gems/psych-1.3.4/lib/psych.rb:127:in `load'
/Users/mmueller/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:492:in `from_yaml'

Applying the tweak from pull request #54 resolves the error for me. (I understand that this may not be the "correct" change, but it works...) Removing psych from Gemfile also fixes it (the psych in Ruby's stdlib continues to exist of course). Hopefully this helps. For some reason I doubt it actually has anything to do with apipie-rails, which is why I'm posting here. It's probably just triggering this code path in bundler to execute somehow.

I was also facing the same issue, I updated the bundler version from 1.2.2 to 1.3.5 and it worked for me.

@tenderlove tenderlove closed this Aug 29, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment