Open VSCode from Remotly Server to Local like WSL2 - linux

Recently i created one server (with centos) on another computer, i assigned static local ip (192.168.1.100) and i my computer has local static ip too (192.168.1.50), and i would like open the vscode from my local computer when i run "code" command on remote server (like code .) inside vscode of my computer.
Basically like WSL2 works, but, when we install the distro of WSL2, the vscode install automatically one extension for WSL2, and that works.
And another question, is about the terminal of local vscode, when i open the vscode terminal, i would like to open the remote server terminal (ssh) on the current folder. (Exactly like WSL2)
Basically i would like create a WSL2 outside from the same computer. The "SubSystem" i want to install are on another computer (my server)

I think that's what you're looking for 1
A simpler method would be to install ssh-remote plugin in VSCode and you will see Remote Explorer in your left bar. After you log in once to that server you will see the connection and with a simple click, you can connect from there.

Related

Open WSL directly to vscode

I'm trying to open WSL directly from vscode without opening or connecting to a remote window. In the image attached, my friend was able to add WSL as a profile and open it directly in vscode without connecting to a remote window or opening a new WSL. How would I be able to do this? (https://i.stack.imgur.com/sukIe.png)
I have WSL installed and enabled and I've tried to look up tutorials, but they all use the remote window.

How to debug remote Python script in VS Code

I am doing Python development in Raspberry Pi. I have installed VS Code in my laptop and have installed the ssh extension. Using this I can easily connect to Raspberry Pi. While I am connected I can see that VS Code has also loaded the Python interpreter of Raspberry Pi. I can run my Python script from within the vs code but when I tried to debug the code, nothing happens.
Is it possible to remotely debug the Python script from laptop to Raspberry Pi? How can I enable this?
I have resolved this issue. If anyone wants to do remote development and debugging, follow below steps:
Install remote ssh extension in VS code
Once installed, you will find a green icon on the bottom left corner in vs code which allows us to connect to the remote machine.
Connect to the remote machine using the standard ssh command. Alternatively, you can use ssh-keygen to generate a public-private key if you don't want to use the password at every prompt.
Once you are connected to remote machine, you can open the file explorer and create any python file. When you will save this, it will get saved in your remote machine. This way you are using your machine to remotely develop code on another remote machine.
Good thing about vs code is that it selects the remote machine's python interpreter so all the packages which you have installed on your remote machine will work with IntelliSense.
In order to debug the code, we will use debugpy. Install this on both machine (remote & local)
On your remote machine, run below command:
python3 -m debugpy --listen 1.2.3.4:5678 --wait-for-client app.py
here 1.2.3.4 is the IP of remote machine. This will start a remote debugger which will wait for a clients connection.
On your local machine, in VS code open Run & Debug, add a configuration of Python: Remote Attach. Make sure that launch.json has the host as the IP of your remote machine and port as 5678.
Now start debugging as normal and you will notice the code will break at first breakpoint and from here you can proceed normally as we used to do in local debugging process.
TBH, this is best feature VS code has because most of the software allows you to do remote development which is nothing but just a normal SSH but remote debugging gives you more control. I was doing some python project on Raspberry Pi and obviously cannot install VS code or pycharm on it. But with this feature now I can easily develop the code using Pi's python interpreter and debug it as well.
If anyone is having any issues, let me know. Happy to help.

Debugging VSCode Extension within a remote container

I'm currently using vscode-tomcat extension within a RHEL7 container and developing over SSH using the vscode-remote extension. However, I am unable to launch the tomcat debugger due to this unresolved issue.
"TypeError: Cannot set property 'readableListening' of undefined"
The issue only occurs when trying to launch the Tomcat debugger while doing remote SSH development. I am making an attempt to debug the issue, but I'm not sure how to debug a VSCode extension within a remote container.
Any tips would be greatly appreciated. Let me know if I can provide any additional details.
There is now documentation for all of this. Read
https://code.visualstudio.com/api/advanced-topics/remote-extensions#debugging-using-ssh
and then keep reading because further down you will find this
https://code.visualstudio.com/api/advanced-topics/remote-extensions#debugging-using-ssh
in fact read all of it, there's a lot of stuff there that initially made me think "So?" but which is vital knowledge in specialised problems.
Here's the portion relating to the immediate problem.
Debugging using SSH
Follow steps:
After installing and configuring the Remote - SSH extension, select Remote-SSH: Connect to Host... from the Command Palette (F1) in VS Code to connect to a host.
Once connected, either use File > Open... / Open Folder... to select the remote folder with your extension source code in it or select Git: Clone from the Command Palette (F1) to clone it and open it on the remote host.
Install any required dependencies that might be missing (for example using yarn install or apt-get) in a new VS Code terminal window (Ctrl+Shift+` ).
Finally, press F5 or use the Run view to launch the extension inside on the remote host and attach the debugger.
Note: You will not be able to open the extension source code folder in the window that appears, but you can open a sub-folder or somewhere else on the SSH host.
The extension development host window that appears will include your extension running on the SSH host with the debugger attached to it.
Installing a development version of your extension
Anytime VS Code automatically installs an extension on an SSH host, inside a container or WSL, or through GitHub Codespaces, the Marketplace version is used (and not the version already installed on your local machine).
While this makes sense in most situations, you may want to use (or share) an unpublished version of your extension for testing without having to set up a debugging environment. To install an unpublished version of your extension, you can package the extension as a VSIX and manually install it into a VS Code window that is already connected to a running remote environment.
Follow these steps:
If this is a published extension, you may want to add "extensions.autoUpdate": false to settings.json to prevent it from auto-updating to the latest Marketplace version.
Next, use vsce package to package your extension as a VSIX.
Connect to a codespace, development container, SSH host, or WSL environment.
Use the Install from VSIX... command available in the Extensions view More Actions (...) menu to install the extension in this specific window (not a local one).
5.Reload when prompted.
Tip: Once installed, you can use the Developer: Show Running Extensions command to see whether VS Code is running the extension locally or remotely.

VSCode execute node script on remote linux or windows machine

Using VSCode, is it possible to execute a node.js script on a remote linux or windows system without setting up a full Visual Studio Code Remote Development Environment?
Assume the following:
VSCode installed on client (Windows)
remote system is a virtual machine running on the client. It has access to the project folder (including the script to be executed and the node modules) on the client. Node is installed on the remote system.
Actually I just need something like a launch configuration which executes an SSH command for linux, for windows maybe something else. With these assumptions (shared project folder between remote system and client), is that possible without setting up a full Visual Studio Code Remote Development Environment? I don't need remote editing or debugging.

Opening web browser on linux virtual machine

I have created a virtual linux machine from amazon web services... the terminal that opens up is the gitbash prompt. I'm trying to open any web browser but I couldnt find a command to do so. I have tried xdg-open, start and several other commands that I came across but they wouldnt work. Please assist me!
The text based lynx is usually installed by default. Otherwise if X-windows is installed and configured, the shell command "startx" will start a GUI session.
But gitbash is tiny and is void of most packages to reduce space...

Resources