manzt / juv

Reproducible Jupyter notebooks, powered by uv.
MIT License
61 stars 2 forks source link

juv run fails when $TMPDIR is on a different device than the notebook #42

Open cvaske opened 2 hours ago

cvaske commented 2 hours ago

In an environment with a distinct device for temporary files the notebook, such as:

[cvaske]$ df $TMPDIR
Filesystem       1K-blocks        Used   Available Use% Mounted on
XYZ           XYZ XYZ XYZ  33% /data
[cvaske]$ df quak-profile.ipynb
Filesystem                            1K-blocks       Used   Available Use% Mounted on
XYZ XYZ XYZ XYZ  21% /cluster/home

Doing juv run will fail while trying to create links:

[cvaske]$ juv run quak-profile.ipynb
Reading inline script metadata from `stdin`
Traceback (most recent call last):
  File "<string>", line 56, in <module>
OSError: [Errno 18] Invalid cross-device link: '/cluster/home/cvaske/.cache/uv/archive-v0/8boOMyuaDFqxXAS-p_VHI/share/jupyter/labextensions/@jupyter-widgets/jupyterlab-manager/install.json' -> '/data/tmp/tmpvens5a8t/jupyter/labextensions/@jupyter-widgets/jupyterlab-manager/install.json'

Because hard links do not work across devices. Potentially, symbolic link could be created instead.

manzt commented 2 hours ago

Thanks for reporting the issue.

We need to create an temporary directory were we merge the contents of uv's layered virtual envs (from their cache) for Jupyter (otherwise plugins, widgets won't work). We don't need to use the TEMPDIR and could probably use our own cache (e.g., ~/.cache/juv/jupyter).