Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install script failing with yarn workspaces #1434

Closed
MixMasterMitch opened this issue Jul 9, 2021 · 5 comments
Closed

Install script failing with yarn workspaces #1434

MixMasterMitch opened this issue Jul 9, 2021 · 5 comments

Comments

@MixMasterMitch
Copy link

I am getting the following error in my yarn workspace when I disable all hoisting (e.g. nohoist: ['**/**'])

error /Users/username/Github/repo/packages/A/node_modules/esbuild, /Users/username/Github/repo/packages/B/node_modules/esbuild, /Users/username/Github/repo/packages/C/node_modules/A/node_modules/esbuild: Command failed.
Exit code: 1
Command: node install.js
Arguments:
Directory: /Users/username/Github/repo/packages/A/node_modules/esbuild
Output:
/Users/username/Github/repo/packages/A/node_modules/esbuild/install.js:198
      throw e;
      ^

Error: ENOENT: no such file or directory, rename '/Users/username/Github/repo/packages/A/node_modules/esbuild/bin/esbuild__' -> '/Users/username/Github/repo/packages/A/node_modules/esbuild/bin/esbuild'
    at Object.renameSync (fs.js:772:3)
    at /Users/username/Github/repo/packages/A/node_modules/esbuild/install.js:197:78
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  errno: -2,
  syscall: 'rename',
  code: 'ENOENT',

As a workaround, I have refined my hoisting so that esbuild is hoisted, but it still seems like esbuild install script should function in either case.

@evanw
Copy link
Owner

evanw commented Jul 9, 2021

Could you provide a simple self-contained code sample that demonstrates the problem? I don't use Yarn and don't know what hoisting is or how to set it up myself.

It also seems strange that hoisting would break esbuild's install script since esbuild doesn't have any dependencies and hoisting seems to be about dependencies. The call to renameSync(A, ...) should follow a call to either copyFileSync(..., A) or writeFileSync(A, ...) so it's not clear to me why that file doesn't exist.

@MixMasterMitch
Copy link
Author

I attempted to replicate the issue with a minimal repo example and ... there was no issue.

Back in the repo exhibiting the issue, I realized that I hadn't tried deleting the yarn.lock file. Deleting it resolved the issue for me. So for any future person stumbling across this issue:

Delete the yarn.lock file

@MixMasterMitch
Copy link
Author

I ran into the same issue again and this time deleting the yarn.lock file didn't work. When the failure happens it looks like yarn is installing esbuild multiple times in parallel right before failing. There is a similar issue with node-gyp here: yarnpkg/yarn#1874

I ran yarn global add esbuild and then my subsequent yarn install in my repo was successful (but maybe I just got lucky).

Could the esbuild install script be made more idempotent / thread safe?

@MixMasterMitch MixMasterMitch reopened this Jul 9, 2021
@MixMasterMitch
Copy link
Author

MixMasterMitch commented Jul 9, 2021

Ah I also just discovered that I was using different versions of esbuild across packages (0.11.23 and 0.12.15). I just upgraded them all to the latest version. I suspect that was a major contributor to the problem. Feel free to close unless you want to try to take further action.

@evanw
Copy link
Owner

evanw commented Sep 21, 2021

I'm going to close this since this is no longer a problem for you and since the installation strategy is about to change: #1621.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants