Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/uv/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ impl RunSettings {
// Resolve flags from CLI and environment variables.
let locked = resolve_flag(locked, "locked", environment.locked);
let frozen = resolve_flag(frozen, "frozen", environment.frozen);
let no_sync = resolve_flag(no_sync, "no-sync", environment.no_sync);

// Check for conflicts between locked and frozen.
check_conflicts(locked, frozen);
Expand Down Expand Up @@ -677,7 +678,7 @@ impl RunSettings {
all_packages,
package,
no_project,
no_sync,
no_sync: no_sync.is_enabled(),
active: flag(active, no_active, "active"),
python: python.and_then(Maybe::into_option),
python_platform,
Expand Down
59 changes: 59 additions & 0 deletions crates/uv/tests/it/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2433,6 +2433,65 @@ fn run_no_sync() -> Result<()> {
Ok(())
}

/// Test that `UV_NO_SYNC=1` environment variable works for `uv run`.
///
/// See: <https://github.com/astral-sh/uv/issues/17390>
#[test]
fn run_no_sync_env_var() -> Result<()> {
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 = ["anyio==3.7.0"]

[build-system]
requires = ["setuptools>=42"]
build-backend = "setuptools.build_meta"
"#,
)?;

// Running with `UV_NO_SYNC=1` should succeed, even if the lockfile isn't present.
uv_snapshot!(context.filters(), context.run().env(EnvVars::UV_NO_SYNC, "1").arg("--").arg("python").arg("--version"), @r###"
success: true
exit_code: 0
----- stdout -----
Python 3.12.[X]

----- stderr -----
"###);

context.lock().assert().success();

// Running with `UV_NO_SYNC=1` should not install any requirements.
uv_snapshot!(context.filters(), context.run().env(EnvVars::UV_NO_SYNC, "1").arg("--").arg("python").arg("--version"), @r###"
success: true
exit_code: 0
----- stdout -----
Python 3.12.[X]

----- stderr -----
"###);

context.sync().assert().success();

// But it should have access to the installed packages.
uv_snapshot!(context.filters(), context.run().env(EnvVars::UV_NO_SYNC, "1").arg("--").arg("python").arg("-c").arg("import anyio; print(anyio.__name__)"), @r###"
success: true
exit_code: 0
----- stdout -----
anyio

----- stderr -----
"###);

Ok(())
}

#[test]
fn run_empty_requirements_txt() -> Result<()> {
let context = TestContext::new("3.12");
Expand Down