Skip to main content

Fix a warning about copying files on external volumes

ID
23cc5b3
date
2025-04-23 07:44:09+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
f788958
message
Fix a warning about copying files on external volumes
changed files
1 file, 19 additions, 1 deletion

Changed files

fish_functions/pip_sync.fish (713) → fish_functions/pip_sync.fish (1521)

diff --git a/fish_functions/pip_sync.fish b/fish_functions/pip_sync.fish
index 16ef1f4..0b0f093 100644
--- a/fish_functions/pip_sync.fish
+++ b/fish_functions/pip_sync.fish
@@ -12,8 +12,26 @@ function pip_sync --description "Make a virtualenv dependencies look like requir
         venv
     end
     
-    echo ""
+    # If we're on an external disk, disable the warning about being
+    # unable to clone files.  In particular:
+    #
+    #     warning: Failed to clone files; falling back to full copy.
+    #     This may lead to degraded performance.  If the cache and target 
+    #     directories are on different filesystems, reflinking may not
+    #     be supported.
+    #
+    #     If this is intentional, set `export UV_LINK_MODE=copy` or use 
+    #     `--link-mode=copy` to suppress this warning.
+    #
+    # On macOS, this means "are you in a path that starts with /Volumes".
+    if string match -q "/Volumes/*" "$PWD"
+        set UV_LINK_MODE copy
+    end
 
+    # Actually run the `uv pip sync` command.
+    #
+    # If a dev_requirements.txt file is available, use that, otherwise use 
+    # the standard `requirements.txt`.
     if test \( -e dev_requirements.txt \)
         ~/repos/scripts/debug/print_info "-> uv pip sync dev_requirements.txt"
         uv pip sync dev_requirements.txt