Open altearius opened 11 years ago
I have encountered this as well. BTW, this seems to be a Windows-specific issue. Mac (and Linux, I guess) are fine.
@Leonya Thanks - I was wondering why I wasn't able to reproduce it! :+1:
Yeah, this version fails on Windows. I was testing to hopefully close an issue that should be fixed by this release and got super confused. I thought it was operator error. From within the ant task, I get this:
-css:
[echo] Concatenating any @imports...
[copy] Copying 1 file to C:\Documents and Settings\larser\My Documents\proj
ects\html5-boilerplate\intermediate\css
[echo] NOT Processing LESS CSS
[echo] NOT Processing SASS (SCSS) CSS
[echo] Minifying css...
[apply] java.io.FileNotFoundException: Documents and SettingslarserMy Docume
ntsprojectshtml5-boilerplateintermediatecssstyle-concat.min.css:\Documents and S
ettings\larser\My Documents\projects\html5-boilerplate\intermediate\css\style-co
ncat.css (The filename, directory name, or volume label syntax is incorrect)
[apply] at java.io.FileOutputStream.open(Native Method)
[apply] at java.io.FileOutputStream.<init>(FileOutputStream.java:212)
[apply] at java.io.FileOutputStream.<init>(FileOutputStream.java:104)
[apply] at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompr
essor.java:208)
[apply] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[apply] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
sorImpl.java:57)
[apply] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
hodAccessorImpl.java:43)
[apply] at java.lang.reflect.Method.invoke(Method.java:601)
[apply] at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.ja
va:21)```
I don't have ready access to a Windows box these days to check this - could one of you try using the forward slashes (/) as you specify the path? I realize it's not a great solution, but I'm wondering if it's at least viable until the root cause is dug out.
I'm using it from within Ant and on a project that has users on every platform and of every skill level, so it's not a solution for me. That said, I can test it out if that will help discover the root cause.
@roblarsen Agreed, this isn't meant to be a solution so much as analysis.
Several variations. All failed. Windows 8/Powershell.
PS C:\Users\Rob\Documents\GitHub\html5-boilerplate\build> java -jar "tools/yuicompressor-2.4.8.jar" "C:\Users\Rob\Documents\GitHub\html5-boilerplate\js\main.js" --charset UTF-8 --type js -o "C:/Users/Rob/Documents/GitHub/html5-boilerplate/js/output.js"
C:/Users/Rob/Documents/GitHub/html5-boilerplate/js/output.js [Ljava.lang.String;@40442b95
java.io.FileNotFoundException: \Users\Rob\Documents\GitHub\html5-boilerplate\js\output.js:\Users\Rob\Documents\GitHub\ht
ml5-boilerplate\js\main.js (The filename, directory name, or volume label syntax is incorrect)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:212)
at java.io.FileOutputStream.<init>(FileOutputStream.java:104)
at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompressor.java:184)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21)
PS C:\Users\Rob\Documents\GitHub\html5-boilerplate\build> java -jar "tools/yuicompressor-2.4.8.jar" "C:/Users/Rob/Docume
nts/GitHub/html5-boilerplate/js/main.js" --charset UTF-8 --type js -o "C:/Users/Rob/Documents/GitHub/html5-boilerplate/j
s/output.js"
C:/Users/Rob/Documents/GitHub/html5-boilerplate/js/output.js [Ljava.lang.String;@40442b95
java.io.FileNotFoundException: \Users\Rob\Documents\GitHub\html5-boilerplate\js\output.js:\Users\Rob\Documents\GitHub\ht
ml5-boilerplate\js\main.js (The filename, directory name, or volume label syntax is incorrect)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:212)
at java.io.FileOutputStream.<init>(FileOutputStream.java:104)
at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompressor.java:184)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21)
PS C:\Users\Rob\Documents\GitHub\html5-boilerplate\build> java -jar "tools/yuicompressor-2.4.8.jar" "/Users/Rob/Document
s/GitHub/html5-boilerplate/js/main.js" --charset UTF-8 --type js -o "/Users/Rob/Documents/GitHub/html5-boilerplate/js/ou
tput.js"
/Users/Rob/Documents/GitHub/html5-boilerplate/js/output.js [Ljava.lang.String;@c324b85
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21)
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:604)
at java.util.ArrayList.get(ArrayList.java:382)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.getToken(JavaScriptCompressor.java:578)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.printSymbolTree(JavaScriptCompressor.java:1094)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.compress(JavaScriptCompressor.java:556)
at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompressor.java:187)
... 5 more
PS C:\Users\Rob\Documents\GitHub\html5-boilerplate\build> java -jar "tools/yuicompressor-2.4.8.jar" "../js/main.js" --ch
arset UTF-8 --type js -o "../js/output.js"
../js/output.js [Ljava.lang.String;@39fc0f04
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21)
Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:604)
at java.util.ArrayList.get(ArrayList.java:382)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.getToken(JavaScriptCompressor.java:578)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.printSymbolTree(JavaScriptCompressor.java:1094)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.compress(JavaScriptCompressor.java:556)
at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompressor.java:187)
... 5 more```
Let me know if you need anything else. I'll take a look myself, tomorrow. Of course I can't guarantee much since I've written about 5 lines of Java ever, but at least I've got a Windows machine to test this issue against.
The above commit fixes it. It was pure repo/diff detective work and not me actually knowing my ass from my java elbow, so I'm not sure if there's something I'm missing (there probably is :thumbsup: )
@roblarsen Great find - that line will create other problems, but now I know where to go looking. Thanks - I should have something for you to test before the weekend, if you're amenable.
Sure. Just let me know.
I'm experiencing the same issue. All absolute paths not working, it seems to mangle the output and input paths together.
It occurs to me the new pattern replacement syntax includes the colon as a separator, which is a reserved path character on windows, which is probably the root of the problem.
Is there any fix yet?
any timeline for this?
I will be testing this patch as soon as I have restored my machine to working order, it has temporarily run out of magic smoke. Sorry for the delay.
Same problem here. I would vote for fixing this if I could ;-)
The problem still exists in 2.4.8 (or got back don't know). Just created a workaround for the problem:
snip
Too fast. The workaround does not work either :-(
Hi guys,
issue ist still persistent (after 1 1/2 year). Do you have any plans to fix this at all? Would be very sad to see Windows Support dropped which currently is the case.
Thx and brgds
Jan
Brutal.
At the end of the day this one needs some TLC from a Windows developer. I don't do development on Windows, so I don't have ready access to the only OS where this problem presents itself. If one of you has the time to put some effort into a patch, I'd invite the assistance.
Before I move onto bolting another tool into a project I thought was stable, is there officially no longer any support for this tool for Windows? If there's no desire to support Windows you should document it as such so people aren't mislead into thinking this is a cross platform tool.
There's plenty of desire; I would love it if YUICompressor continued to work on Windows platforms. However, I don't actively use Windows, and so it's very difficult for me to test and develop Windows specific issues. If you're a Windows developer and can provide a PR that fixes this bug without breaking anything else, I heartily welcome your participation! :+1:
Desire is great, but as far as I can see if you can't support Windows, then the project can't support Windows. It's no longer a cross platform tool.
It was fun while it lasted.
Well, it's an open source project; the Contributor Model around which YUICompressor is shaped really doesn't call for me to be the sole developer on the project.
I do understand the frustration, and wish there were more people willing to contribute code so YUICompressor could progress more rapidly - until then, I'll continue to work my best to support you guys, and contributions are ALWAYS welcome.
I understand what you're going through. Believe me. The last thing I want to do is come on someone's repo and complain about bugs not being fixed. I've been on the other end of that enough to not want to be that guy. That said, I've got my own bugs to clear and to do so I need clarity and/or closure on this issue. Since it's going to remain open until the Java versions of Larry Bird walks through the door, I'm going to have to solve it in some other way.
Rob. You made your point.
Temporary fix for Windows (2.4.8)
Use relative path for output
java.exe -jar "C:\YUI Compressors\yuicompressor-2.4.8.jar" "C:\some path\with spaces\bootstrap.css" -o "output\bootstrap.min.css" -v --preserve-semi --charset utf-8
Compressed files will be in "C:\YUI Compressors\output\bootstrap.min.css"
Am I missing something here? Didn't @maskamar fix this issue a year and a half ago with 350933e2ef1651b3631ea4b1898b8e40f9f18aaf? In our product build, 2.4.8 fails on Windows with absolute paths but yuicompressor built from master seems to handle them fine. Any further fixes or testing required before closing this issue?
There is a feature that cause this problem.
"-o outfile ... Supports a filter syntax for expressing the output pattern when there are multiple input files. ex: java -jar yuicompressor.jar -o '.css$:-min.css' *.css ... will minify all .css files and save them as -min.css"
This feature splits output path with colon and handle it like multiple input files. So C:\somename.css is split to C and \somename.css and then something wrong happen with output path (I don't know exactly what).
I added condition to prevent this feature for path starting with c:\ (and also for other letters). Yeah, it is that simple.
I also fixed issue https://github.com/yui/yuicompressor/issues/130 with https://github.com/yui/yuicompressor/commit/98eb2c0e6632bc26a274af7478d3c0ce44544981 no one cares and people still have those problems. :-1:
Well, @maskamar, I care. We use a very old version of this library in our build, I attempted an upgrade, encountered this issue, and cloned the repo looking to fix the problem myself... but, of course, you already took care of it. Thank you for that!
Perhaps the fix wasn't noticed because this issue was left open with no reference to your commit? Regardless, I'd be happy to help push out a new release (2.4.9?) to get your fixes and others to the community.
@maskamar It's untrue that no one cares; however, as @labkey-adam notes, there's nothing in here that shows me your suggested fix, so I'm not sure what you would like me to do? There was a period of time where a mistake by the Yahoo folks unassigned all tickets away from me, and GitHub didn't notify me, so it took a few months for me to notice it had happened. Perhaps you sent a PR in that timeline and then retracted it or something?
Those who are still having the same problem, seems they just download from outdated binary releases / not compile it by hand. Here to test, compiled version from OSX 10.11 & Windows 10 with Ant 1.9.4 & jdk-8u66-64 from latest commits in this repo. Once it run without this bugs, please start to replace old 2.4.8 zip released, so peoples can instantly download & run it without any problem.
Ok so was having this same issue, have a temp solution for windows issue....
cd "%Full-path-to-output-folder%" java -jar %full-path-to\yuicompressor-2.4.8.jar% %Full-path-to-input-file-demo.js% -o demo.min.js
Hopefuly this helps someone else for now.
Just ran into this issue.
These comments were helpful to me to find out why the problem exists to begin with - especially comment by maskamar on oct 31, 2015. Since the new code is not yet jar'd, I downloaded the fixed source and used ant 1.10.1 to build it. It produced version yuicompressor-2.4.9. jar which I have used for a few days with no problems. The absolute path issue is gone.
In my copy, I also updated the --help option under -o \<file> to reflect the fact that this version does not support split filter syntax for absolute paths that start with drive name and a ":", such as C:\dir\filename.js etc.
Thanks for the useful comments. BTW, the link in cecekpawon Oct 31, 2015 comment is broken.
Would 2.4.9 be officially released any time soon?
Since the last release (2.4.8) was four years ago, I wouldn't hold my breath. I don't know for sure, but I would guess that YUI Compressor is included as part of this announcement: https://yahooeng.tumblr.com/post/96098168666/important-announcement-regarding-yui
Since you seem to have a working build of 2.4.9, perhaps you should fork the project and make your build more generally available. If you do so, it will probably be the most meaningful advance of YUI in years.
@altearius
I've made enhancements in yuicompressor-2.4.9 to solve the (colon ':' in file/pathname ) problem in a more generic way. The fix in this release is adding a new option -s <char>
where char is a new character used (in place of ':') for splitting output file name. For example if we chose "@" as the new character, one can safely use the following to process a batch of javascript files:
java -jar yuicompressor-2.4.9.jar -s @ -o ".js$@-min.js" C:\dir\*.js
or in a single file compression scenario:
java -jar yuicompressor-2.4.9.jar -s @ -o C:\dir1\outfile.js C:\dir2\infile.js
So the -s option now appears to solve the issues that were discussed on this forum. I have also added two other options:
-w, --no-style-warning
to suppress coding style warnings generated by the compressor, such as,
"[WARNING] Using 'eval' is not recommended." After all, why should a compressor complain about coding style?
-W, --no-warning
to suppress all warnings. Good when compressing third party code.
-v, --verbose
was also enhanced and is more verbose and actually useful now.
Usage() is also updated. I have tested it on over 100 files under windows and unix shell and It is working as advertised. I am not a pro githubber and haven't done any forks here. But I have the modified sources and the new yuicompressor-2.4.9.jar
available on this link for whoever can take it over and make it an official release, or if you just want to download and use it.
Reg,
Brad
CC: @maskamar, @tml , @roblarsen , @Leonya , @labkey-adam
@altearius Fejlesztéseket végeztem a yuicompressor-2.4.9-ben, hogy általánosabb módon oldjam meg a (kettőspont ':' a fájl/elérési útnévben) problémát. Ebben a kiadásban a javítás egy új beállítást ad,
-s <char>
ahol a char egy új karakter, amelyet (a „:” helyett) használnak a kimeneti fájlnév felosztására. Például, ha a "@"-t választottuk új karakterként, biztonságosan használhatja a következőket egy köteg JavaScript-fájl feldolgozásához:
java -jar yuicompressor-2.4.9.jar -s @ -o ".js$@-min.js" C:\dir\*.js
vagy egyetlen fájl tömörítési forgatókönyv esetén:
java -jar yuicompressor-2.4.9.jar -s @ -o C:\dir1\outfile.js C:\dir2\infile.js
Tehát úgy tűnik, hogy a -s opció megoldja a fórumon megvitatott problémákat. Két további lehetőséget is hozzáadtam:
-w, --no-style-warning
a tömörítő által generált kódolási stílus figyelmeztetések elnyomására, például: "[FIGYELMEZTETÉS] Az "eval" használata nem javasolt." Végül is miért panaszkodhatna egy kompresszor a kódolási stílusra?
-W, --no-warning
hogy elnyomjon minden figyelmeztetést. Harmadik fél kódjának tömörítéséhez jó.
-v, --verbose
is továbbfejlesztett, és bőbeszédűbb, és most már valóban hasznos.A Usage() is frissül. Több mint 100 fájlon teszteltem Windows és unix shell alatt, és a hirdetett módon működik. Nem vagyok profi githubber, és nem csináltam itt semmilyen fork-ot. De ezen a linken
yuicompressor-2.4.9.jar
elérhetőek a módosított források és az új, aki át tudja venni és hivatalos kiadássá tudja tenni, vagy csak letölteni és használni szeretné. Reg, BradCC:@maskamar,@tml,@roblarsen,@Leonya,@labkey-adam
can you send me the jar file?
In 2.4.7, it was possible to specify an absolute path for the output file. Attempting to do this in 2.4.8 causes the following error: