Smartgit installed with flatpak can’t run pre-commit script

  Kiến thức lập trình

I’ve added a pre-commit hook using the pre-commit tool. Committing via the command line works fine, but committing with smartgit fails:

~/projects/jobby> git commit --cleanup=whitespace --allow-empty --file=/tmp/smartgit12407019311209412612/commit17051915623650681255.tmp
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/philip-f37/projects/jobby/.venv/lib/python3.11/site-packages/pre_commit/", line 3, in <module>
    from pre_commit.main import main
  File "/home/philip-f37/projects/jobby/.venv/lib/python3.11/site-packages/pre_commit/", line 10, in <module>
    from pre_commit import clientlib
  File "/home/philip-f37/projects/jobby/.venv/lib/python3.11/site-packages/pre_commit/", line 16, in <module>
    from pre_commit.all_languages import language_names
  File "/home/philip-f37/projects/jobby/.venv/lib/python3.11/site-packages/pre_commit/", line 6, in <module>
    from pre_commit.languages import dart
  File "/home/philip-f37/projects/jobby/.venv/lib/python3.11/site-packages/pre_commit/languages/", line 16, in <module>
    from pre_commit.yaml import yaml_load
  File "/home/philip-f37/projects/jobby/.venv/lib/python3.11/site-packages/pre_commit/", line 6, in <module>
    import yaml
ModuleNotFoundError: No module named 'yaml'

This SO answer as well as the official documentation suggests extending the PATH by changing ~/.smartgit/smartgit.vmoptions. However, I have Smartgit installed via Flatpak, so no such file exists in my home directory or anywhere outside of the flatpak directory.

A smartgit.vmoptions file can be found in in the flatpak directory:


In that file, I have tried to include the path to the project’s virtualenv python binary, but that didn’t fix the issue:


I have also tried creating a similar file at ~/.smartgit/smartgit.vmoptions, but that didn’t help either.

I have also tried giving smartgit full filesystem access to my home directory via flatseal – again, no success.

pre-commit hook

#!/usr/bin/env bash
# File generated by pre-commit:
# ID: 138fd403232d2ddd5efb44317e38bf03

# start templated
ARGS=(hook-impl --config=.pre-commit-config.yaml --hook-type=pre-commit)
# end templated

HERE="$(cd "$(dirname "$0")" && pwd)"
ARGS+=(--hook-dir "$HERE" -- "$@")

if [ -x "$INSTALL_PYTHON" ]; then
    exec "$INSTALL_PYTHON" -mpre_commit "${ARGS[@]}"
elif command -v pre-commit > /dev/null; then
    exec pre-commit "${ARGS[@]}"
    echo '`pre-commit` not found.  Did you forget to activate your virtualenv?' 1>&2
    exit 1

pre-commit config

  - repo:
    rev: v0.4.4
      - id: ruff
  - repo:
    rev: 24.4.2
      - id: black