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

An error occurs when the YARN Workspaces MacOS terminal is used #1655

Closed
TLovers opened this issue Oct 4, 2021 · 9 comments
Closed

An error occurs when the YARN Workspaces MacOS terminal is used #1655

TLovers opened this issue Oct 4, 2021 · 9 comments

Comments

@TLovers
Copy link

TLovers commented Oct 4, 2021

[4/4] 🔨  Building fresh packages...
[8/12]  core-js
[9/12]  highlight.js
[7/12]  esbuild
[4/12]  fsevents
error /Volumes/Code/Nuxt/Jane/Jane/node_modules/esbuild: Command failed.
Exit code: 1
Command: node install.js
Arguments: 
Directory: /Volumes/Code/Nuxt/Jane/Jane/node_modules/esbuild
Output:
node:child_process:867
    throw err;
    ^

<ref *1> Error: spawnSync /Volumes/Code/Nuxt/Jane/Jane/node_modules/esbuild/bin/esbuild ENOENT
    at Object.spawnSync (node:internal/child_process:1083:20)
    at spawnSync (node:child_process:812:24)
    at Object.execFileSync (node:child_process:858:15)
    at validateBinaryVersion (/Volumes/Code/Nuxt/Jane/Jane/node_modules/esbuild/install.js:64:32)
    at Object.<anonymous> (/Volumes/Code/Nuxt/Jane/Jane/node_modules/esbuild/install.js:96:3)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawnSync /Volumes/Code/Nuxt/Jane/Jane/node_modules/esbuild/bin/esbuild',
  path: '/Volumes/Code/Nuxt/Jane/Jane/node_modules/esbuild/bin/esbuild',
  spawnargs: [ '--version' ],
  error: [Circular *1],
  status: null,
  signal: null,
  output: null,
  pid: 9360,

Using vite to initialize the Vue project, I removed all dependencies and re-installed it like this
node v16.9.1
npm 7.21.1

@evanw
Copy link
Owner

evanw commented Oct 4, 2021

Installing esbuild with yarn works for me:

$ echo {} > package.json

$ yarn --silent add esbuild
warning package.json: No license field
warning No license field
warning No license field

$ yarn esbuild --version
yarn run v1.22.15
warning package.json: No license field
$ ./node_modules/.bin/esbuild --version
0.13.3

You'll have to provide more specific instructions for me to be able to reproduce your issue.

@ham-zeal
Copy link

ham-zeal commented Oct 4, 2021

@evanw here's a minimal reproduction https://github.com/ham-zeal/esbuile-13-yar3-error

i misspelled all of that lol

i think this issue is again yarn P'n'P based, i'd be very interested in providing you with an automated test for PnP compatibility if you tell me where you want it.

@evanw
Copy link
Owner

evanw commented Oct 4, 2021

Caveat: I have never used Docker myself.

From what I understand, if you are using Docker then you need to install packages inside Docker instead of outside. If you install packages outside of Docker and then copy the files inside, the binary executable in the installed package may be specific to the wrong OS and/or architecture. See #1170 for an example of someone accidentally doing this.

@ham-zeal
Copy link

ham-zeal commented Oct 4, 2021

i will give some context here:

# download node
FROM node:14-alpine

ARG USER=tester
ARG GROUP=tester
ARG UID=1337
ARG GID=1337

# make app directory
RUN mkdir -p /usr/src/app

# move to app folder
WORKDIR /usr/src/app

# create group, create user w/ home directory, chown home and app dir
RUN addgroup -g $GID -S $GROUP &&\
    adduser -u $UID -S $USER -G $GROUP\
    && chown -R $USER:$GROUP /home/tester \
    && chown -R $USER:$GROUP /usr/src/app

# copy all files into container
# blind copy (see .dockerignore for skipping stuff!)
COPY --chown=$USER:$GROUP . .

# Run everything after as non-privileged user.
USER tester

# setup node isntall steps
ARG NODE_ENV=production
ENV NODE_ENV ${NODE_ENV}

ARG APP_VERSION=develop
ENV APP_VERSION ${APP_VERSION}

# move to app folder
WORKDIR /usr/src/app

when you run this it's pulling alpine 3, copying in all the files, on the step yarn show:fail you enter the container itself, and then you get this failure:

# This file contains the result of Yarn building a package (esbuild@npm:0.13.3)
# Script name: postinstall

child_process.js:830
    throw err;
    ^

