File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ use fs_err as fs;
1010use fs_err:: File ;
1111use itertools:: Itertools ;
1212use owo_colors:: OwoColorize ;
13- use tracing:: debug;
13+ use tracing:: { debug, trace } ;
1414
1515use uv_configuration:: PreviewMode ;
1616use uv_fs:: { CWD , Simplified , cachedir} ;
@@ -85,6 +85,18 @@ pub(crate) fn create(
8585 format ! ( "File exists at `{}`" , location. user_display( ) ) ,
8686 ) ) ) ;
8787 }
88+ Ok ( metadata)
89+ if metadata. is_dir ( )
90+ && location
91+ . read_dir ( )
92+ . is_ok_and ( |mut dir| dir. next ( ) . is_none ( ) ) =>
93+ {
94+ // If it's an empty directory, we can proceed
95+ trace ! (
96+ "Using empty directory at `{}` for virtual environment" ,
97+ location. user_display( )
98+ ) ;
99+ }
88100 Ok ( metadata) if metadata. is_dir ( ) => {
89101 let name = if uv_fs:: is_virtualenv_base ( location) {
90102 "virtual environment"
@@ -100,13 +112,6 @@ pub(crate) fn create(
100112 remove_virtualenv ( location) ?;
101113 fs:: create_dir_all ( location) ?;
102114 }
103- OnExisting :: Fail
104- if location
105- . read_dir ( )
106- . is_ok_and ( |mut dir| dir. next ( ) . is_none ( ) ) =>
107- {
108- debug ! ( "Ignoring empty directory" ) ;
109- }
110115 OnExisting :: Fail => {
111116 match confirm_clear ( location, name) ? {
112117 Some ( true ) => {
You can’t perform that action at this time.
0 commit comments