File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -144,6 +144,7 @@ pub(crate) async fn pin(
144
144
let Some ( config_dir) = user_uv_config_dir ( ) else {
145
145
return Err ( anyhow:: anyhow!( "No user-level config directory found." ) ) ;
146
146
} ;
147
+ fs_err:: tokio:: create_dir_all ( & config_dir) . await ?;
147
148
PythonVersionFile :: new ( config_dir. join ( PYTHON_VERSION_FILENAME ) )
148
149
. with_versions ( vec ! [ request] )
149
150
} else {
Original file line number Diff line number Diff line change @@ -328,6 +328,31 @@ fn python_pin_global_use_local_if_available() -> Result<()> {
328
328
Ok ( ( ) )
329
329
}
330
330
331
+ #[ test]
332
+ fn python_pin_global_creates_parent_dirs ( ) {
333
+ let context: TestContext = TestContext :: new_with_versions ( & [ "3.12" ] ) ;
334
+ let uv_global_config_dir = context. user_config_dir . child ( "uv" ) ;
335
+
336
+ assert ! (
337
+ !uv_global_config_dir. exists( ) ,
338
+ "Global config directory should not exist yet."
339
+ ) ;
340
+
341
+ uv_snapshot ! ( context. filters( ) , context. python_pin( ) . arg( "3.12" ) . arg( "--global" ) , @r"
342
+ success: true
343
+ exit_code: 0
344
+ ----- stdout -----
345
+ Pinned `[UV_USER_CONFIG_DIR]/.python-version` to `3.12`
346
+
347
+ ----- stderr -----
348
+ " ) ;
349
+
350
+ assert ! (
351
+ uv_global_config_dir. exists( ) ,
352
+ "Global config directory should be automatically created (if missing) after global pin."
353
+ ) ;
354
+ }
355
+
331
356
/// We do not need a Python interpreter to pin without `--resolved`
332
357
/// (skip on Windows because the snapshot is different and the behavior is not platform dependent)
333
358
#[ cfg( unix) ]
You can’t perform that action at this time.
0 commit comments