vitejs/vite-ecosystem-ci

hydrogen - yarn1 install error

dominikg opened this issue · 4 comments

running pnpm test -- hydrogen results in the following error:

error An unexpected error occurred: "ENOENT: no such file or directory, stat '/home/dominikg/develop/vite-ecosystem-ci/workspace/hydrogen/hydrogen/node_modules/vite/node_modules/resolve'".
yarn install v1.22.17
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
[4/5] Linking dependencies...
info If you think this is a bug, please open a bug report with the information provided in "/home/dominikg/develop/vite-ecosystem-ci/workspace/hydrogen/hydrogen/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
    at makeError (file:///home/dominikg/develop/vite-ecosystem-ci/node_modules/.pnpm/execa@6.1.0/node_modules/execa/lib/error.js:59:11)
    at handlePromise (file:///home/dominikg/develop/vite-ecosystem-ci/node_modules/.pnpm/execa@6.1.0/node_modules/execa/index.js:119:26)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async $ (file:///home/dominikg/develop/vite-ecosystem-ci/utils.ts:42:18)
    at async applyPackageOverrides (file:///home/dominikg/develop/vite-ecosystem-ci/utils.ts:239:5)
    at async runInRepo (file:///home/dominikg/develop/vite-ecosystem-ci/utils.ts:142:3)
    at async test (file:///home/dominikg/develop/vite-ecosystem-ci/tests/hydrogen.ts:22:3)
    at async run (file:///home/dominikg/develop/vite-ecosystem-ci/ecosystem-ci.ts:103:3)
    at async CAC.<anonymous> (file:///home/dominikg/develop/vite-ecosystem-ci/ecosystem-ci.ts:42:5) {
  shortMessage: 'Command failed with exit code 1: yarn install',

if you look closely, you'll notice that vite is inside hydrogen/node_modules and not our local one.
this seems to be caused by the fact that yarn1 silently refuses to use absolute paths in resolutions.

prefixing the resolution path with link: fixes that, but then other errors crop up because yarn tries to hoist dependencies and that fails.

Already tried rewriting hydrogens workspaces declaration in package.json to

  "workspaces": {
    "packages": [
      "examples/*",
      "packages/*",
      "packages/playground/*"
    ],
    "nohoist": [
      "vite/**"
    ]
  },

but that failed with

  Error: ENOENT: no such file or directory, lstat '/home/dominikg/develop/vite-ecosystem-ci/workspace/vite/packages/vite/node_modules/esbuild-linux-64'

tbh i'm out of ideas and not familiar with yarn1 or hydrogens project setup.

@frandiox: is there a way to to provide a local vite package to hydrogen so that yarn install works without using yarn link on the cli?

funnily enough running yarn install a second time after the esbuild error passes with a success message.

but then the hydrogen build fails with a message about missing vite

template-hydrogen-default:build: /bin/sh: line 1: vite: command not found

i know i sound like a broken record at this point, but maybe it's time to ditch yarn1 for pnpm

see #41 (comment)

Ugh, weird, when I tried locally with pnpm test -- hydrogen --release 2.8.6 it was passing 🤔

@frandiox: is there a way to to provide a local vite package to hydrogen so that yarn install works without using yarn link on the cli?

Not sure, really. We just import Vite normally or call its CLI from packageJson scripts. Yarn v1 hoists Vite to the root, hydrogen/node_modules, so I would assume it can be moved there but who knows.

i know i sound like a broken record at this point, but maybe it's time to ditch yarn1 for pnpm

We are aware that pnpm is better. We tried to migrate back in November but there were issues with peer dependencies because we depend on an experimental version of React that conflicts with other stuff. Apart from that, pnpm was using symlinks and that was making Vite somewhat angry at that moment, but I can't remember the details.

We'll likely try to migrate to pnpm again but I'm not sure when. I guess we can disable Hydrogen tests here until then.

Thanks for checking it btw!

--release 2.8.6 doesn't test against a local build but links to the registry version. My guess is that yarn1 hoists it correctly in that case.

I'm going to move hydrogen.ts to _hydrogen.ts (which means you can still call it from cli with pnpm test -- _hydrogen but it won't be included in pnpm test. Also going to remove it from the github actions for now.

Sorry it doesn't work out right now. Happy to help if you've got questions regarding pnpm migration.