Closed ahue closed 3 years ago
I've look a bit into it, and this might be a bug on their end. This error gets thrown before my extension receives the resolved task definition. It might be worthwhile opening an issue in microsoft/vscode to support ${file}
and such for editors for FileSystemProvider files.
At first glance, one possible solution is intercepting the variables before the task definition gets resolved, and replacing them with placeholders I can resolve later. I did run a quick check and noticed that I can see the current editor and which (remote) file it opens, so this seems technically feasible.
This would "fix" ${file}
and similar, but only for ssh-shell
tasks. Other tasks trying to use ${file}
for remote files will still error, nothing I can do about that. Another solution is not touching the built-in variables, and adding my own instead, e.g. ${remoteFile}
. I'm more inclined towards the first solution, though, although nothing stops me from doing both.
I have exams now, one being in less than a week, so it might take a while.
I've looked a bit more into it, and I've stumbled on a big roadblock regarding the first solution:
Modifying/replacing the task definition my extension receives breaks the whole task providing process. This means I can't actually replace ${file}
with ${remoteFile}
and such before VS Code tries to resolve it and thus errors.
I'll still add ${remoteFile}
and such, that just means you can't use the built-in ${file}
ones, or at least they won't be properly mapped. Again, those variables would only work for ssh-shell
tasks. Alternatively I could add support for ${command:sshfs.pickRemoteFolder}
or something similar, but that'd be something for later.
Pull request in vscode got merged, once it's released (I assume 1.54.0, maybe 1.53.1) I'll continue working on this.
This is now added in v1.20.0 of the extension. You should be able to use ${remoteFile}
once you've updated to v1.20.0 or later.
Observed behavior
Created a task in tasks.json to execute tests in the current open file using pytest.
On running the task, I get the error Variable ${file} can not be resolved. Please open an editor.
Same behavior with other file-reated variable placeholders, see https://code.visualstudio.com/docs/editor/variables-reference
Expected behavior
${file} is replace with the absolute path of the file on the host.
System info SSH FS version: v1.19.1 VSCode version: 1.52.1 OS: Windows 10 10.0.19041