Open Bhoft opened 6 years ago
Thank you for the reported issue. Would you like to help up to fix this issue by submitting a pull request? We have contributors guide that is a good starting point. If you need any tip – let us know.
java.io.FileNotFoundException: wampwwwyii2-app\web\assets\css\all-temp...
It seem there are missing the DIRECTORY_SEPARATOR.
The yuicompressor has the problem that "absolute paths" aren't working on Windows with the "current" version 2.4.8 for the output file (which is already 3 years old and it doesn't look like a newer release would happen anytime soon)
See this issue about this problem: https://github.com/yui/yuicompressor/issues/78
The Version 2.4.7 works without a problem but has of course issues which were fixed in the 2.4.8 release. So it would be good that the 2.4.8 version of the yuicompressor would also work on Windows.
A solution "could" be that the -o parameter of the shell exec uses a relative path instead of an absolute.
I tried to set the webroot alias "relative", so instead of
Yii::setAlias('@webroot', __DIR__ . '/web');
toYii::setAlias('@webroot', './web');
in the "assets.php" file for assetbundle generation callyii asset assets.php config/assets-dev.php
.The compressed css is then generated but all 'url' inside the css are wrong, so images and fonts aren't correctly included..
If the -o parameter for the yuicompressor would use a relative path instead of an absolute the generated would work also Windows machines.
So instead of
'{to}' => escapeshellarg($outputFile),
use this line'{to}' => escapeshellarg(substr($outputFile, strlen(Yii::getAlias('@app/')))),
on this line: https://github.com/yiisoft/yii2/blob/master/framework/console/controllers/AssetController.php#L549
So that the to output path would be
-o "web/assets/css/all-temp.css"
instead of-o "D:\wamp\www\yii2-app\web/assets/css/all-temp.css"
What steps will reproduce the problem?
create a asset bundle on console with yuicompressor version 2.4.8 on Windows.
What is the expected result?
a compressed css instead of an java exception.
What do you get instead?
java.io.FileNotFoundException: wampwwwyii2-app\web\assets\css\all-temp.css:\wamp\www\yii2-app\web\assets\css\all-temp.css.tmp (The filename, directory name, or volume label syntax is incorrect) at java.io.FileOutputStream.open0(Native Method) at java.io.FileOutputStream.open(Unknown Source)
Additional info