Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in vscode extension on windows, I get 'D2.<command>' not found #74

Closed
imding opened this issue Apr 7, 2023 · 29 comments
Closed

in vscode extension on windows, I get 'D2.<command>' not found #74

imding opened this issue Apr 7, 2023 · 29 comments

Comments

@imding
Copy link

imding commented Apr 7, 2023

it happens whenever I try to preview or compile to svg.

@imding imding changed the title on windows, I get 'D2.<command>' not found in vscode extension on windows, I get 'D2.<command>' not found Apr 7, 2023
@alixander alixander transferred this issue from terrastruct/d2 Apr 7, 2023
@alixander
Copy link
Contributor

related: #73

@gavin-ts
Copy link
Contributor

gavin-ts commented Apr 7, 2023

I can't reproduce this issue on my machine, are you able to reproduce this on windows @BarryNolte ?

@gavin-ts
Copy link
Contributor

gavin-ts commented Apr 7, 2023

@imding if you use vscode menubar Help->Toggle Developer Tools do you see any error messages in the console?

@BarryNolte
Copy link
Collaborator

BarryNolte commented Apr 7, 2023

@gavin-ts I'm not seeing anything. I built the vsix based on master and installed it, no obvious problems on Windows or Linux. I brought up dev tools and didn't see anything there either. Next bit of troubleshooting is, what extensions are installed (@imding . @quixoticaxis)? And what version of vscode, there was just an update.

@quixoticaxis
Copy link

I'm using the latest Windows VSCode version (1.77.1).
Dev tools show the following line: mainThreadExtensionService.ts:112 Activating extension 'Terrastruct.d2' failed: File URL path must be absolute.

@gavin-ts
Copy link
Contributor

gavin-ts commented Apr 7, 2023

@BarryNolte I wonder if it is related to the esmoduleinterop change, and if this could fix it: 15d75d6 . but until we can reproduce the issue we won't be able to confirm the fix.
I was looking at the changes between master and 57d6782 and this seems like an option

@BarryNolte
Copy link
Collaborator

@gavin-ts This seems to be a likely culprit. The only time I've had extensions fail to load, it's something like an imported module failing to load.

@gavin-ts
Copy link
Contributor

gavin-ts commented Apr 7, 2023

This looks like a similar issue: microsoft/vscode-go#1386 (comment)

@BarryNolte
Copy link
Collaborator

Maybe, but given the bug is 5 years old, I don't know. How about we try the change you made, and if it still works in our machines, at least we know it wasn't made worse.

@gavin-ts
Copy link
Contributor

gavin-ts commented Apr 8, 2023

ok we can see if it is fixed in 0.8.5

@quixoticaxis
Copy link

@gavin-ts 0.8.5 still does not work the same as 0.8.4 (URL path must be absolute).

@quixoticaxis
Copy link

quixoticaxis commented Apr 8, 2023

Extension works on Linux for me, so something is probably OS related.

I'm currently on Windows 11 (10.0.22621.1485).

@alixander
Copy link
Contributor

did 0.8.4 work on linux for you as well? @quixoticaxis

@quixoticaxis
Copy link

@alixander 0.8.3, 0.8.4, and 0.8.5 work on my Kubuntu (latest stable).
Only 0.8.3 works on my Windows 11 PC.

@BarryNolte
Copy link
Collaborator

It all works on my win10 machine, so win11 related?

@quixoticaxis
Copy link

Disclaimer: I know literally zero javascript.
Debugging the isnstalled extension (running debugger from %userprofile%\.vscode\extensions\terrastruct.d2-0.8.5 folder) gave me the following callstack:

