jekyll-pageless-redirects icon indicating copy to clipboard operation
jekyll-pageless-redirects copied to clipboard

Wrong number of arguments in `load_file` call

Open timmyomahony opened this issue 10 years ago • 13 comments

I was getting an error when trying to build my jekyll site:

jekyll 2.0.3 | Error: wrong number of arguments (2 for 1)

When I added a traceback with jekyll build -t I was seeing the more detailed error:

/usr/lib/ruby/1.9.1/psych.rb:296:in `load_file': wrong number of arguments (2 for 1) (ArgumentError)

The problem seemed to be stemming from the following line in jekyll-pageless-redirects:

if File.exists?(file_path)
    YAML.load_file(file_path, :safe => true).each do | new_url, old_url |
      generate_aliases( old_url, new_url )
end

where YAML.load_file is passing two arguments instead of one. I'm not sure if it's down to my version of psych (2.0.5) but changing the line to:

if File.exists?(file_path)
    YAML.load_file(file_path).each do | new_url, old_url |
      generate_aliases( old_url, new_url )
end

has fixed the issue for me

timmyomahony avatar Jun 20 '14 15:06 timmyomahony

I've got the same issue but removing the 2nd argument doesn't solve it. I get this:

.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15: stack level too deep (SystemStackError)

atdnd avatar Jul 31 '14 15:07 atdnd

Thanks for reporting. I've been on vacation and am trying to catch up with all my obligations. I'll start looking into this shortly.

If you find a solution, a PR would be greatly appreciated and welcomed. :smiley: I'll even send you a rockin' loon sticker.

nquinlan avatar Aug 05 '14 22:08 nquinlan

I will try to help but I'm not good with ruby at all :(

atdnd avatar Aug 05 '14 23:08 atdnd

No worries. If not, I'll get to it eventually. I just need to dig myself out of the land of 1,000,000,000 emails first.

nquinlan avatar Aug 06 '14 00:08 nquinlan

Changing this line in jekyll-pageless-redirects:

@site.static_files << Jekyll::PagelessRedirectFile.new(@site, @site.dest, alias_index_path.split('/')[0, sections].join('/'), '')

to this:

@site.static_files << Jekyll::PagelessRedirectFile.new(@site, @site.dest, alias_index_path.split('/')[1, sections + 1].join('/'), '')

fixed the stack level too deep error for me.

dcac avatar Aug 26 '14 15:08 dcac

Any update on this issue? I have the same "wrong number of arguments (2 for 1) (ArgumentError)" as @timmyomahony

Richard-West avatar Oct 27 '14 18:10 Richard-West

I can't remember how I fixed the number of arguments, but the changes I made in my pull request fixed all the issues for me.

https://github.com/nquinlan/jekyll-pageless-redirects/pull/7

dcac avatar Oct 27 '14 18:10 dcac

Thanks @dcac -- I'm using the code in your PR and the error is gone. However none of the redirect stubs are being created in the _site folder. I might have a different issue that's causing this behavior. I've tried both ._redirects.yml and _redirects.json

Richard-West avatar Oct 27 '14 19:10 Richard-West

Odd, I'm using _redirects.yml, and it's working well for me.

Is it even creating any of the directories that match your old structure/locations?

dcac avatar Oct 27 '14 19:10 dcac

No -- none of the folders are being created in the _site folder. Do you have a public repo that I can take a look at to see if there is something else I have misconfigured?

Richard-West avatar Oct 27 '14 19:10 Richard-West

This is using it: https://github.com/dcac/dcac.github.io

dcac avatar Oct 27 '14 19:10 dcac

Thanks for your help @dcac -- I was not formating my yml file correctly.

I was trying: initial-page : /destination-page

Your file, and what is working for me as well, looks like: /initial-page/index.html : /destination-page/index.html

Richard-West avatar Oct 27 '14 19:10 Richard-West

Ah, yes. Glad to help!

dcac avatar Oct 27 '14 19:10 dcac