yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.37k stars 2.72k forks source link

fatal: Destination path 'xxx' already exists and is not an empty directory. #8947

Open toFrankie opened 1 year ago

toFrankie commented 1 year ago
$ yarn
yarn run v1.22.19
$ minci build --env development
(node:10334) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
✔ 移除产出目录
✔ 构建项目
✖ 构建 NPM
Error: Command failed: cd /Users/frankie/Web/ifanr/zhongshan-trade-union/miniprogram/src && yarn install --production
error Command failed.
Exit code: 128
Command: git
Arguments: clone https://github.com/rchunping/wxapp-google-analytics.git /Users/frankie/Library/Caches/Yarn/v6/.tmp/e186f3a46d966ecd612948ea9438aed5
Directory: /Users/frankie/Web/ifanr/zhongshan-trade-union/miniprogram/src
Output:
致命错误:不能创建工作区目录 '/Users/frankie/Library/Caches/Yarn/v6/.tmp/e186f3a46d966ecd612948ea9438aed5': File exists

    at ChildProcess.exithandler (node:child_process:412:12)
    at ChildProcess.emit (node:events:513:28)
    at ChildProcess.emit (node:domain:489:12)
    at maybeClose (node:internal/child_process:1091:16)
    at Socket.<anonymous> (node:internal/child_process:449:11)
    at Socket.emit (node:events:513:28)
    at Socket.emit (node:domain:489:12)
    at Pipe.<anonymous> (node:net:313:12)
    at Pipe.callbackTrampoline (node:internal/async_hooks:130:17) {
  code: 128,
  killed: false,
  signal: null,
  cmd: 'cd /Users/frankie/Web/ifanr/zhongshan-trade-union/miniprogram/src && yarn install --production',
  stdout: '[1/4] Resolving packages...\n' +
    '[2/4] Fetching packages...\n' +
    'info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.\n',
  stderr: 'error Command failed.\n' +
    'Exit code: 128\n' +
    'Command: git\n' +
    'Arguments: clone https://github.com/rchunping/wxapp-google-analytics.git /Users/frankie/Library/Caches/Yarn/v6/.tmp/e186f3a46d966ecd612948ea9438aed5\n' +
    'Directory: /Users/frankie/Web/ifanr/zhongshan-trade-union/miniprogram/src\n' +
    'Output:\n' +
    "致命错误:不能创建工作区目录 '/Users/frankie/Library/Caches/Yarn/v6/.tmp/e186f3a46d966ecd612948ea9438aed5': File exists\n"
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Here's the thing: I have a package in package.json that was added via the git+https protocol ("wxapp-ga": "git+https://github.com/rchunping/wxapp-google-analytics.git #v1.2.0").

After first yarn install, the directory /Users/frankie/Library/Caches/Yarn/v6/.tmp/e186f3a46d966ecd612948ea9438aed5 already exists locally due to yarn cache. When yarn install again, because git+https is installed through git clone https://github.com/rchunping/wxapp-google-analytics.git /Users/frankie/Library/Caches/Yarn/v6/.tmp/e186f3a46d966ecd612948ea9438aed5, the git clone process will fail, because destination path (xxx/.tmp/e186f3a46d966ecd612948ea9438aed5) already exists, not an empty directory. This will eventually cause yarn install to abort.

At present, only after clearing .tmp/e186f3a46d966ecd612948ea9438aed5 through yarn cache clean or rm -rf Users/frankie/Library/Caches/Yarn/v6/.tmp/e186f3a46d966ecd612948ea9438aed5, yarn install will succeed.

Is there any other better solution?