ast-grep / ast-grep-vscode

ast-grep VSCode is a structural search and replace extension for many languages.
https://marketplace.visualstudio.com/items?itemName=ast-grep.ast-grep-vscode
MIT License
158 stars 12 forks source link

Does not work on windows / global npm installation #235

Open hediet opened 7 months ago

hediet commented 7 months ago

I like the idea of this extension! Unfortunately, I didn't manage to get it working.

5x2ckzh57i

Version: 1.88.0-insider (user setup) Commit: be210b3a60c7d60030c1d3d92da00d008edf6ab9 Date: 2024-03-15T05:48:19.790Z Electron: 28.2.6 ElectronBuildId: 27476517 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Windows_NT x64 10.0.22631

Code_-_Insiders_GQMp8C1F7T

HerringtonDarkholme commented 7 months ago

Using pwsh may be the problem. Would you like install it via cmd? by default the command is ast-grep.exe on windows. you can tweak it via https://github.com/ast-grep/ast-grep-vscode?tab=readme-ov-file#extension-settings

hediet commented 7 months ago

I think npm/yarn just don't generate any .exe files. Neither for PWSH nor CMD.

Code_-_Insiders_Sesd5KgYZE

HerringtonDarkholme commented 7 months ago

It should be fixed in 0.1.3! Thanks for reporting!

hediet commented 7 months ago

Still does not work :/

image

Also, when I click x in that dialog, it wants to open a website, which is quite annoying.

HerringtonDarkholme commented 7 months ago

weird, @hediet would you like to confirm if this is caused by VSCode not picking up npm?

Say, you can change the serverPath to the absolute path to ast-grep binary installed globally? Thanks!

HerringtonDarkholme commented 7 months ago

I tried on my windows machine by installing nodejs via its official website. then I installed npm install @ast-grep/cli -g in the vanilla command prompt. I did find some issues about vcruntime140.dll but after I installed vc redistribution package the DLL is okay.

Then ast-grep vscode can work properly.

image
hediet commented 7 months ago

Code_-_Insiders_T2r5wbNpUr

Code_-_Insiders_wujghlu60n

I suggest to show more error details, so that debugging is easier.