From 792bbb4e874fc243fed81e9b8580bde752736aae Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Sun, 24 Mar 2024 09:51:57 +0100 Subject: [PATCH] fix(yarn): revert default proxy behavior (#28100) --- docs/usage/self-hosted-experimental.md | 4 ++-- lib/modules/manager/npm/post-update/yarn.spec.ts | 2 ++ lib/modules/manager/npm/post-update/yarn.ts | 2 +- lib/modules/manager/npm/readme.md | 7 ++++--- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/docs/usage/self-hosted-experimental.md b/docs/usage/self-hosted-experimental.md index bd95401a8c..d7d7348927 100644 --- a/docs/usage/self-hosted-experimental.md +++ b/docs/usage/self-hosted-experimental.md @@ -177,6 +177,6 @@ Don't combine with `redisUrl`, Redis would be preferred over SQlite. Suppress the pre-commit support warning in PR bodies. -## `RENOVATE_X_YARN_IGNORE_PROXY` +## `RENOVATE_X_YARN_PROXY` -Skip configuring global Yarn proxy settings if HTTP proxy environment variables are detected. +Configure global Yarn proxy settings if HTTP proxy environment variables are detected. diff --git a/lib/modules/manager/npm/post-update/yarn.spec.ts b/lib/modules/manager/npm/post-update/yarn.spec.ts index 54ff7db991..d1e01dc27a 100644 --- a/lib/modules/manager/npm/post-update/yarn.spec.ts +++ b/lib/modules/manager/npm/post-update/yarn.spec.ts @@ -48,6 +48,7 @@ describe('modules/manager/npm/post-update/yarn', () => { delete process.env.BUILDPACK; delete process.env.HTTP_PROXY; delete process.env.HTTPS_PROXY; + delete process.env.RENOVATE_X_YARN_PROXY; Fixtures.reset(); GlobalConfig.set({ localDir: '.', cacheDir: '/tmp/cache' }); removeDockerContainer.mockResolvedValue(); @@ -152,6 +153,7 @@ describe('modules/manager/npm/post-update/yarn', () => { it('sets http proxy', async () => { process.env.HTTP_PROXY = 'http://proxy'; process.env.HTTPS_PROXY = 'http://proxy'; + process.env.RENOVATE_X_YARN_PROXY = 'true'; GlobalConfig.set({ localDir: '.', allowScripts: true, diff --git a/lib/modules/manager/npm/post-update/yarn.ts b/lib/modules/manager/npm/post-update/yarn.ts index fe4d57a3ba..3334a8d616 100644 --- a/lib/modules/manager/npm/post-update/yarn.ts +++ b/lib/modules/manager/npm/post-update/yarn.ts @@ -210,7 +210,7 @@ export async function generateLockFile( commands.push(`yarn set version ${quote(yarnUpdate.newValue!)}`); } - if (!process.env.RENOVATE_X_YARN_IGNORE_PROXY) { + if (process.env.RENOVATE_X_YARN_PROXY) { if (process.env.HTTP_PROXY && !isYarn1) { commands.push('yarn config unset --home httpProxy'); commands.push( diff --git a/lib/modules/manager/npm/readme.md b/lib/modules/manager/npm/readme.md index aa0be6c827..a5d8549e57 100644 --- a/lib/modules/manager/npm/readme.md +++ b/lib/modules/manager/npm/readme.md @@ -17,9 +17,10 @@ If Renovate detects a `packageManager` setting for Yarn in `package.json` then i #### HTTP Proxy Support Yarn itself does not natively recognize/support the `HTTP_PROXY` and `HTTPS_PROXY` environment variables. -If Renovate detects Yarn 2+, and one or both of those variables are present, then it will run commands like `yarn config set --home httpProxy http://proxy` prior to executing `yarn install`. + +You can configure `RENOVATE_X_YARN_PROXY=true` as an environment variable to enable configuring of Yarn proxy (e.g. if you cannot configure these proxy settings yourself in `~/.yarnrc.yml`). + +If set, and Renovate detects Yarn 2+, and one or both of those variables are present, then Renovate will run commands like `yarn config set --home httpProxy http://proxy` prior to executing `yarn install`. This will result in the `~/.yarnrc.yml` file being created or modified with these settings, and the settings are not removed afterwards. Configuration/conversion of `NO_PROXY` to Yarn config is not supported. - -You can configure `RENOVATE_X_YARN_IGNORE_PROXY=true` as an environment variable to skip the configuring of Yarn proxy (e.g. if you already configure these proxy settings yourself in `~/.yarnrc.yml`); -- GitLab