railslove / fontello_rails_converter

CLI gem for comfortably working with icon fonts (open, download, convert) from http://fontello.com for usage in Rails apps.
MIT License
73 stars 35 forks source link

fontello convert error, zip corrupt #18

Closed ErikKrause closed 10 years ago

ErikKrause commented 10 years ago

Hello, when I run fontello convert I get this error:

C:/Ruby193/lib/ruby/gems/1.9.1/gems/rubyzip-1.1.0/lib/zip/entry_set.rb:56:in `dup': can't dup NilClass (TypeError)
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rubyzip-1.1.0/lib/zip/entry_set.rb:56:in `block in dup'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rubyzip-1.1.0/lib/zip/entry_set.rb:56:in `each'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rubyzip-1.1.0/lib/zip/entry_set.rb:56:in `map'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rubyzip-1.1.0/lib/zip/entry_set.rb:56:in `dup'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rubyzip-1.1.0/lib/zip/file.rb:84:in `initialize'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rubyzip-1.1.0/lib/zip/file.rb:96:in `new'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/rubyzip-1.1.0/lib/zip/file.rb:96:in `open'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/fontello_rails_converter-0.2.0/lib/fontello_rails_converter/cli.rb:30:in `convert'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/fontello_rails_converter-0.2.0/bin/fontello:98:in `<top (required)>'
        from C:/Ruby193/bin/fontello:23:in `load'
        from C:/Ruby193/bin/fontello:23:in `<main>'

Investigating a bit further I found that in the automatically downloaded fontello.zip there are additional hex 0D 0A sequences where in the otherwise completely identical manually downloaded version there is only hex 0A (both always after hex 50 48 03 04 - PK...). What goes on here?

Sorry, I'm a total ruby noob, so please be patient if I missed something obvious.

jhilden commented 10 years ago

Hi @ErikKrause, thanks for your issue and the further investigation. Are you able to try and see if the issue could be related to this commit 31d9f48016d3e6e159aa5313782dc745cc5e09ba by @hqm42?

jhilden commented 10 years ago

Actually, the commit has been made after the last release. Could you try if working with the current master branch fixes your issue?

ErikKrause commented 10 years ago

Sorry, I have no idea how to install the master branch. Could you give me (or point me to) a short description...

jhilden commented 10 years ago

@ErikKrause I just released a new version 0.3.0 of the gem including the encoding fixes by @hqm42 can you try if that fixed your issue?

kangguru commented 10 years ago

and just for the records you can put the following into your Gemfile:

gem "fontello_rails_converter", git; "https://github.com/railslove/fontello_rails_converter.git"

and it will use the current master instead of the latest released version on rubygems.org

ErikKrause commented 10 years ago

I ran gem update which installed v.0.3.0 and gem clean to delete the older versions. However, the zip I get with fontello convert is still corrupt the same way. I get different error messages though (from rubyzip).

jhilden commented 10 years ago

can you post the complete error message? also, can you provide me the corrupt zip file? and with your config.json file?

ErikKrause commented 10 years ago

Am 21.03.2014 11:13, schrieb Jakob Hilden:

can you post the complete error message? also, can you provide me the corrupt zip file? and with your config.json file?

Sure. Attached...

Erik Krause Herchersgarten 1 79249 Merzhausen

jhilden commented 10 years ago

I don't think you can email files to github

ErikKrause commented 10 years ago

Am 21.03.2014 20:50, schrieb Jakob Hilden:

I don't think you can email files to github

Sorry, didn't know. Find it here : http://ge.tt/4z8SpNS1/v/0

Erik Krause Herchersgarten 1 79249 Merzhausen

jhilden commented 10 years ago

Thanks for providing those files, unfortunately I wasn't able to reproduce your issue. I took your config.json put it into the correct folder structure and successfully ran fontello convert on it (using ruby 1.9.3 or 2.1.1, on Ubuntu 64-bit and rubyzip 1.1.2). What setup do you have?

ErikKrause commented 10 years ago

Am 24.03.2014 10:01, schrieb Jakob Hilden:

Thanks for providing those files, unfortunately I wasn't able to reproduce your issue. I took your config.json put it into the correct folder structure and successfully ran fontello convert on it (using ruby 1.9.3 or 2.1.1, on Ubuntu 64-bit and rubyzip 1.1.2). What setup do you have?

I'm on windows 7 64-bit. May be that's the culprit, since x0D0A are windows line endings. Somehow the x0A must get converted to x0D0A during download, since if I download the zip manually anything is ok.

Erik Krause Herchersgarten 1 79249 Merzhausen

jhilden commented 10 years ago

I see. Unfortunately I don't have a windows machine for testing :( I fear I won't be able to help out any further in that case. Let me know if there is anything else I can help with or if somebody else is able to help with this issue.

ErikKrause commented 10 years ago

Am 24.03.2014 19:43, schrieb Jakob Hilden:

I see. Unfortunately I don't have a windows machine for testing :( I fear I won't be able to help out any further in that case.

A pity. Doing all steps manually is pretty tedious...

Most FTP clients have a feature to transfer either binary or change line endings from unix to windows style or vice versa. I don't know how the zip is downloaded from fontello, but I guess there is some ruby function. On http://www.ruby-doc.org/core-2.1.1/File/Constants.html I found: "BINARY disable line code conversion" ...

Erik Krause Herchersgarten 1 79249 Merzhausen

jhilden commented 10 years ago

I'm sure that there is a way in ruby, but I still have not way of testing it without a Windows machine.

I will gladly help out by explaining the code and I'm always open for pull requests, but I fear somebody else will have to step up for the actual implementation.

ErikKrause commented 10 years ago

Am 24.03.2014 20:22, schrieb Jakob Hilden:

I will gladly help out by explaining the code and I'm always open for pull requests, but I fear somebody else will have to step up for the actual implementation.

I guess opening the file in binary mode would help on any platform. At least it wouldn't harm. In PHP I'd write "fopen(, 'rb')" in order to open it for binary reading or "fopen(, 'wb+')" for binary reading, writing or creation.

According to http://www.ruby-doc.org/core-2.1.1/IO.html#method-c-new this should be similar in ruby, but I don't have any clue how to use it correctly. However, in master/lib/fontello_rails_converter/cli.rb line 30 you seem to use only "w+"...

Erik Krause Herchersgarten 1 79249 Merzhausen