Skip to main content

Don’t allow creating venvs in the root of volumes

ID
56fc369
date
2025-04-23 07:44:18+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
23cc5b3
message
Don't allow creating venvs in the root of volumes
changed files
1 file, 8 additions

Changed files

fish_functions/venv.fish (1142) → fish_functions/venv.fish (1457)

diff --git a/fish_functions/venv.fish b/fish_functions/venv.fish
index 4327dd4..63b70f8 100644
--- a/fish_functions/venv.fish
+++ b/fish_functions/venv.fish
@@ -14,6 +14,14 @@ function venv --description "Create and activate a new virtual environment"
     if test "$PWD" = "$HOME"
         cd $(mktemp -d)
     end
+    
+    # I never want to create a virtual environment in the top level of
+    # one of my external volumes; block it if I try -- it means I've
+    # run a command in the wrong directory.
+    if test (dirname "$PWD") = "/Volumes"
+        print_error "Can’t create a virtualenv in $PWD!"
+        return 1
+    end
 
     print_info "Creating virtual environment in "(pwd)"/.venv"
     uv venv --quiet .venv