Skip to content

fix: make Linux/WSL terminals, venvs and package management work end to end - #622

Open
tusharbana-ansys wants to merge 3 commits into
mainfrom
fix/wsl-terminal-detection-591
Open

tusharbana-ansys wants to merge 3 commits into
mainfrom
fix/wsl-terminal-detection-591

Conversation

@tusharbana-ansys

@tusharbana-ansys tusharbana-ansys commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #591.

On Linux, and especially WSL, most actions failed silently because the app only ever launched gnome-terminal. This PR adds terminal detection with clear errors. It also fixes Linux bugs found while testing end to end: library leaks into terminals, package installs targeting the wrong Python, venvs created without pip/uv, and an RHEL/Fedora installer that reported false success.

Fixes

Terminal launching (linux_functions.py)

  • Detect the first available terminal instead of hardcoding gnome-terminal. Supported: gnome-terminal, konsole, xfce4-terminal, mate-terminal, tilix, xterm, x-terminal-emulator.
  • Launch with subprocess argument lists instead of os.system(), which also fixes shell-quoting issues.
  • If no terminal is found, raise NoLinuxTerminalError with an install hint for the distro (sudo apt-get install xterm or sudo dnf install xterm).
  • Start terminals with the user's LD_LIBRARY_PATH, not the frozen app's bundled one. Before, commands in these terminals loaded the app's own OpenSSL and other libraries, which broke ssl in Python built from source and could break system tools. This also affected gnome-terminal in v0.6.3.

Error reporting

  • Console, launch and package actions show an error dialog instead of doing nothing (installed_table.py).
  • Uninstall shows an error if the uninstaller can't be launched (uninstall.py).
  • Venv creation no longer reports success after a failure. It checks that <venv>/bin/python exists and removes the empty folder so the same name can be reused (create_virtual_environment.py).

Package management on Linux (linux_functions.py, installed_table.py)

  • Base Python: install into the selected interpreter (uv pip --python <path>) instead of --system. --system picked the OS Python: on Ubuntu 22.04 it installed into the OS Python, and on Ubuntu 24.04 and Fedora it failed with "externally managed". The interpreter's bin folder now comes first on PATH.
  • New venvs: created with uv venv --seed, and pip and uv are installed into them. Before, venvs had neither, so uv pip ... failed with "command not found".
  • Existing venvs: pip and uv are updated with the venv's own interpreter. Before, the command tried to run the venv folder itself. Venvs created by older versions get pip via ensurepip.
  • Removed the duplicate pip/uv update on Linux.

Other

  • find_miniforge_linux(): read CONDA_PYTHON_EXE from the environment. A shell pipe passed without shell=True meant system conda was never detected.

Installers and docs

  • linux/debian/installer.sh, docs: require gnome-terminal instead of the full gnome desktop, and add a note that xterm is enough on WSL.
  • installer_CentOS.sh (also shipped as installer_Fedora.sh):
    • use dnf, falling back to yum; exit with an error if neither exists;
    • require mesa-libGL, mesa-libEGL and xcb-util-cursor, without which the app can't open its window;
    • detect installed groups with group list --installed, and fall back to the development-tools group ID, which dnf5 (Fedora 41+) requires;
    • exit with an error instead of printing "Installation success" when dependency or package installation fails.
  • Docs: list the extra RHEL/Fedora packages; the Fedora command uses the development-tools group ID.

Testing

  • Unit tests: cover terminal detection, the no-terminal error and install hint, and LD_LIBRARY_PATH handling for both launch modes. All 23 tests pass, and all pre-commit hooks pass.
  • Manual testing: apps frozen from this branch, run on fresh WSL distros as a non-root user and driven through the GUI with the keyboard. Results were checked on disk.
