acoustic-carpenter-78188
07/20/2026, 4:04 AMflyte deploy never records _F_SYS_PATH, breaking code-bundle imports under src/
Issue created by earlybard
Describe the bug
The deploy command docs document sys.path synchronization as the default behavior of flyte deploy:
Default behavior (path synchronization enabled): Flyte captures local sys.path entries that are under the root directory. These paths are passed to the remote container via theThis is not implemented. The deploy code path never computes or records `_F_SYS_PATH`; only the run path does.environment variable. At runtime, the remote container adds these paths to its sys.path, maintaining the same import environment._F_SYS_PATH
flyte run and flyte deploy handle code-bundle import paths asymmetrically:
• run: the client computes _F_SYS_PATH from the local sys.path and injects it as a run-level env var — _RunLauncher._build_env_dict in `flyte/_run.py`:
# These paths will be appended to sys.path at runtime.
if cfg.sync_local_sys_paths:
root_dir_abs = pathlib.Path(cfg.root_dir).resolve()
env[FLYTE_SYS_PATH] = ":".join(
f"./{pathlib.Path(p).relative_to(root_dir_abs)}"
for p in sys.path
if pathlib.Path(p).is_relative_to(root_dir_abs)
)
• deploy: nothing equivalent exists. flyte/_deploy.py, task_serde.py, and trigger_serde.py never reference sync_local_sys_paths or `FLYTE_SYS_PATH`; translate_task_to_wire serializes only the user-declared env_vars into container.env. The deployed task spec and its triggers carry no record of the sys.path entries the code bundle needs.
At runtime, adjust_sys_path (flyte/_utils/module_loader.py) puts only ., the code-bundle destination, and whatever _F_SYS_PATH contains onto sys.path. For a client-launched run, _F_SYS_PATH arrives via the run envs and imports work. For a run of a deployed task fired by a trigger/schedule, there is no client, _F_SYS_PATH is unset, and only the bundle root is importable.
Note flyte deploy even accepts --no-sync-local-sys-paths and stores it in the init config, but the deploy code path never reads it — the flag is a no-op, suggesting this was intended but never wired up.
Consequence
Any project with a src/ layout (the uv init --lib default and standard modern packaging) using a with_uv_project image is broken for scheduled runs: project_install_mode defaults to dependencies_only, so the project's own package exists only in the code bundle at ./src/<pkg>. flyte run injects _F_SYS_PATH=./src:... and works; the identical deployed task fired by a Cron trigger fails every time with ModuleNotFoundError: No module named '<pkg>'. The workaround is to compute the paths yourself and set TaskEnvironment(env_vars={"_F_SYS_PATH": ...}) — verified to reach the pod on trigger-fired runs. (Trigger(env_vars=...) does not reach the pod; reported separately.)
Steps to reproduce
1. uv init --lib myproj (code lands in src/myproj/), add a task:
# src/myproj/wf.py
import flyte
from myproj import hello # any first-party import
env = flyte.TaskEnvironment(
"myproj",
image=flyte.Image.from_debian_base().with_uv_project("pyproject.toml"),
)
@env.task(triggers=flyte.Trigger("minutely", automation=flyte.Cron("* * * * *")))
async def main() -> str:
return hello()
2. flyte run src/myproj/wf.py main — succeeds; the run's env shows _F_SYS_PATH=./src:....
3. flyte deploy src/myproj/wf.py env and wait for the trigger to fire — the run fails with ModuleNotFoundError: No module named 'myproj'. The run has no _F_SYS_PATH.
Expected behavior
deploy should capture the same bundle-relative sys.path entries run computes (the code bundle is built from the same workspace, so they're known at deploy time) and persist them in the deployed task so every run of the task — trigger-fired or otherwise — resolves imports identically to flyte run.
Environment
• flyte SDK 2.5.9 (Python 3.14), self-hosted Flyte v2 backend
flyteorg/flyteacoustic-carpenter-78188
07/23/2026, 5:06 PMflyte deploy never records _F_SYS_PATH, breaking code-bundle imports under src/
Issue closed as completed by pingsutw
flyteorg/flyte