<ref *1> Error: spawnSync /usr/src/app/.yarn/unplugged/esbuild-npm-0.13.3-0c72846e03/node_modules/esbuild/lib/yarn-pnp-esbuild Unknown system error -8
    at Object.spawnSync (internal/child_process.js:1077:20)
    at spawnSync (child_process.js:776:24)
    at Object.execFileSync (child_process.js:822:15)
    at Object.<anonymous> (/usr/src/app/.yarn/unplugged/esbuild-npm-0.13.3-0c72846e03/node_modules/esbuild/bin/esbuild:99:26)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.external_module_.Module._load (/usr/src/app/.pnp.cjs:9590:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47 {
  errno: -8,
  code: 'Unknown system error -8',
  syscall: 'spawnSync /usr/src/app/.yarn/unplugged/esbuild-npm-0.13.3-0c72846e03/node_modules/esbuild/lib/yarn-pnp-esbuild',
  path: '/usr/src/app/.yarn/unplugged/esbuild-npm-0.13.3-0c72846e03/node_modules/esbuild/lib/yarn-pnp-esbuild',
  spawnargs: [ '--version' ],
  error: [Circular *1],
  status: null,
  signal: null,
  output: null,
  pid: 51,
  stdout: null,
  stderr: null
}
child_process.js:830
    throw err;
    ^

Error: Command failed: node /usr/src/app/.yarn/unplugged/esbuild-npm-0.13.3-0c72846e03/node_modules/esbuild/bin/esbuild --version
child_process.js:830
    throw err;
    ^

<ref *1> Error: spawnSync /usr/src/app/.yarn/unplugged/esbuild-npm-0.13.3-0c72846e03/node_modules/esbuild/lib/yarn-pnp-esbuild Unknown system error -8
    at Object.spawnSync (internal/child_process.js:1077:20)
    at spawnSync (child_process.js:776:24)
    at Object.execFileSync (child_process.js:822:15)
    at Object.<anonymous> (/usr/src/app/.yarn/unplugged/esbuild-npm-0.13.3-0c72846e03/node_modules/esbuild/bin/esbuild:99:26)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.external_module_.Module._load (/usr/src/app/.pnp.cjs:9590:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47 {
  errno: -8,
  code: 'Unknown system error -8',
  syscall: 'spawnSync /usr/src/app/.yarn/unplugged/esbuild-npm-0.13.3-0c72846e03/node_modules/esbuild/lib/yarn-pnp-esbuild',
  path: '/usr/src/app/.yarn/unplugged/esbuild-npm-0.13.3-0c72846e03/node_modules/esbuild/lib/yarn-pnp-esbuild',
  spawnargs: [ '--version' ],
  error: [Circular *1],
  status: null,
  signal: null,
  output: null,
  pid: 51,
  stdout: null,
  stderr: null
}

    at checkExecSyncError (child_process.js:790:11)
    at Object.execFileSync (child_process.js:827:15)
    at validateBinaryVersion (/usr/src/app/.yarn/unplugged/esbuild-npm-0.13.3-0c72846e03/node_modules/esbuild/install.js:64:32)
    at Object.<anonymous> (/usr/src/app/.yarn/unplugged/esbuild-npm-0.13.3-0c72846e03/node_modules/esbuild/install.js:98:3)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.external_module_.Module._load (/usr/src/app/.pnp.cjs:9590:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47 {
  status: 1,
  signal: null,
  output: [
    null,
    Buffer(0) [Uint8Array] [],
    Buffer(1322) [Uint8Array] [
       99, 104, 105, 108, 100,  95, 112, 114, 111,  99, 101, 115,
      115,  46, 106, 115,  58,  56,  51,  48,  10,  32,  32,  32,
       32, 116, 104, 114, 111, 119,  32, 101, 114, 114,  59,  10,
       32,  32,  32,  32,  94,  10,  10,  60, 114, 101, 102,  32,
       42,  49,  62,  32,  69, 114, 114, 111, 114,  58,  32, 115,
      112,  97, 119, 110,  83, 121, 110,  99,  32,  47, 117, 115,
      114,  47, 115, 114,  99,  47,  97, 112, 112,  47,  46, 121,
       97, 114, 110,  47, 117, 110, 112, 108, 117, 103, 103, 101,
      100,  47, 101, 115,
      ... 1222 more items
    ]
  ],
  pid: 44,
  stdout: Buffer(0) [Uint8Array] [],
  stderr: Buffer(1322) [Uint8Array] [
     99, 104, 105, 108, 100,  95, 112, 114, 111,  99, 101, 115,
    115,  46, 106, 115,  58,  56,  51,  48,  10,  32,  32,  32,
     32, 116, 104, 114, 111, 119,  32, 101, 114, 114,  59,  10,
     32,  32,  32,  32,  94,  10,  10,  60, 114, 101, 102,  32,
     42,  49,  62,  32,  69, 114, 114, 111, 114,  58,  32, 115,
    112,  97, 119, 110,  83, 121, 110,  99,  32,  47, 117, 115,
    114,  47, 115, 114,  99,  47,  97, 112, 112,  47,  46, 121,
     97, 114, 110,  47, 117, 110, 112, 108, 117, 103, 103, 101,
    100,  47, 101, 115,
    ... 1222 more items
  ]

this install is happening inside the container.

to prove it's PnP you can check out this branch, which uses node_modules instead of pnp and it all works. lemme know if you need more info

@TLovers
Copy link
Author

TLovers commented Oct 5, 2021

@eelco
Hi Evanw very glad that you can reply!I tried the same project again on a different computer and did not reproduce the problem I described above.So the problem is on my computer 😄

@evanw evanw removed the unactionable label Oct 5, 2021
@evanw
Copy link
Owner

evanw commented Oct 5, 2021

Issue #1656 was also created recently which may be a duplicate of this issue. I left the comment #1656 (comment) over there that explains what I think is happening in that case and a way to work around it:

I did finally manage to reproduce the problem from scratch, but only by copying files that were already installed on macOS and then running them on Linux. In that case, Yarn's installation process breaks. This documentation seems relevant: https://yarnpkg.com/cli/rebuild/. Specifically this part:

Note that while Yarn forgets the compilation, the previous artifacts aren't erased from the filesystem and may affect the next builds (in good or bad). To avoid this, you may remove the .yarn/unplugged folder, or any other relevant location where packages might have been stored (Yarn may offer a way to do that automatically in the future).

So it looks like yarn's package management isn't idempotent. If you copy a directory tree containing a .yarn/unplugged folder from one OS to another, you need to delete that directory before running yarn again or the package directory may be corrupted. This appears to be by design. So the solution is to run some form of rm -fr .yarn/unplugged before running yarn. I've tried this solution out myself and fixes your issue. You have to delete the .yarn/unplugged folder after copying the files from the non-Linux OS to Linux but before running yarn.

Basically you need to either not copy a post-installed directory tree into Docker or you need to remove the .yarn/unplugged directory and re-run the yarn command inside Docker to re-install the packages for the right OS. Hopefully this issue is also your issue and the fix works for you too. This specific thing is a problem with Yarn, not with esbuild.

@TLovers
Copy link
Author

TLovers commented Oct 5, 2021

@evanw
It should not be the same problem as #1656.

I'm sorry that I did not provide enough information for you, the location of the error code is the install.js line 64, just try to comment out node_modules/esbuild/install.js validateBinaryVersion line 62 function. The code does not report an error

/Volumes/Code/Test/esbuild cd vite-project
/Volumes/Code/Test/esbuild/vite-project yarn
yarn install v1.22.15
warning package.json: No license field
info No lockfile found.
warning vite-project@0.0.0: No license field
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
info esbuild-darwin-arm64@0.13.3: The CPU architecture "x64" is incompatible with this module.
info "esbuild-darwin-arm64@0.13.3" is an optional dependency and failed compatibility check. Excluding it from installation.
info esbuild-android-arm64@0.13.3: The platform "darwin" is incompatible with this module.
info "esbuild-android-arm64@0.13.3" is an optional dependency and failed compatibility check. Excluding it from installation.
info esbuild-android-arm64@0.13.3: The CPU architecture "x64" is incompatible with this module.
info esbuild-linux-arm@0.13.3: The platform "darwin" is incompatible with this module.
info "esbuild-linux-arm@0.13.3" is an optional dependency and failed compatibility check. Excluding it from installation.
info esbuild-linux-arm@0.13.3: The CPU architecture "x64" is incompatible with this module.
info esbuild-linux-64@0.13.3: The platform "darwin" is incompatible with this module.
info "esbuild-linux-64@0.13.3" is an optional dependency and failed compatibility check. Excluding it from installation.
info esbuild-freebsd-arm64@0.13.3: The platform "darwin" is incompatible with this module.
info "esbuild-freebsd-arm64@0.13.3" is an optional dependency and failed compatibility check. Excluding it from installation.
info esbuild-freebsd-arm64@0.13.3: The CPU architecture "x64" is incompatible with this module.
info esbuild-linux-32@0.13.3: The platform "darwin" is incompatible with this module.
info "esbuild-linux-32@0.13.3" is an optional dependency and failed compatibility check. Excluding it from installation.
info esbuild-linux-32@0.13.3: The CPU architecture "x64" is incompatible with this module.
info esbuild-openbsd-64@0.13.3: The platform "darwin" is incompatible with this module.
info "esbuild-openbsd-64@0.13.3" is an optional dependency and failed compatibility check. Excluding it from installation.
info esbuild-freebsd-64@0.13.3: The platform "darwin" is incompatible with this module.
info "esbuild-freebsd-64@0.13.3" is an optional dependency and failed compatibility check. Excluding it from installation.
info esbuild-sunos-64@0.13.3: The platform "darwin" is incompatible with this module.
info "esbuild-sunos-64@0.13.3" is an optional dependency and failed compatibility check. Excluding it from installation.
info esbuild-linux-arm64@0.13.3: The platform "darwin" is incompatible with this module.
info "esbuild-linux-arm64@0.13.3" is an optional dependency and failed compatibility check. Excluding it from installation.
info esbuild-linux-arm64@0.13.3: The CPU architecture "x64" is incompatible with this module.
info esbuild-windows-arm64@0.13.3: The platform "darwin" is incompatible with this module.
info "esbuild-windows-arm64@0.13.3" is an optional dependency and failed compatibility check. Excluding it from installation.
info esbuild-windows-arm64@0.13.3: The CPU architecture "x64" is incompatible with this module.
info esbuild-linux-ppc64le@0.13.3: The platform "darwin" is incompatible with this module.
info "esbuild-linux-ppc64le@0.13.3" is an optional dependency and failed compatibility check. Excluding it from installation.
info esbuild-linux-ppc64le@0.13.3: The CPU architecture "x64" is incompatible with this module.
info esbuild-windows-32@0.13.3: The platform "darwin" is incompatible with this module.
info "esbuild-windows-32@0.13.3" is an optional dependency and failed compatibility check. Excluding it from installation.
info esbuild-windows-32@0.13.3: The CPU architecture "x64" is incompatible with this module.
info esbuild-linux-mips64le@0.13.3: The platform "darwin" is incompatible with this module.
info "esbuild-linux-mips64le@0.13.3" is an optional dependency and failed compatibility check. Excluding it from installation.
info esbuild-linux-mips64le@0.13.3: The CPU architecture "x64" is incompatible with this module.
info esbuild-windows-64@0.13.3: The platform "darwin" is incompatible with this module.
info "esbuild-windows-64@0.13.3" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] 🔗  Linking dependencies...
[4/4] 🔨  Building fresh packages...
error /Volumes/Code/Test/esbuild/vite-project/node_modules/esbuild: Command failed.
Exit code: 1
Command: node install.js
Arguments: 
Directory: /Volumes/Code/Test/esbuild/vite-project/node_modules/esbuild
Output:
node:child_process:867
    throw err;
    ^

<ref *1> Error: spawnSync /Volumes/Code/Test/esbuild/vite-project/node_modules/esbuild/bin/esbuild ENOENT
    at Object.spawnSync (node:internal/child_process:1083:20)
    at spawnSync (node:child_process:812:24)
    at Object.execFileSync (node:child_process:858:15)
    at validateBinaryVersion (/Volumes/Code/Test/esbuild/vite-project/node_modules/esbuild/install.js:64:32)
    at Object.<anonymous> (/Volumes/Code/Test/esbuild/vite-project/node_modules/esbuild/install.js:96:3)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawnSync /Volumes/Code/Test/esbuild/vite-project/node_modules/esbuild/bin/esbuild',
  path: '/Volumes/Code/Test/esbuild/vite-project/node_modules/esbuild/bin/esbuild',
  spawnargs: [ '--version' ],
  error: [Circular *1],
  status: null,
  signal: null,
  output: null,
  pid: 10887,
  stdout: null,
  stderr: null
}

@evanw
Copy link
Owner

evanw commented Oct 17, 2021

I tried the same project again on a different computer and did not reproduce the problem I described above.So the problem is on my computer 😄

This likely means it won't be possible to debug and fix the issue unfortunately. The first step to fixing this would be getting a set of reproducible steps that demonstrate the problem.

Another suggestion could be to try upgrading the esbuild package to the latest version and seeing if the problem goes away.

@evanw
Copy link
Owner

evanw commented Jan 6, 2022

Closing due to age and lack of a way to reproduce the issue.

@evanw evanw closed this as completed Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants