nils-soderman / vscode-unreal-python

Visual Studio Code extension with features to assist when writing python code for Unreal Engine
https://marketplace.visualstudio.com/items?itemName=NilsSoderman.ue-python
MIT License
85 stars 10 forks source link

Remote code execution from WSL2 #16

Open richardnm-2 opened 1 year ago

richardnm-2 commented 1 year ago

Would it be possible to implement remote code execution from WSL2 as well? I've never worked with VSCode extensions, maybe with some guidance I can help implement it.

EDIT: I've been able to connect to the Windows UE5 instance from WSL2, changing TTL to 2 in the plugin and extension settings. Even so, when I try to run a script file, the UE5 output log displays:

LogPython: Error: Traceback (most recent call last):
LogPython: Error:   File "<string>", line 1, in <module>
LogPython: Error: OSError: [Errno 22] Invalid argument: '/home/richardnm/.vscode-server/extensions/nilssoderman.ue-python-1.1.0/python/execute/vscode_execute_entry.py'

It seems that it has the root for file execution on Windows, trying to access the WSL Ubuntu /home/... directory.

nils-soderman commented 1 year ago

Hi,

Interesting, I don't se why we shouldn't support this!

I haven't used WSL2 myself, I'll download it and give it a try, but any help in both testing & implementing this would be greatly appreciated! I'm going to put together a contributing.md document in the coming days, with some info on how to run/debug the extension.

It seems the extension is installed on the WSL2 VM, which means we cannot share any files between the extension/unreal. All communication needs to happen through the socket. There are currently some python scripts that the extension refers to by filepath (see src/modules/remote-handler::executeFile). These python files will instead need to be read inside this executeFile method, and then pass along the code instead of the filepath.

Then comes the issue of vscode_execute_entry.py which does a relative import of vscode_execute.py. Worst case we could skip this and execute vscode_execute.py directly (only incase of WSL2).

Lastly, instead of passing in the filepath (fileToExecute) in src/scripts/execute::main, this file also needs to be read here and passed as code.

nils-soderman commented 1 year ago

There is now a CONTRIBUTING.md with some info on how to setup the extension for development/debugging.

It will probably be some time before I have the time to look at this, but feel free to give it a go if you're feeling up to it.

Cheers, Nils