Skip to content

Installing VS Code under chroot and configuring it for ns-3

Visual Studio Code (VS Code) is an open-source source-code editor made by Microsoft for Windows, Linux and macOS[1]. It has the support for debugging, syntax highlighting, intelligent code completion, snippets, code refactoring, embedded Git and having rich and freely available extensions.

Caution:

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 [2], 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 ns3.35 in Debian 10 chroot Jail Under Debian 11 Host OS or any Version of Linux Host

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 [3] – 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 update
$ 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.

$ wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add –
$ 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.

$ apt install code

Step  3: Trying to Start ‘code’

The following command will try to start the VS code editor.

$ code

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.

Hidden Section! Contact Charles  

The key/passphrase will be given once you have been approved for getting paid research support/assistance from Charles. To get paid support, you may start a 'free' research discussion.  

WhatsApp chatDiscuss Through WhatsApp
 

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 [4]. But I customized it to make it work for the latest ns-3-dev version code.

The following article[5] explains the configuration procedure.

Configuring Visual Studio Code for ns-3 Under chroot Jail

 

References:

  1. https://en.wikipedia.org/wiki/Visual_Studio_Code
  2. Installing ns3.35 in Debian 10 chroot Jail Under Debian 11 Host OS or any Version of Linux Host
  3. https://linuxize.com/post/how-to-install-visual-studio-code-on-ubuntu-20-04/
  4. https://gabrielcarvfer.github.io/NS3/installation/visualcode
  5. https://www.projectguideline.com/configuring-visual-studio-code-for-ns-3-under-chroot-jail/

 

WhatsApp Discuss Through WhatsApp