cjohansen / juicer

A command line tool for JavaScript and CSS developers
630 stars 47 forks source link

Merge to file on different drive causes error #23

Open LoveAndCoding opened 14 years ago

LoveAndCoding commented 14 years ago

I'm unsure whether or not to post this here or on the lighthouse tracker so I put it on both. Anyway, here is the issue:

Hi,

I've run into a small problem when merging my files into a file on a different drive. The process finishes successfully, but it throws an error at the end. I've copied the entire command that I used below:

    D:\Scripts\Google-Bump>juicer merge main.js -s -f -o %appdata%\Mozilla\Firefox\Profiles\eyo2kaec.default\gm_scripts\google_bump\google_bump.user.js
    C:/Ruby19/lib/ruby/gems/1.9.1/gems/juicer-1.0.3/lib/juicer.rb:61: warning: nested repeat operator + and ? was replaced with '*'
    C:/Ruby19/lib/ruby/gems/1.9.1/gems/juicer-1.0.3/lib/juicer.rb:61: warning: nested repeat operator + and ? was replaced with '*'
    C:/Ruby19/lib/ruby/gems/1.9.1/gems/juicer-1.0.3/lib/juicer.rb:61: warning: nested repeat operator + and ? was replaced with '*'
    C:/Ruby19/lib/ruby/gems/1.9.1/gems/juicer-1.0.3/lib/juicer.rb:61: warning: nested repeat operator + and ? was replaced with '*'
    Unable to access jarfile
    C:/Ruby19/lib/ruby/1.9.1/pathname.rb:742:in `relative_path_from': different prefix: "C:/" and "D:/Scripts/Google-Bump" (ArgumentError)
    from C:/Ruby19/lib/ruby/gems/1.9.1/gems/juicer-1.0.3/lib/juicer/command/util.rb:24:in `block in relative'
    from C:/Ruby19/lib/ruby/gems/1.9.1/gems/juicer-1.0.3/lib/juicer/command/util.rb:21:in `collect'
    from C:/Ruby19/lib/ruby/gems/1.9.1/gems/juicer-1.0.3/lib/juicer/command/util.rb:21:in `relative'
    from C:/Ruby19/lib/ruby/gems/1.9.1/gems/juicer-1.0.3/lib/juicer/command/merge.rb:126:in `execute'
    from C:/Ruby19/lib/ruby/gems/1.9.1/gems/cmdparse-2.0.2/lib/cmdparse.rb:438:in `parse'
    from C:/Ruby19/lib/ruby/gems/1.9.1/gems/juicer-1.0.3/lib/juicer/cli.rb:27:in `parse'
    from C:/Ruby19/lib/ruby/gems/1.9.1/gems/juicer-1.0.3/lib/juicer/cli.rb:37:in `run'
    from C:/Ruby19/lib/ruby/gems/1.9.1/gems/juicer-1.0.3/bin/juicer:6:in `<top (required)>'
    from C:/Ruby19/bin/juicer:19:in `load'
    from C:/Ruby19/bin/juicer:19:in `<main>'

It also should be noted that I am not using a minifier. I'm not sure if that affects this issue, but its probably worth noting. I am running the code without YUI compressor installed because I want the code to be readable when it comes out.

shiki commented 14 years ago

I'm also getting this error -- with Ruby 1.9.1 running on Ubuntu

cjohansen commented 14 years ago

This seems to be some kind of Windows path name issue. I don't have a working 1.9/Windows install available, and don't use Windows so any help in resolving this would be appreciated.

LoveAndCoding commented 14 years ago

I'll look into it and see what I can come up with, but I'm new to ruby so I'm not sure how much I'll be able to track down for sure... Though shiki says he was having issues in ubuntu to. I'll spin up a ubuntu vm and see if I can't reproduce it there too to see if its windows specific.

LoveAndCoding commented 14 years ago

Okay, the fix for it seems to be pretty simple. I just changed the relative method to resort to the full path if it cannot use the relative one. I'm not sure if that breaks it in other spots though. It allows me to run without error, though I still receive the 'unable to access jar file'.

Here is the fix I implemented.

Change: path.relative_path_from(reference_path).to_s

To: begin path.relative_path_from(reference_path).to_s rescue ArgumentError path.realpath() end

And the full transcript of a run this time: D:\Scripts\Google-Bump>juicer merge main.js -s -f -o %appdata%\Mozilla\Firefox\Profiles\eyo2kaec.default\gm_scripts\google_bump\googlebump.user.js C:/Ruby19/lib/ruby/gems/1.9.1/gems/juicer-1.0.3/lib/juicer.rb:61: warning: nested repeat operator + and ? was replaced with '' C:/Ruby19/lib/ruby/gems/1.9.1/gems/juicer-1.0.3/lib/juicer.rb:61: warning: nested repeat operator + and ? was replaced with '' C:/Ruby19/lib/ruby/gems/1.9.1/gems/juicer-1.0.3/lib/juicer.rb:61: warning: nested repeat operator + and ? was replaced with '' C:/Ruby19/lib/ruby/gems/1.9.1/gems/juicer-1.0.3/lib/juicer.rb:61: warning: nested repeat operator + and ? was replaced with '_' Unable to access jarfile Produced C:/Users/Android/AppData/Roaming/Mozilla/Firefox/Profiles/eyo2kaec.default/gm_scripts/google_bump/google_bump.user.js from header.js image-store.js options-store.js helper-functions.js media-embed.js style-assignment-header.js assign-style-center.js center-styles.css assign-style-classic.js classic-styles.css assign-style-color.js color-picker.css assign-style-column.js column-styles.css assign-style-dock.js dock-styles.css assign-style-gen.js general-styles.css assign-style-media.js media-styles.css assign-style-multi.js multisearch-styles.css stylesheet-store.js style-functions.js update.js color-picker.js dialog-pieces.js dialogs.js dialog-functions.js shortcuts.js multisearch.js text-functions.js visual-functions.js video-extraction.js video-search.js video-functions.js image-search.js image-functions.js wiki-functions.js main.js

shiki commented 14 years ago

Also, I think maybe this is just for Ruby 1.9.1. I have a VM here with Ruby 1.8.7 and it seems to be working fine.

cjohansen commented 14 years ago

Thanks, that looks sensible. I don't have access to a Windows machine until monday. Could you try something for me?

D:\>java -cp C:\location\of\juicer\bin -jar yui-compressor.jar

Does that help with the "unable to access jar file" error? If so, I can patch these two issues up and do a release next week.

LoveAndCoding commented 14 years ago

The unable to access jar seems to have stemmed from my not having install YUI compressor at all. Installing it via juicer fixed my error. Seems to have been unrelated.