Exception has occurred: TypeError: File URL path must be absolute
t new NodeError (node:internal/errors:371:5)
	at getPathFromURLWin32 (node:internal/url:1390:11)
	at fileURLToPath (node:internal/url:1420:22)
	at 2163 (&userprofile%\.vscode\extensions\terrastruct.d2-0.8.5\dist\extension.js:1:85043)
	at r (&userprofile%\.vscode\extensions\terrastruct.d2-0.8.5\dist\extension.js:1:90391)
	at 6662 (&userprofile%\.vscode\extensions\terrastruct.d2-0.8.5\dist\extension.js:1:51580)
	at r (&userprofile%\.vscode\extensions\terrastruct.d2-0.8.5\dist\extension.js:1:90391)
	at 3961 (&userprofile%\.vscode\extensions\terrastruct.d2-0.8.5\dist\extension.js:1:53416)
	at r (&userprofile%\.vscode\extensions\terrastruct.d2-0.8.5\dist\extension.js:1:90391)
	at 112 (&userprofile%\.vscode\extensions\terrastruct.d2-0.8.5\dist\extension.js:1:54771)
	at r (&userprofile%\.vscode\extensions\terrastruct.d2-0.8.5\dist\extension.js:1:90391)
	at &userprofile%\.vscode\extensions\terrastruct.d2-0.8.5\dist\extension.js:1:90808
	at Object.<anonymous> (&userprofile%\.vscode\extensions\terrastruct.d2-0.8.5\dist\extension.js:1:90833)
	at Module._compile (node:internal/modules/cjs/loader:1165:14)
	at Module._extensions..js (node:internal/modules/cjs/loader:1220:10)
	at Module.load (node:internal/modules/cjs/loader:1035:32)
	at Module._load (node:internal/modules/cjs/loader:876:12)
	at c._load (node:electron/js2c/asar_bundle:5:13343)
	at m._load (%letscallitprogramfiles%\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:124:14199)
	at h._load (%letscallitprogramfiles%\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:119:11871)
	at I._load (%letscallitprogramfiles%\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:119:11264)
	at Module.require (node:internal/modules/cjs/loader:1059:19)
	at require (node:internal/modules/cjs/helpers:102:18)
	at Function.i [as __$__nodeRequire] (%letscallitprogramfiles%\Microsoft VS Code\resources\app\out\vs\loader.js:5:98)
	at E.rb (%letscallitprogramfiles%\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:119:13135)
	at async Promise.all (index 0)

Hope it helps.

@BarryNolte
Copy link
Collaborator

Excellent, now I have something to go on! I'll see if my current hunch is correct. Thanks!

@BarryNolte
Copy link
Collaborator

It's the open module that I added to open links in the preview window trying get the path to the 'xdg-open' script for linux, on a windows machine. This module had a note about not really working in electron apps, so I guess this is the subtle hint to not use it. Going off to find alternatives...

@vittee
Copy link

vittee commented Apr 9, 2023

The error is originated from this file:
C:\Users\vittee\.vscode\extensions\terrastruct.d2-0.8.5\dist\extension.js

And I found that it contains a literal string pointing to an invalid path (on Windows)

const $e = i.dirname((0, s.fileURLToPath)("file:///Users/gavinnishizawa/github_repos/d2-vscode/node_modules/open/index.js"))

Simply edit that string to:

const $e = i.dirname((0, s.fileURLToPath)("file://./node_modules/open/index.js"))

And it now works

@vittee
Copy link

vittee commented Apr 9, 2023

Might be related to this

https://github.com/sindresorhus/open/blob/accd304abffaec9016f180496d4d3de40145b3c9/index.js#L14

@therastal
Copy link

The error is originated from this file: C:\Users\vittee\.vscode\extensions\terrastruct.d2-0.8.5\dist\extension.js

And I found that it contains a literal string pointing to an invalid path (on Windows)

const $e = i.dirname((0, s.fileURLToPath)("file:///Users/gavinnishizawa/github_repos/d2-vscode/node_modules/open/index.js"))

Simply edit that string to:

const $e = i.dirname((0, s.fileURLToPath)("file://./node_modules/open/index.js"))

And it now works

This fixed it for me! 👍

@Rhywun
Copy link

Rhywun commented Apr 11, 2023

The noted fix worked for me too

@gavin-ts
Copy link
Contributor

thanks everyone version 0.8.6 is released and should fix this issue

@alixander
Copy link
Contributor

we'll close this once someone can confirm. @Rhywun @therastal @vittee @quixoticaxis @imding

@quixoticaxis
Copy link

@gavin-ts , @alixander , thank you. 0.8.6 works.

@alixander
Copy link
Contributor

great. thanks @BarryNolte !

@jfudickar
Copy link

Same for me!
Great work. Thanks

@imding
Copy link
Author

imding commented Apr 14, 2023

sorry for completely dropping out on the thread.

I only had this issue on windows, will check asap, and thanks so much for fixing it!!

@imding
Copy link
Author

imding commented Apr 14, 2023

it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

9 participants