summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2024-03-20 02:04:08 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2024-03-20 04:16:28 +0530
commit069d89223769a380ccecd069a01e3bd5d71fdef3 (patch)
tree72dfe6b896332cdf41da5b2daec71955c51f9dea
parent2d7b7c3aaf23d08d51f375fa1eea80e0ffffed87 (diff)
downloadmeson-069d89223769a380ccecd069a01e3bd5d71fdef3.tar.gz
devenv: Don't use Path.relative_to() to resolve relative paths
It's utterly broken, and only works when one path is inside the other: Traceback (most recent call last): File "/usr/lib/python3.12/site-packages/mesonbuild/mesonmain.py", line 194, in run return options.run_func(options) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/mesonbuild/mdevenv.py", line 188, in run write_gdb_script(privatedir, install_data, workdir) File "/usr/lib/python3.12/site-packages/mesonbuild/mdevenv.py", line 142, in write_gdb_script rel_path = gdbinit_path.relative_to(workdir_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib64/python3.12/pathlib.py", line 682, in relative_to raise ValueError(f"{str(self)!r} is not in the subpath of {str(other)!r}") ValueError: '/path/to/builddir/.gdbinit' is not in the subpath of '/path/to/workdir' ERROR: Unhandled python exception This is a Meson bug and should be reported!
-rw-r--r--mesonbuild/mdevenv.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/mesonbuild/mdevenv.py b/mesonbuild/mdevenv.py
index c8d0144c5..cc69fb6e0 100644
--- a/mesonbuild/mdevenv.py
+++ b/mesonbuild/mdevenv.py
@@ -10,7 +10,7 @@ import typing as T
from pathlib import Path
from . import build, minstall
from .mesonlib import (EnvironmentVariables, MesonException, is_windows, setup_vsenv, OptionKey,
- get_wine_shortpath, MachineChoice)
+ get_wine_shortpath, MachineChoice, relpath)
from . import mlog
@@ -140,7 +140,7 @@ def write_gdb_script(privatedir: Path, install_data: 'InstallData', workdir: Pat
if first_time:
gdbinit_path = gdbinit_path.resolve()
workdir_path = workdir.resolve()
- rel_path = gdbinit_path.relative_to(workdir_path)
+ rel_path = Path(relpath(gdbinit_path, workdir_path))
mlog.log('Meson detected GDB helpers and added config in', mlog.bold(str(rel_path)))
mlog.log('To load it automatically you might need to:')
mlog.log(' - Add', mlog.bold(f'add-auto-load-safe-path {gdbinit_path.parent}'),