nquinlan / jekyll-pageless-redirects

Generates redirect pages based on YAML or htaccess style redirects.
MIT License
83 stars 15 forks source link

Wrong number of arguments in `load_file` call #5

Open timmyomahony opened 10 years ago

timmyomahony commented 10 years ago

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

atdnd commented 10 years ago

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)

nquinlan commented 10 years ago

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.

atdnd commented 10 years ago

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

nquinlan commented 10 years ago

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 10 years ago

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.

Richard-West commented 9 years ago

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

dcac commented 9 years ago

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

Richard-West commented 9 years ago

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 9 years ago

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?

Richard-West commented 9 years ago

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?

dcac commented 9 years ago

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

Richard-West commented 9 years ago

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 9 years ago

Ah, yes. Glad to help!