diff --git a/glean-core/python/glean/_process_dispatcher.py b/glean-core/python/glean/_process_dispatcher.py index 33a8b12796..a39b54a917 100644 --- a/glean-core/python/glean/_process_dispatcher.py +++ b/glean-core/python/glean/_process_dispatcher.py @@ -120,8 +120,14 @@ def dispatch(cls, func, args) -> Union[_SyncWorkWrapper, subprocess.Popen]: Path(".coveragerc").absolute() ) + # Explicitly pass the contents of `sys.path` as `PYTHONPATH` to the + # subprocess so that there aren't any module search path + # differences. + python_path = ":".join(sys.path)[1:] + p = subprocess.Popen( - [sys.executable, _process_dispatcher_helper.__file__, payload] + [sys.executable, _process_dispatcher_helper.__file__, payload], + env={"PYTHONPATH": python_path}, ) cls._last_process = p