Open rafal-kos opened 6 years ago
Thanks for opening the issue, I‘ll push a branch some time soon and then would like to ask you to test if it works for you.
OK. Thanks for info.
I require your help to get the tool working on windows.
Can you please install the win-compatibility
branch and let me know how that works?
composer remove --dev mage2tv/magento-cache-clean
composer require --dev mage2tv/magento-cache-clean:dev-win-compatibility
I expect a new error to occur. I'll try to fix one after the other until it works on windows too. Please be patient with me until it works. I appreciate your help.
I checked the new branch. Still the same issue :
[ERROR] Command failed: php -r 'echo json_encode((require "D:\projects\example\magento/app\etc\env.php") ?? []);'
I see in file system.cljs
(defn- win? []
(= "win32" (.-platform process)))
On my machine I am using GIT Bash (mingw64). Maybe different platform is used here? Any chance to add some debug here?
According to the documentation win32
is the operating identifier returned by nodejs on any windows host.
You can see the value on your host by running the following command in your teminal
node -e 'console.log(process.platform)'
Got info from third party using Win10:
aaron@AVALANCHE MINGW64 ~
$ node -e 'console.log(process.platform)'
win32
Yes. It looks the same on my machine. Any chance to get not minified cache-clean.js? I tried to build it on WIN without success.
I've pushed an update to the win-compatibility
branch.
This time all file system methods get path arguments on windows with backslashes instead of slashes.
There still might be other issues though.
Could you please do me a favor and update the branch again?
composer remove --dev mage2tv/magento-cache-clean
composer require --dev mage2tv/magento-cache-clean:dev-win-compatibility
Please also run cache-clean.js --version
to confirm the correct build is being used. It should display the release name 0.0.22-dev-win-compat
.
I can look into creating an un-minified build, but right now I don't have the time.
OK. There is still the same problem. I had some time to make some debug. So... problem is not directly with path but how the php is processed from the windows cmd.exe. cmd.exe is run when you call child_process.execSync(cmd)
On windows this one will not work :
php -r 'echo json_encode((require "D:\projects\example\magento\app/etc/env.php") ?? []);'
when this one works fine :
php -r "echo json_encode((require 'D:\projects\example\magento\app/etc/env.php') ?? []);"
After changing the command and running bin/cache-clean.js
cache was cleaned up 😃
Problem is when I ran bin/cache-clean.js -w
. Below the error
[ERROR] Command failed: php -r 'require "D:\projects\example\magento\vendor/autoload.php"; foreach ((new \Magento\Framework\Component\ComponentRegistrar)->getPaths("module") as $m) echo $m.PHP_EOL;'
In this case I suppose that you have to change slightly how the commands are run on windows. I would like to help more but closure is just out of my scope 😄
Thanks for the input! So executed command arguments have to be quoted with double strings. That sounds possible. I'll see that I get a version ready some time soon that does that.
Okay, so I threw away the slash-to-backslash in file system paths conversion code, and instead made command line arguments to php
be wrapped in double quotes.
Can you please update the dev-win-compatibility
branch and give it another go?
👍 it works almost perfect but.. still problem with --watch. Below the command
php -d display_errors -r "require 'D:\projects\example\magento/vendor/autoload.php'; foreach ((new \Magento\Framework\Component\ComponentRegistrar)->getPaths('module') as \$m) echo \$m.PHP_EOL;"
and error I am receiving
Parse error: syntax error, unexpected '$m' (T_VARIABLE), expecting identifier (T_STRING) in Command line code on line 1
Thanks for trying that out. Interesting.
When I run that exact command on OS X or Linux it works.
Maybe the $
of $m
has to be escaped with a different character than \
on windows? Or maybe it doesn't have to be escaped at all?
In my shell it is required so it isn't interpreted as a bash variable that needs to be interpolated into the string.
After a bit of googling it seems like it might be the ^
character.
Could you please try running the command?
php -d display_errors -r "require 'D:\projects\example\magento/vendor/autoload.php'; foreach ((new \Magento\Framework\Component\ComponentRegistrar)->getPaths('module') as ^$m) echo ^$m.PHP_EOL;"
I've got this error then :
Parse error: syntax error, unexpected '^' in Command line code on line 1
This command works fine :
php -d display_errors -r "require 'D:\projects\example\magento/vendor/autoload.php'; foreach ((new \Magento\Framework\Component\ComponentRegistrar)->getPaths('module') as $m) echo $m.PHP_EOL;"
Is there a need for \ or ^?
Well, that’s what I’m trying to figure out.
I know the $
needs quoting on unix systems.
Can you try running the command without any quotes for the $
and let me know if that works on windows?
As I said in my last comment. It works fine without "\" and I see list of directories in output.
Oh, I didn't see that part, sorry. Thanks for your answer, I'll remove the quoting of the $
on windows.
New build available on the win-compatibility
branch without quoting of PHP variables in command line arguments on windows.
Hope this solves the issue of executing PHP on windows finally.
OK. Cleaning speciific type of cache is working fine. Now I am testing "watch" action. For now I few times this kind of issue
Error: ENOENT: no such file or directory, unlink 'D:\projects\example\magento\generated\code\Vendor\Module\Controller\Adminhtml\Artist\Edit\Interceptor.php'
at Object.fs.unlinkSync (fs.js:1061:18)
at Jh (D:\projects\example\magento\vendor\mage2tv\magento-cache-clean\bin\cache-clean.js:318:201)
at D:\projects\example\magento\vendor\mage2tv\magento-cache-clean\bin\cache-clean.js:303:275
at Xc (D:\projects\example\magento\vendor\mage2tv\magento-cache-clean\bin\cache-clean.js:103:185)
at Nd.f.ca (D:\projects\example\magento\vendor\mage2tv\magento-cache-clean\bin\cache-clean.js:126:67)
at eb (D:\projects\example\magento\vendor\mage2tv\magento-cache-clean\bin\cache-clean.js:104:349)
at og (D:\projects\example\magento\vendor\mage2tv\magento-cache-clean\bin\cache-clean.js:303:238)
at yk (D:\projects\example\magento\vendor\mage2tv\magento-cache-clean\bin\cache-clean.js:399:271)
at D:\projects\example\magento\vendor\mage2tv\magento-cache-clean\bin\cache-clean.js:400:101
at FSWatcher.<anonymous> (D:\projects\example\magento\vendor\mage2tv\magento-cache-clean\bin\cache-clean.js:320:138
After checking the path file was deleted but watcher was stopped and I had to run it again.
I will do more tests next week and probably be back in case of any additional issues.
Cool, one step further towards supporting windows 👍
Thanks for your help.
I wonder why the file already was gone by the time fs.unlinkSync
is called.
As a reference for myself, maybe this is helpful: https://stackoverflow.com/a/20801823/485589
@rafal-kos Any news on this topic by chance? I could wrap the unlink in a check to see if the file still exists. When does that exception occur? When changing a file?
I added regexes that match file paths with backslashes instead of regular slashes, added a check if a file exists before unlinking it, and merged the result into master and published it as release 0.0.25
.
It would be cool if you could try how that works for you...
Sorry for late response but I didn't had time to check it. I have installed latest version from master branch. No error about missing file but I suppose it doesn't work correctly. Example output of command run with options "-w -vv":
Processing D:\projects\example\app\code\Vendor\Artist/view\adminhtml\ui_component\artist_form.xml
Cleaning id(s): ui_component_configuration_data_artist_form
Cache storage {:backend Cm_Cache_Backend_File, :cache_dir D:\projects\example/var/cache}
Processing D:\projects\example\app\code\Vendor\Artist/view\adminhtml\ui_component
Processing D:\projects\example\app\code\Vendor\Artist/view\adminhtml\ui_component\artist_form.xml
Cleaning id(s): ui_component_configuration_data_artist_form
Cache storage {:backend Cm_Cache_Backend_File, :cache_dir D:\projects\example/var/cache}
Processing D:\projects\example\app\code\Vendor\Artist/view\adminhtml\ui_component
Processing D:\projects\example\app\code\Vendor\Artist/view\adminhtml\ui_component
Processing D:\projects\example\app\code\Vendor\Artist/view\adminhtml\ui_component\artist_form.xml
Cleaning id(s): ui_component_configuration_data_artist_form
Cache storage {:backend Cm_Cache_Backend_File, :cache_dir D:\projects\example/var/cache}
Processing D:\projects\example\app\code\Vendor\Artist/view\adminhtml\ui_component
Processing D:\projects\example\app\code\Vendor\Artist/view\adminhtml\ui_component
Processing D:\projects\example\app\code\Vendor\Artist/view\adminhtml\ui_component\artist_form.xml
Cleaning id(s): ui_component_configuration_data_artist_form
Cache storage {:backend Cm_Cache_Backend_File, :cache_dir D:\projects\example/var/cache}
Processing D:\projects\example\app\code\Vendor\Artist/view\adminhtml\ui_component
Processing D:\projects\example\app\code\Vendor\Artist/view\adminhtml\ui_component
Processing D:\projects\example\app\code\Vendor\Artist/etc\adminhtml\menu.xml
Processing D:\projects\example\app\code\Vendor\Artist/etc\adminhtml
Processing D:\projects\example\app\code\Vendor\Artist/view\adminhtml\ui_component\artist_form.xml
Cleaning id(s): ui_component_configuration_data_artist_form
Cache storage {:backend Cm_Cache_Backend_File, :cache_dir D:\projects\example/var/cache}
Processing D:\projects\example\app\code\Vendor\Artist/view\adminhtml\ui_component
Processing D:\projects\example\app\code\Vendor\Artist/view\adminhtml\ui_component
Processing D:\projects\example\app\code\Vendor\Artist/view\adminhtml\ui_component\artist_form.xml
Cleaning id(s): ui_component_configuration_data_artist_form
Cache storage {:backend Cm_Cache_Backend_File, :cache_dir D:\projects\example/var/cache}
Processing D:\projects\example\app\code\Vendor\Artist/view\adminhtml\ui_component
After change in ui component or menu file I see info about processing but cache is not cleared.
For example I am changing title in menu.xml. I see "processing" output but no info about clearing of cache.
Thanks for trying out the new version and giving an update @rafal-kos!
In order to be able to work on windows support more effectively I'll add a new trace
log level that will give more details when enabled with -vvv
.
Also, could you please try editing a di.xml
file?
The difference is that editing ui_component
files clears a single cache ID, while editing a di.xml
file will clear the whole config
cache segment.
Thanks for your help.
Update to the win-compatibility
branch pushed.
When you have a moment, please update with
composer remove --dev mage2tv/magento-cache-clean
composer require --dev mage2tv/magento-cache-clean:dev-win-compatibility
Then check the release matches this:
$ cache-clean.js --version
Release 0.0.27-dev-win-compat sponsored by https://www.mage2.tv
0.0.27-dev-win-compat
If that is true, please run the command with the -w -vvv
options to enable trace level logging.
Then edit a ui_component
XML file and a di.xml
file and post the (probably long) output here in the thread.
Again, thank you for your help, I appreciate you doing that.
Still the same :(
First I am changing the ui_component XML file. Output :
Watcher initialized (Ctrl-C to quit)
Processing D:\projects\magento\app\code\Vendor\Artist/view\adminhtml\ui_component\artist_form.xml
Cleaning id(s): ui_component_configuration_data_artist_form
Cache storage {:backend Cm_Cache_Backend_File, :cache_dir D:\projects\magento/var/cache}
Delete cache record if exists: D:\projects\magento/var/cache/mage--3/mage---fa7_UI_COMPONENT_CONFIGURATION_DATA
_ARTIST_FORM
Then some changes in di.xml is done. Output :
Processing D:\projects\magento\app\code\Vendor\Artist/view\adminhtml\ui_component
Processing D:\projects\magento\app\code\Vendor\Artist/view\adminhtml\ui_component
Processing D:\projects\magento\app\code\Vendor\Artist/etc\di.xml
Processing D:\projects\magento\app\code\Vendor\Artist/etc
I don't see any change on form after reloading the page.
@rafal-kos Thanks again for your help and your patience.
The paths still contain forward slashes. I'll focus next on making them consistent - then the regex to fingerprint the file names should work more reliable.
I've updated the win-compatibility branch accordingly.
The release string now is 0.0.28-dev-win-compat
For reference, to install the current version of the branch, please use:
composer remove --dev mage2tv/magento-cache-clean
composer require --dev mage2tv/magento-cache-clean:dev-win-compatibility
@rafal-kos Can you please try it when you get a chance and let me know if there is some progress?
Thank you!
The cache-clean.js utility seems to now work on windows (since release 0.0.37), at least under some circumstances. Reference issue #32
It would be great if I could get confirmation from others using a windows based development environment!
I'm back to this topic. I have installed latest version. Still some issues. For example I have made some changes in ui component xml (artist_listing.xml). In output I see this :
Cleaning id(s): ui_component_configuration_data_artist_listing
but after reload I still see old content. In var/cache/mage--a/mage---608_UI_COMPONENT_CONFIGURATION_DATA_ARTIST_LISTING file is still existing.
Also changes in etc/di.xml or etc/adminhtml/system.xml are not reloading the cache. Nothing in output.
Hi @rafal-kos, I'm happy you are back on this topic, welcome back!
When you say "the latest version", which version is this?
Can you please also post your cache related configuration in app/etc/env.php
?
Thanks!
@Vinai ./vendor/bin/cache-clean.js -v
gives me this output :
Release 0.0.37 sponsored by https://www.mage2.tv
In app/etc/env.php
I have nothing regarding the cache. As I understand magento in this case is using file system for cache storage. I can check with db for example just to see if this is related for file system.
No, you are right - no cache configuration in app/etc/env.php
means the file system cache storage is used.
Okay, next question.
If you run the watcher with the -vv
flag to enable debug output, there is a line that reads something like: Calculated default cache ID prefix <id-prefix> from <path>
.
Can you please let me know what the <path>
is in your case?
Thanks!
Example output :
Magento dir D:\projects\projekty\project_name\magento
Flushing all caches
Using :default cache_backend
Calculated default cache ID prefix f78_ from D:\projects\projekty\project_name\magentoapp/etc/
Cache storage {:backend Cm_Cache_Backend_File, :cache_dir D:/projects/projekty/project_name/magento/var/cache, :id_prefix f78_}
Cleaning dir D:/projects/projekty/project_name/magento/var/cache/
Using :page_cache cache backend
Cache storage {:backend Cm_Cache_Backend_File, :cache_dir D:/projects/projekty/project_name/magento/var/page_cache, :id_prefix f78_}
Cleaning dir D:/projects/projekty/project_name/magento/var/page_cache/
This path D:\projects\projekty\project_name\magentoapp/etc/
looks strange. Maybe some issue here?
It does indeed. There is at least one bug in there that’s already fixed. Could you please upgrade to release 0.0.40 and check again? At least the missing directory separator between magento and app should be there then.
Hello,
I am trying to run the tool on windows Git Bash :
vendor/bin/cache-clean.js config full_page
but in result I have this error :[ERROR] Command failed: php -r 'echo json_encode((require "D:\projects\example\magento/app/etc/env.php") ?? []);'
Looks like there a problem with slash. When I run this command
php -r 'echo json_encode((require "D:/projects/example/magento/app/etc/env.php") ?? []);'
I am getting correct results.Is it possible to get some fix for hat? Thanks in advance.