Visual Studio Code (VS Code) is an open-source source-code editor made by Microsoft for Windows, Linux and macOS. It has the support for debugging, syntax highlighting, intelligent code completion, snippets, code refactoring, embedded Git and having rich and freely available extensions.
The default user of chroot environment will have root access to the entire file system under the chroot jail. But, it is not advised to use VS Code as the root user. For the same reason, while staring VSCode, it will just exit by displaying the following message : “You are trying to start Visual Studio Code as a super user which isn’t recommended. If this was intended, please specify an alternate user data directory using the `–user-data-dir` argument.”
But in this article, we are trying to configure and use VS code under chroot jail.
As explained in , using chroot facility, we can easily install any guest UNIX/Linux variant under a host operating system and install/compile any software without disturbing the packages and software that are installed on the guest OS.
In the following article, we already mentioned the way of setting up a chroot jail and explained the advantages of installing ns-3 under chroot based environment.
Using the procedure mentioned in the following article, install a 64bit version of Debian Linux under chroot jail.
Installing VS Code under Debian 10 chroot Jail.
VS Code is available from the official Apt repositories of Microsoft. We can download it and install it under Debian as explained below. I just followed the procedure presented in  – but I customized that procedure for installing it under chroot jail.
Step 1: Installing the dependencies.
The following command will update the package repository and will install the necessary dependency packages.
$ apt install software-properties-common apt-transport-https wget
Step 2: Import the Microsoft GPG key and enable the VS Code repository
The following command will import the Microsoft GPG key and will add the VS Code repository in the ‘apt’ environment.
$ add-apt-repository “deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main”
The following command will download and install VS Code from the Microsoft apt repository.
Step 3: Trying to Start ‘code’
The following command will try to start the VS code editor.
Generally, if we invoke the command ‘code’ from a terminal window, then it will generally start ‘VS Code’ editor. Since we are running ‘code’ as root user under chroot environment, simply it will exit after displaying a message. The following screenshot shows that.
Step 4: Starting VS Code under chroot jail.
The following command will start the VS Code even under chroot Jail.
The above command successfully starts the VS Code editor, and now we can use it under chroot. [Kindly note that, in the following output, the VS Code Editor is actually running under the 64 bit Debian 10 chroot jail which is under the host os (64 bit Debian 11)]. It means the GUI program which is running under 64 bit Debian 10 chroot jail is getting rendered at the X windowing system of the host operating system (64 bit Debian 11).
If you closely notice the terminal window, you can see the command “code” which is actually starting the VS Code editor. If you see the title bar of the VS Code editor window, you will see the word “[superuser]” in the window title text. It tells that the VS Code editor is now run as user “root” – because, the default user of chroot jail is “root” user.
Configuring VS Code for ns-3.
For configuring VS Code for ns-3-dev, I closely followed the configuration proceeded presented in . But I customized it to make it work for the latest ns-3-dev version code.
The following article explains the configuration procedure.
- Installing ns3.35 in Debian 10 chroot Jail Under Debian 11 Host OS or any Version of Linux Host