live-share icon indicating copy to clipboard operation
live-share copied to clipboard

Running Python as guest results in incorrect file path

Open stanleyjzheng opened this issue 5 years ago • 3 comments

When connecting to myself in liveshare and running a python program, it does not run from the correct directory. When I run the file as the liveshare leader, the following command is executed: & "C:/Users/my_name/Anaconda3/python.exe" "c:/Users/my_name/source/repos/test.py" and the correct output is given. However, when running from liveshare connected to myself, the following command is executed: & "C:/Users/my_name/Anaconda3/python.exe" /test.py. Since there is no file at /test.py, I am given a generic python error that there is no file there. 'can't open file '/test.py': [Errno 2] No such file or directory'. However, when I manually type in the command generated by the host, the file is run properly.

Product and Version: VSC 1.45 OS Version: Windows 10 Live Share Extension Version: 1.0.2236 Target Platform or Language: Python

Steps to Reproduce / Scenario:

  1. Create a new folder and python file inside. Open the folder and liveshare it
  2. Attempt to run it from the shared machine with the run button

Thanks for your help, I'm a student trying to attend a virtual hackathon. log.zip

stanleyjzheng avatar May 25 '20 22:05 stanleyjzheng

Hi Stanley,

Thanks for reporting this issue. Do you have launch configuration in .vscode/launch.json? If you do, can you please share the launch configuration you have there from your host machine?
When you launch from your guest machine, what launch configuration do you use?

IlyaBiryukov avatar May 26 '20 16:05 IlyaBiryukov

My launch.json file is as follows on both the host and guest:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/test.py",
            "console": "integratedTerminal",
            "cwd": "${workspaceFolder}"
        }
    ]
}

I just realized the command run by the Guest is run in the Guest's local terminal, not in the shared terminal, resulting in an error. When the command & "C:/Users/my_name/Anaconda3/python.exe" /test.py is run from the shared terminal, the expected output is given. Thanks.

stanleyjzheng avatar May 27 '20 16:05 stanleyjzheng

This issue has been automatically marked as stale because it has not had recent activity. It will be closed automatically in 2 days.

github-actions[bot] avatar Aug 15 '22 10:08 github-actions[bot]