Revert "Make it warn_user_once"

This reverts commit f05a529969.
This commit is contained in:
Charlie Marsh 2025-07-02 13:31:39 -04:00
parent f05a529969
commit 2c443000e5
10 changed files with 77 additions and 25 deletions

View file

@ -25,7 +25,7 @@ use tempfile::TempDir;
use tokio::io::AsyncBufReadExt;
use tokio::process::Command;
use tokio::sync::{Mutex, Semaphore};
use tracing::{Instrument, debug, info_span, instrument};
use tracing::{Instrument, debug, info_span, instrument, warn};
use uv_cache_key::cache_digest;
use uv_configuration::PreviewMode;
@ -459,7 +459,7 @@ impl SourceBuild {
source_tree_lock = LockedFile::acquire(lock_path, self.source_tree.to_string_lossy())
.await
.inspect_err(|err| {
warn_user_once!("Failed to acquire build lock: {err}");
warn!("Failed to acquire build lock: {err}");
})
.ok();
}

View file

@ -5,7 +5,7 @@ use std::path::PathBuf;
use anyhow::Context;
use itertools::Itertools;
use owo_colors::OwoColorize;
use tracing::{Level, debug, enabled};
use tracing::{Level, debug, enabled, warn};
use uv_cache::Cache;
use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder};
@ -36,7 +36,7 @@ use uv_resolver::{
};
use uv_torch::{TorchMode, TorchStrategy};
use uv_types::{BuildIsolation, HashStrategy};
use uv_warnings::{warn_user, warn_user_once};
use uv_warnings::warn_user;
use uv_workspace::WorkspaceCache;
use crate::commands::pip::loggers::{DefaultInstallLogger, DefaultResolveLogger, InstallLogger};
@ -240,7 +240,7 @@ pub(crate) async fn pip_install(
.lock()
.await
.inspect_err(|err| {
warn_user_once!("Failed to acquire environment lock: {err}");
warn!("Failed to acquire environment lock: {err}");
})
.ok();

View file

@ -3,7 +3,7 @@ use std::fmt::Write;
use anyhow::{Context, Result};
use owo_colors::OwoColorize;
use tracing::debug;
use tracing::{debug, warn};
use uv_cache::Cache;
use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder};
@ -30,7 +30,7 @@ use uv_resolver::{
};
use uv_torch::{TorchMode, TorchStrategy};
use uv_types::{BuildIsolation, HashStrategy};
use uv_warnings::{warn_user, warn_user_once};
use uv_warnings::warn_user;
use uv_workspace::WorkspaceCache;
use crate::commands::pip::loggers::{DefaultInstallLogger, DefaultResolveLogger};
@ -215,7 +215,7 @@ pub(crate) async fn pip_sync(
.lock()
.await
.inspect_err(|err| {
warn_user_once!("Failed to acquire environment lock: {err}");
warn!("Failed to acquire environment lock: {err}");
})
.ok();

View file

@ -3,7 +3,7 @@ use std::fmt::Write;
use anyhow::Result;
use itertools::{Either, Itertools};
use owo_colors::OwoColorize;
use tracing::debug;
use tracing::{debug, warn};
use uv_cache::Cache;
use uv_client::BaseClientBuilder;
@ -17,7 +17,6 @@ use uv_python::EnvironmentPreference;
use uv_python::PythonRequest;
use uv_python::{Prefix, PythonEnvironment, Target};
use uv_requirements::{RequirementsSource, RequirementsSpecification};
use uv_warnings::warn_user_once;
use crate::commands::pip::operations::report_target_environment;
use crate::commands::{ExitStatus, elapsed};
@ -105,7 +104,7 @@ pub(crate) async fn pip_uninstall(
.lock()
.await
.inspect_err(|err| {
warn_user_once!("Failed to acquire environment lock: {err}");
warn!("Failed to acquire environment lock: {err}");
})
.ok();

View file

@ -10,7 +10,7 @@ use anyhow::{Context, Result, bail};
use itertools::Itertools;
use owo_colors::OwoColorize;
use rustc_hash::{FxBuildHasher, FxHashMap};
use tracing::debug;
use tracing::{debug, warn};
use url::Url;
use uv_cache::Cache;
@ -323,7 +323,7 @@ pub(crate) async fn add(
.acquire_lock()
.await
.inspect_err(|err| {
warn_user_once!("Failed to acquire environment lock: {err}");
warn!("Failed to acquire environment lock: {err}");
})
.ok();

View file

@ -1247,7 +1247,7 @@ impl ProjectEnvironment {
let _lock = ProjectInterpreter::lock(workspace)
.await
.inspect_err(|err| {
warn_user_once!("Failed to acquire project environment lock: {err}");
warn!("Failed to acquire project environment lock: {err}");
})
.ok();
@ -1470,7 +1470,7 @@ impl ScriptEnvironment {
let _lock = ScriptInterpreter::lock(script)
.await
.inspect_err(|err| {
warn_user_once!("Failed to acquire script environment lock: {err}");
warn!("Failed to acquire script environment lock: {err}");
})
.ok();

View file

@ -5,7 +5,7 @@ use std::str::FromStr;
use anyhow::{Context, Result};
use owo_colors::OwoColorize;
use tracing::debug;
use tracing::{debug, warn};
use uv_cache::Cache;
use uv_configuration::{
@ -285,7 +285,7 @@ pub(crate) async fn remove(
.acquire_lock()
.await
.inspect_err(|err| {
warn_user_once!("Failed to acquire environment lock: {err}");
warn!("Failed to acquire environment lock: {err}");
})
.ok();

View file

@ -37,7 +37,7 @@ use uv_scripts::Pep723Item;
use uv_settings::PythonInstallMirrors;
use uv_shell::runnable::WindowsRunnable;
use uv_static::EnvVars;
use uv_warnings::{warn_user, warn_user_once};
use uv_warnings::warn_user;
use uv_workspace::{DiscoveryOptions, VirtualProject, Workspace, WorkspaceCache, WorkspaceError};
use crate::commands::pip::loggers::{
@ -244,7 +244,7 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
.lock()
.await
.inspect_err(|err| {
warn_user_once!("Failed to acquire environment lock: {err}");
warn!("Failed to acquire environment lock: {err}");
})
.ok();
@ -396,7 +396,7 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
.lock()
.await
.inspect_err(|err| {
warn_user_once!("Failed to acquire environment lock: {err}");
warn!("Failed to acquire environment lock: {err}");
})
.ok();
@ -715,7 +715,7 @@ hint: If you are running a script with `{}` in the shebang, you may need to incl
.lock()
.await
.inspect_err(|err| {
warn_user_once!("Failed to acquire environment lock: {err}");
warn!("Failed to acquire environment lock: {err}");
})
.ok();

View file

@ -6,6 +6,7 @@ use std::sync::Arc;
use anyhow::{Context, Result};
use itertools::Itertools;
use owo_colors::OwoColorize;
use tracing::warn;
use uv_cache::Cache;
use uv_client::{BaseClientBuilder, FlatIndexClient, RegistryClientBuilder};
@ -28,7 +29,7 @@ use uv_resolver::{FlatIndex, Installable, Lock};
use uv_scripts::{Pep723ItemRef, Pep723Script};
use uv_settings::PythonInstallMirrors;
use uv_types::{BuildIsolation, HashStrategy};
use uv_warnings::{warn_user, warn_user_once};
use uv_warnings::warn_user;
use uv_workspace::pyproject::Source;
use uv_workspace::{DiscoveryOptions, MemberDiscovery, VirtualProject, Workspace, WorkspaceCache};
@ -173,7 +174,7 @@ pub(crate) async fn sync(
.lock()
.await
.inspect_err(|err| {
warn_user_once!("Failed to acquire environment lock: {err}");
warn!("Failed to acquire environment lock: {err}");
})
.ok();

View file

@ -3,13 +3,14 @@ use assert_cmd::prelude::*;
use assert_fs::{fixture::ChildPath, prelude::*};
use indoc::{formatdoc, indoc};
use insta::assert_snapshot;
use crate::common::{TestContext, download_to_disk, packse_index_url, uv_snapshot, venv_bin_path};
use predicates::prelude::predicate;
use tempfile::tempdir_in;
use uv_fs::Simplified;
use uv_static::EnvVars;
use crate::common::{TestContext, download_to_disk, packse_index_url, uv_snapshot, venv_bin_path};
#[test]
fn sync() -> Result<()> {
let context = TestContext::new("3.12");
@ -9989,3 +9990,54 @@ fn sync_url_with_query_parameters() -> Result<()> {
Ok(())
}
#[test]
#[cfg(unix)]
fn read_only() -> Result<()> {
use std::os::unix::fs::PermissionsExt;
let context = TestContext::new("3.12");
let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(
r#"
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = ["iniconfig"]
"#,
)?;
uv_snapshot!(context.filters(), context.sync(), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Resolved 2 packages in [TIME]
Prepared 1 package in [TIME]
Installed 1 package in [TIME]
+ iniconfig==2.0.0
"###);
assert!(context.temp_dir.child("uv.lock").exists());
// Remove the flock.
fs_err::remove_file(context.venv.child(".lock"))?;
// Make the virtual environment read and execute (but not write).
fs_err::set_permissions(&context.venv, std::fs::Permissions::from_mode(0o555))?;
uv_snapshot!(context.filters(), context.sync(), @r"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Resolved 2 packages in [TIME]
Audited 1 package in [TIME]
");
Ok(())
}