Problem
PyCharm runs in a Kubernetes pod, for example with access through VNC. The embedded browser is suspended, and the dialog offers Install Profile... and Disable Sandbox. Clicking Install Profile... opens a terminal titled "Install AppArmor profile for PyCharm", which fails with:
sudo: command not found
Cause
The embedded browser (JCEF) runs in a sandbox that needs unprivileged user namespaces. When they are restricted, the IDE offers to install an AppArmor profile. The installation needs root access, so the IDE runs the install script through sudo, which is not present in the container image. Even with sudo, AppArmor profiles are normally managed on the host node, not inside a container.
Resolution
Turn off the embedded browser sandbox. None of the options below needs root access or a rebuilt container image.
Turning off the sandbox removes a security layer of the embedded browser. Restricted unprivileged user namespaces describes what the sandbox does and the security considerations.
Option 1: Disable Sandbox button
- Click Disable Sandbox in the embedded browser dialog.
- A confirm exit dialog appears instead of a restart prompt (IJPL-233796). Click Exit.
- If PyCharm does not start again, start it manually.
The setting is stored in the PyCharm configuration directory, ~/.config/JetBrains/PyCharm<version>. It persists only if this directory is kept between pod restarts.
Option 2: Custom VM options in the configuration directory
- Go to Help | Edit Custom VM Options.
-
Add the following line at the end of the file:
-Dide.browser.jcef.sandbox.enable=false - Restart PyCharm.
This file is also stored in the configuration directory, so the same persistence condition applies.
Option 3: PYCHARM_VM_OPTIONS environment variable
Use this option when the configuration directory is not kept between pod restarts. The file that PYCHARM_VM_OPTIONS points to overrides all other JVM options files, so it must contain the full default option set.
- Copy
<IDE_HOME>/bin/pycharm64.vmoptionsto a persistent volume, for example/workspace/pycharm64.vmoptions. - Add
-Dide.browser.jcef.sandbox.enable=falseat the end of the copy. - Close PyCharm completely. If PyCharm is still running, a new start can bring up the existing window, and the new options are not used.
-
Start PyCharm from a terminal with the variable set:
PYCHARM_VM_OPTIONS=/workspace/pycharm64.vmoptions <IDE_HOME>/bin/pycharm.sh - Make sure the embedded browser no longer shows the sandbox message.
To set the variable on every pod start without rebuilding the image, add it to the container env section of the pod specification (for example, in the Deployment):
env:
- name: PYCHARM_VM_OPTIONS
value: /workspace/pycharm64.vmoptions
The file must be on a volume that is mounted in every pod that runs PyCharm. If a startup script resets the environment before it starts PyCharm, set the variable in that script.
For more information about JVM options files, see Configure JVM options.
Comments
0 comments
Please sign in to leave a comment.