Skip to content

Commit 4e3b2f6

Browse files
yoadsnarcanis
authored andcommitted
fix: Use cmdshim instead of symlink on win32 in base-fetcher (#6621)
* fix: Use cmdshim instead of symlink on win32 in base-fetcher * Update CHANGELOG * Bumps the cache key * Use cmdShim.ifExists to handle missing src like symlink (ignores) * Update CHANGELOG.md
1 parent 4177b08 commit 4e3b2f6

File tree

7 files changed

+17
-2
lines changed

7 files changed

+17
-2
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa
1616

1717
[#6611](https://github.com/yarnpkg/yarn/pull/6611) - [**Jack Zhao**](https://github.com/bugzpodder)
1818

19+
- Fixes an issue with how symlinks are setup into the cache on Windows
20+
21+
[#6621](https://github.com/yarnpkg/yarn/pull/6621) - [**Yoad Snapir**](https://github.com/yoadsn)
22+
1923
## 1.12.1
2024

2125
- Ensures the engine check is ran before showing the UI for `upgrade-interactive`

src/constants.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const YARN_INSTALLER_MSI = 'https://yarnpkg.com/latest.msi';
2828
export const SELF_UPDATE_VERSION_URL = 'https://yarnpkg.com/latest-version';
2929

3030
// cache version, bump whenever we make backwards incompatible changes
31-
export const CACHE_VERSION = 3;
31+
export const CACHE_VERSION = 4;
3232

3333
// lockfile version, bump whenever we make backwards incompatible changes
3434
export const LOCKFILE_VERSION = 1;

src/fetchers/base-fetcher.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import normalizeManifest from '../util/normalize-manifest/index.js';
99
import {makePortableProxyScript} from '../util/portable-script.js';
1010
import * as constants from '../constants.js';
1111
import * as fs from '../util/fs.js';
12+
import lockMutex from '../util/mutex.js';
1213

14+
const cmdShim = require('@zkochan/cmd-shim');
1315
const path = require('path');
1416

1517
export default class BaseFetcher {
@@ -77,7 +79,16 @@ export default class BaseFetcher {
7779
}
7880

7981
await fs.mkdirp(binDest);
80-
await fs.symlink(src, `${binDest}/${binName}`);
82+
if (process.platform === 'win32') {
83+
const unlockMutex = await lockMutex(src);
84+
try {
85+
await cmdShim.ifExists(src, `${binDest}/${binName}`);
86+
} finally {
87+
unlockMutex();
88+
}
89+
} else {
90+
await fs.symlink(src, `${binDest}/${binName}`);
91+
}
8192
}
8293
}
8394

0 commit comments

Comments
 (0)