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

[VS Code]: Running a shell task with ${workspaceRoot} for path to script provides incorrect path on remote host. #2576

Closed
jamesharris-garmin opened this issue Jul 29, 2019 · 11 comments

Comments

@jamesharris-garmin
Copy link

Error:

Executing task in folder jenkins-job-builder: \/.vscode/jjb-build.bat test aoem-test <

'\' is not recognized as an internal or external command,
operable program or batch file.
The terminal process command 'C:\Windows\System32\cmd.exe /C \/.vscode/jjb-build.bat test aoem-test' failed to launch (exit code: 1)

It looks like ${workspaceRoot} is being resolved to \ when the live share guest executes a task.

If the liveshare host executes the task ${workspaceRoot} is resolved correctly.

Steps to Reproduce:

  1. Create a task as follows:
       {
            "label": "jjb-build",
            "type": "shell",
            "command": "${workspaceRoot}/.vscode/jjb-build.bash",
            "windows": {
                "command": "${workspaceRoot}/.vscode/jjb-build.bat",
                "options": {
                    "shell": {
                        "executable": "C:\\Windows\\System32\\cmd.exe",
                        "args": [
                            "/C"
                        ]
                    }
                }
            }
       }
  1. create a .bat file to run (jjb-build.bat) with the following contents:
echo off
echo Hello World!
  1. Create a live share session in one system
  2. connect to a live share session from a different machine.
  3. The host user should be able to run the task successfully.
  4. Run the task from the remotely connected user.
Version Data
extensionName VSLS
extensionVersion 1.0.581
protocolVersion 2.2
applicationName VSCode
applicationVersion 1.36.1
platformName Linux
platformVersion 4.18.0-25-generic
@IlyaBiryukov
Copy link
Collaborator

Fixing this needs VSCode support first, tracked by microsoft/vscode#73748.
So, blocked for now.

@jamesharris-garmin
Copy link
Author

jamesharris-garmin commented Aug 5, 2019

Thanks for getting back to that. hopefully we will be able to fix vscode for that sometime soon.

@jamesharris-garmin
Copy link
Author

Another wrinkle in this.

If the liveshare session shares a remote workspace (i.e. a remote-ssh) workspace. The task runner further assumes that we are on a windows host and attempts to execute the windows commands in the workspace.

@IlyaBiryukov
Copy link
Collaborator

It all happens because in Live Share session the guest gets .vscode/tasks.json file from the host. These tasks, as is, do not make sense for the guest. We could have hidden the file from the guest, but what if the guest wanted to collaborate with the host on this file? So we don't hide it. Instead we want to be able to tell VSCode to disregard this file on the guest (microsoft/vscode#73748). Live Share itself already provides the proxies of the tasks that just invoke these tasks on the host.

@jimmyharris
Copy link

how do you get to those proxies?

@IlyaBiryukov
Copy link
Collaborator

On the guest side in VSCode run "Tasks: Run Task" command. This will show a drop down with the list of tasks. Tasks that start with "Shared:" are those proxies. You'd need to configure the host VSCode to allow guest run tasks first. By default, it is not allowed for security reasons. It is "Live Share: Allow Guest Task Control" setting on the host.

@jamesharris-garmin
Copy link
Author

ok so on the vscode side you just need to hide the local tasks.json form vscode so that we don't get tasks from it while we are a remote guest.

@AndhikaWB
Copy link

We could have hidden the file from the guest

Could you make it as the default behaviour? It has been a year since issue #73748 was created (and yet still not resolved). Not being able to easily run (build) task as guest is really a deal breaker to me (debugging works fine, though).

but what if the guest wanted to collaborate with the host on this file? So we don't hide it

Then we can just add a new setting to make it appear or hidden (default) to guest.

@IlyaBiryukov
Copy link
Collaborator

It's a valid approach, I'll mark this issue as feature request then. @fubaduba FYI
I don't know when we have time to get to that though. Is this issue completely blocking you, or you can work it around?

@AndhikaWB
Copy link

AndhikaWB commented Sep 18, 2020

Yesterday I tried excluding tasks.json via .vsls.json by using 2 different instances of Live Share on the same PC. Live Share didn't seem to exclude it from the guest tree, though. I'm not sure if it's another issue and I haven't tried it again using different account/PC (maybe will try later; but my friend is kinda upset because of this issue 😅).

Here is my .vsls.json by the way (placed inside .vscode folder):

{
    "$schema": "http://json.schemastore.org/vsls",
    "gitignore": "hide",
    "excludeFiles": [
        "*.json"
    ]
}

Another way I found is by using the debug task as I mentioned earlier (without actually debugging it and just skip to the run program step), but I don't find it really comfortable (especially for long term use). But how can debugging works just fine, though? launch.json is also visible to guest.

EDIT: Can confirm that .vsls.json with above settings does not exclude tasks.json and launch.json.

@derekbekoe
Copy link
Collaborator

We’ve made improvements in this area (including to .vsls.json file exclusion support) since this issue was filed. We believe this may have improved your experience and are closing this issue. If this issue still persists for you, please comment on the issue and let us know. Thank you.

@derekbekoe derekbekoe closed this as not planned Won't fix, can't repro, duplicate, stale Nov 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants