asciidoctor-vscode icon indicating copy to clipboard operation
asciidoctor-vscode copied to clipboard

WIP - attempt to support remote includes

Open apupier opened this issue 2 years ago • 5 comments

from what i understood, placing the allow-uri-read in attributes should have done the thing but it is not working... to investigate

resolves #731

apupier avatar Jun 29 '23 06:06 apupier

@ggrossetie any hints how to investigate on this one?

apupier avatar Jun 30 '23 14:06 apupier

The underlying error is:

Error: Command failed: "/usr/share/code/code" "/home/guillaume/Workspace/opensource/asciidoctor-vscode/node_modules/unxhr/lib/request.js" --ssl="true" --encoding="utf8" --request-options="{\"host\":\"raw.githubusercontent.com\",\"port\":443,\"path\":\"/asciidoctor/asciidoctor-vscode/master/CONTRIBUTING.adoc\",\"method\":\"GET\",\"headers\":{\"User-Agent\":\"node-XMLHttpRequest\",\"Accept\":\"*/*\",\"Host\":\"raw.githubusercontent.com\"},\"agent\":false,\"withCredentials\":false}"

We are using unxhr to fetch remote content synchronously (because we must resolve include synchronously). To do that, we use execSync.

I believe that the issue is that we are using ${process.execPath} which in this case resolves to /usr/share/code/code (which seems to be unable to execute a Node script).

https://github.com/ggrossetie/unxhr/blob/4fbc39978b99180c24cd31ac802c2b4ae5dca3c6/lib/XMLHttpRequest.js#L520

Not sure how we can execute a Node script using code (since we cannot be sure that node will be available in the PATH).

ggrossetie avatar Jul 08 '23 09:07 ggrossetie

I believe that the issue is that we are using ${process.execPath} which in this case resolves to /usr/share/code/code (which seems to be unable to execute a Node script).

seems we are not the only ones to hit this kind of problem: https://stackoverflow.com/questions/75103016/node-execpath-references-vscode-installation-instead-of-path-to-node-installatio

asked on VS Code extension dev Slack channel https://vscode-dev-community.slack.com/archives/C74CB59NE/p1691498625819969 and VS Code Github discussions: https://github.com/microsoft/vscode-discussions/discussions/746

apupier avatar Aug 08 '23 12:08 apupier

I'm wondering if we can use child_process.execFileSync instead of child_process.execSync in unxhr

apupier avatar Aug 08 '23 13:08 apupier

something to try is to use ELECTORON_RUN_AS_NODE https://www.electronjs.org/docs/latest/api/environment-variables#electron_run_as_node

https://github.com/microsoft/vscode-discussions/discussions/746#discussioncomment-6719320

apupier avatar Aug 14 '23 10:08 apupier