Skip to content

flow crashes due to FileNotFoundError from uv at import #17988

@rcash

Description

@rcash

Bug summary

uv raises a FileNotFoundError in new versions of Prefect at import when trying to kick a flow run off - when importing bundles.py or functionality related to it. this is seen because the path uv looks for its binary at does not appear to match the Python installation used (Anaconda), in this case at least.

stack trace

19:27:46.471 | ERROR   | Flow run 'phi5-iyaar' - Unexpected exception encountered when trying to load flow
Traceback (most recent call last):
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/engine.py", line 112, in <module>
    flow: "Flow[..., Any]" = load_flow(flow_run)
                             ^^^^^^^^^^^^^^^^^^^
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/flow_engine.py", line 140, in load_flow
    flow = run_coro_as_sync(
           ^^^^^^^^^^^^^^^^^
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/utilities/asyncutils.py", line 207, in run_coro_as_sync
    return call.result()
           ^^^^^^^^^^^^^
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 329, in result
    return self.future.result(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 192, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/home/ray/anaconda3/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 405, in _run_async
    result = await coro
             ^^^^^^^^^^
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/utilities/asyncutils.py", line 188, in coroutine_wrapper
    return await task
           ^^^^^^^^^^
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/client/utilities.py", line 69, in wrapper
    return await func(client, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/flows.py", line 2518, in load_flow_from_flow_run
    from prefect.deployments.steps.core import StepExecutionError, run_steps
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/deployments/steps/__init__.py", line 2, in <module>
    from .pull import (
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/deployments/steps/pull.py", line 12, in <module>
    from prefect.runner.storage import BlockStorageAdapter, GitRepository, RemoteStorage
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/runner/__init__.py", line 1, in <module>
    from .runner import Runner
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/runner/runner.py", line 72, in <module>
    from prefect._experimental.bundles import (
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/_experimental/bundles.py", line 28, in <module>
    uv_path = uv.find_uv_bin()
              ^^^^^^^^^^^^^^^^
  File "/home/ray/anaconda3/lib/python3.11/site-packages/uv/_find_uv.py", line 36, in find_uv_bin
    raise FileNotFoundError(path)
FileNotFoundError: /home/ray/.local/bin/uv
19:27:46.483 | ERROR   | prefect.engine - Execution of flow run 'f43cc11f-5ba4-459d-91b0-7e02270af306' exited with unexpected exception
Traceback (most recent call last):
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/engine.py", line 57, in handle_engine_signals
    yield
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/engine.py", line 112, in <module>
    flow: "Flow[..., Any]" = load_flow(flow_run)
                             ^^^^^^^^^^^^^^^^^^^
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/flow_engine.py", line 140, in load_flow
    flow = run_coro_as_sync(
           ^^^^^^^^^^^^^^^^^
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/utilities/asyncutils.py", line 207, in run_coro_as_sync
    return call.result()
           ^^^^^^^^^^^^^
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 329, in result
    return self.future.result(timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 192, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/home/ray/anaconda3/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/_internal/concurrency/calls.py", line 405, in _run_async
    result = await coro
             ^^^^^^^^^^
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/utilities/asyncutils.py", line 188, in coroutine_wrapper
    return await task
           ^^^^^^^^^^
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/client/utilities.py", line 69, in wrapper
    return await func(client, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/flows.py", line 2518, in load_flow_from_flow_run
    from prefect.deployments.steps.core import StepExecutionError, run_steps
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/deployments/steps/__init__.py", line 2, in <module>
    from .pull import (
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/deployments/steps/pull.py", line 12, in <module>
    from prefect.runner.storage import BlockStorageAdapter, GitRepository, RemoteStorage
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/runner/__init__.py", line 1, in <module>
    from .runner import Runner
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/runner/runner.py", line 72, in <module>
    from prefect._experimental.bundles import (
  File "/home/ray/anaconda3/lib/python3.11/site-packages/prefect/_experimental/bundles.py", line 28, in <module>
    uv_path = uv.find_uv_bin()
              ^^^^^^^^^^^^^^^^
  File "/home/ray/anaconda3/lib/python3.11/site-packages/uv/_find_uv.py", line 36, in find_uv_bin
    raise FileNotFoundError(path)
FileNotFoundError: /home/ray/.local/bin/uv

Version info

3.3.5

Additional context

this seems like it could be an upstream issue due to how uv resolves the path to itself, but also makes me wonder if this could have any broader impact on conda users of Prefect

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions