diff --git a/cachi2/core/package_managers/yarn/main.py b/cachi2/core/package_managers/yarn/main.py index 3eb602137..664d49d1c 100644 --- a/cachi2/core/package_managers/yarn/main.py +++ b/cachi2/core/package_managers/yarn/main.py @@ -228,7 +228,9 @@ def _generate_environment_variables() -> list[EnvironmentVariable]: def _verify_corepack_yarn_version(expected_version: semver.Version, source_dir: RootedPath) -> None: """Verify that corepack installed the correct version of yarn by checking `yarn --version`.""" - installed_yarn_version = run_yarn_cmd(["--version"], source_dir).strip() + installed_yarn_version = run_yarn_cmd( + ["--version"], source_dir, env={"COREPACK_ENABLE_DOWNLOAD_PROMPT": "0"} + ).strip() try: if installed_yarn_version != expected_version: raise PackageManagerError( diff --git a/tests/unit/package_managers/yarn/test_main.py b/tests/unit/package_managers/yarn/test_main.py index c9f9aa94e..99d861755 100644 --- a/tests/unit/package_managers/yarn/test_main.py +++ b/tests/unit/package_managers/yarn/test_main.py @@ -151,7 +151,9 @@ def test_corepack_installed_correct_yarn_version( mock_run_yarn_cmd.return_value = corepack_yarn_version _verify_corepack_yarn_version(expected_yarn_version, rooted_tmp_path) - mock_run_yarn_cmd.assert_called_once_with(["--version"], rooted_tmp_path) + mock_run_yarn_cmd.assert_called_once_with( + ["--version"], rooted_tmp_path, env={"COREPACK_ENABLE_DOWNLOAD_PROMPT": "0"} + ) @pytest.mark.parametrize( @@ -173,7 +175,9 @@ def test_corepack_installed_correct_yarn_version_fail( with pytest.raises(PackageManagerError): _verify_corepack_yarn_version(expected_yarn_version, rooted_tmp_path) - mock_run_yarn_cmd.assert_called_once_with(["--version"], rooted_tmp_path) + mock_run_yarn_cmd.assert_called_once_with( + ["--version"], rooted_tmp_path, env={"COREPACK_ENABLE_DOWNLOAD_PROMPT": "0"} + ) @pytest.mark.parametrize(