Skip to content

flatpak: fix wrong cwd when running a command through "flatpak build"

Giovanni Campagna requested to merge gcampagna/gnome-builder:wip/set-cwd into master

"flatpak build" will set the cwd of the run command to the build dir, regardless of what directory it is run from. Previously, this would cause us to ignore the cwd set on subprocess launchers created in a flatpak runtime. In turn, this would break subprocesses that rely on the cwd to find configuration, such as eslint, which uses the cwd to resolve the location of the source file and from there the .eslintrc.yml file.

Previously, this would have been unnoticed because:

  1. build system tools (eg make) would run in the build directory anyway
  2. source lint tools (eg eslint) would find some configuration file anyway because the build directory is a descendant of the source directory
  3. most projects only have on .eslintrc.yml file at the root, so they would not notice the wrong cwd on eslint
  4. most projects that use multiple .eslintrc.yml (eg have both node and web JS files) would not use flatpak and/or builddir!=srcdir, therefore the cwd on eslint would be correct anyway

In other words, to trigger this bug you need to have:

  1. half of the JS files written for node and half for GJS, in different
    folders with different .eslintrc.yml
  2. use meson as build system
  3. use flatpak to package the project

Merge request reports