nquinlan/jekyll-pageless-redirects

Wrong number of arguments in `load_file` call

timmyomahony opened this issue · 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

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)

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. 😃 I'll even send you a rockin' loon sticker.

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

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.

dcac commented

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.

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

dcac commented

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.

#7

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

dcac commented

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?

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?

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

dcac commented

Ah, yes. Glad to help!