diff --git a/CHANGELOG.md b/CHANGELOG.md index 83541734b9..6fba204d69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa [#6611](https://github.com/yarnpkg/yarn/pull/6611) - [**Jack Zhao**](https://github.com/bugzpodder) +- Fixes an issue with how symlinks are setup into the cache on Windows + + [#6621](https://github.com/yarnpkg/yarn/pull/6621) - [**Yoad Snapir**](https://github.com/yoadsn) + ## 1.12.1 - Ensures the engine check is ran before showing the UI for `upgrade-interactive` diff --git a/__tests__/fixtures/cache/corrupted/.yarn-cache/v3/corrupted-meta-empty/node_modules/corrupted-meta-empty/.yarn-metadata.json b/__tests__/fixtures/cache/corrupted/.yarn-cache/v4/corrupted-meta-empty/node_modules/corrupted-meta-empty/.yarn-metadata.json similarity index 100% rename from __tests__/fixtures/cache/corrupted/.yarn-cache/v3/corrupted-meta-empty/node_modules/corrupted-meta-empty/.yarn-metadata.json rename to __tests__/fixtures/cache/corrupted/.yarn-cache/v4/corrupted-meta-empty/node_modules/corrupted-meta-empty/.yarn-metadata.json diff --git a/__tests__/fixtures/cache/corrupted/.yarn-cache/v3/corrupted-meta-not-existing/node_modules/corrupted-meta-not-existing/.gitkeep b/__tests__/fixtures/cache/corrupted/.yarn-cache/v4/corrupted-meta-not-existing/node_modules/corrupted-meta-not-existing/.gitkeep similarity index 100% rename from __tests__/fixtures/cache/corrupted/.yarn-cache/v3/corrupted-meta-not-existing/node_modules/corrupted-meta-not-existing/.gitkeep rename to __tests__/fixtures/cache/corrupted/.yarn-cache/v4/corrupted-meta-not-existing/node_modules/corrupted-meta-not-existing/.gitkeep diff --git a/__tests__/fixtures/cache/corrupted/.yarn-cache/v3/corrupted-meta-typo/node_modules/corrupted-meta-typo/.yarn-metadata.json b/__tests__/fixtures/cache/corrupted/.yarn-cache/v4/corrupted-meta-typo/node_modules/corrupted-meta-typo/.yarn-metadata.json similarity index 100% rename from __tests__/fixtures/cache/corrupted/.yarn-cache/v3/corrupted-meta-typo/node_modules/corrupted-meta-typo/.yarn-metadata.json rename to __tests__/fixtures/cache/corrupted/.yarn-cache/v4/corrupted-meta-typo/node_modules/corrupted-meta-typo/.yarn-metadata.json diff --git a/__tests__/fixtures/cache/corrupted/.yarn-cache/v3/good/node_modules/good/.yarn-metadata.json b/__tests__/fixtures/cache/corrupted/.yarn-cache/v4/good/node_modules/good/.yarn-metadata.json similarity index 100% rename from __tests__/fixtures/cache/corrupted/.yarn-cache/v3/good/node_modules/good/.yarn-metadata.json rename to __tests__/fixtures/cache/corrupted/.yarn-cache/v4/good/node_modules/good/.yarn-metadata.json diff --git a/src/constants.js b/src/constants.js index e93a098c59..cb4f587288 100644 --- a/src/constants.js +++ b/src/constants.js @@ -28,7 +28,7 @@ export const YARN_INSTALLER_MSI = 'https://yarnpkg.com/latest.msi'; export const SELF_UPDATE_VERSION_URL = 'https://yarnpkg.com/latest-version'; // cache version, bump whenever we make backwards incompatible changes -export const CACHE_VERSION = 3; +export const CACHE_VERSION = 4; // lockfile version, bump whenever we make backwards incompatible changes export const LOCKFILE_VERSION = 1; diff --git a/src/fetchers/base-fetcher.js b/src/fetchers/base-fetcher.js index 94b43fbea4..e5e7b38aef 100644 --- a/src/fetchers/base-fetcher.js +++ b/src/fetchers/base-fetcher.js @@ -9,7 +9,9 @@ import normalizeManifest from '../util/normalize-manifest/index.js'; import {makePortableProxyScript} from '../util/portable-script.js'; import * as constants from '../constants.js'; import * as fs from '../util/fs.js'; +import lockMutex from '../util/mutex.js'; +const cmdShim = require('@zkochan/cmd-shim'); const path = require('path'); export default class BaseFetcher { @@ -77,7 +79,16 @@ export default class BaseFetcher { } await fs.mkdirp(binDest); - await fs.symlink(src, `${binDest}/${binName}`); + if (process.platform === 'win32') { + const unlockMutex = await lockMutex(src); + try { + await cmdShim.ifExists(src, `${binDest}/${binName}`); + } finally { + unlockMutex(); + } + } else { + await fs.symlink(src, `${binDest}/${binName}`); + } } }