Distro Terminal Verified
Ubuntu 22.04 gnome-terminal Base-Python install goes into the Ansys Python (OS Python untouched); new and old venvs; Console has no leaked LD_LIBRARY_PATH
Ubuntu 24.04 gnome-terminal Base and venv installs; venv creation; base and venv Console
AlmaLinux 9 (RHEL 9 family) gnome-terminal Installer: reinstall fails correctly, clean install, missing dependency installed; base and venv installs; venv creation
Fedora 43 (dnf5) xterm No-terminal error; Python 3.11 source build with working ssl; venvs (including conda); JupyterLab; full installer run with dnf5
  • Baseline: on all four distros without a terminal, v0.6.3 fails silently, while this PR shows an error dialog.

Out of scope (existing behavior)

  • Apart from venv creation, the app still doesn't check whether commands run in the terminal succeeded; it can only tell that the terminal opened.
  • gnome-terminal can fail with "Could not connect" when the WSL user session hasn't started its message bus; wsl --shutdown fixes it.

…nome-terminal (#591)

- Add find_linux_terminal() to detect gnome-terminal, konsole, xfce4-terminal, mate-terminal, tilix, xterm, or x-terminal-emulator via shutil.which
- Raise a clear NoLinuxTerminalError with actionable guidance when none are found, instead of silently doing nothing (the root cause of #591 on WSL, which ships no terminal emulator by default)
- Rewrite execute_linux_command to use subprocess argv lists instead of os.system, fixing a latent shell-quoting bug
- Surface terminal-launch failures to the user via show_error() in installed_table.py (Console/launch actions), uninstall.py (uninstall flow), and create_virtual_environment.py (venv creation), instead of failing silently or showing a misleading success dialog after a failure
- Fix find_miniforge_linux() silently failing to detect system conda (invalid shell pipe passed to subprocess without shell=True)
- Fix Ubuntu prerequisites (docs + installer.sh) requiring the full gnome desktop metapackage instead of just gnome-terminal
- Add regression tests for terminal detection and the no-terminal error path
@github-actions github-actions Bot added documentation Improvements or additions to documentation bug Something isn't working labels Aug 5, 2026
@tusharbana-ansys

Copy link
Copy Markdown
Contributor Author

Although automated tests have passed, I am still testing this manually on each supported distro. Please do not merge yet.
cc - @RobPasMue

@tusharbana-ansys tusharbana-ansys added the enhancement New features or code improvements label Aug 5, 2026
@RobPasMue

Copy link
Copy Markdown
Member

Sounds good! Keep me posted. Once it's ready to review and tested manually I will review :)

- Launch terminals with the user's environment: restore LD_LIBRARY_PATH from
  LD_LIBRARY_PATH_ORIG so commands do not load the frozen app's bundled
  libraries (this broke ssl in Python builds and system tools).
- Suggest the distro's package manager (apt-get/dnf) when no terminal exists.
- Package management on Linux:
  - create venvs with `uv venv --seed` and install pip and uv into them;
  - update pip/uv with the venv's interpreter, bootstrapping pip with
    ensurepip for venvs created by older versions;
  - for base Pythons, target the selected interpreter (`--python`) instead
    of `--system`, which picked the OS Python, and put its bin first on PATH.
- Report a failed venv creation instead of a false success and remove the
  empty folder so the same name can be retried.
- installer_CentOS.sh: use dnf (or yum), require mesa-libGL, mesa-libEGL and
  xcb-util-cursor, detect installed groups correctly, fall back to the
  development-tools group ID on dnf5, and fail instead of reporting success
  when dependency or package installation fails.
- Docs: list the extra RHEL/Fedora packages and use the dnf5-compatible group
  ID for Fedora.
@tusharbana-ansys tusharbana-ansys changed the title fix: detect available Linux terminal emulator instead of hardcoding gnome-terminal fix: make Linux/WSL terminals, venvs and package management work end to end Oct 1, 2026

@RobPasMue RobPasMue left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation enhancement New features or code improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WSL not working with Ansys Python Manager

2 participants