asciidoctor-vscode
asciidoctor-vscode copied to clipboard
WIP - attempt to support remote includes
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
@ggrossetie any hints how to investigate on this one?
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).
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
I'm wondering if we can use child_process.execFileSync instead of child_process.execSync in unxhr
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