Open Dentrax opened 2 years ago
I ma having the exact same issue:
OS: macOS 12.2.1 (M1)
node: 16.14.0
npm: 8.5.3
commit: 89a9f219f21
hitting same issue I ma having the exact same issue: OS: macOS 12.2.1 (M1) node: 16.14.0 npm: 8.5.3
Thanks everyone for reporting! Unfortunately I have never ever managed to reproduce this issue, even if I have very similar environments as you guys do.
Some help would be appreciated here. PRs welcome!
try touch yarn.lock
as a work around https://github.com/yarnpkg/berry/issues/625
I am having exact same error right now on Windows. Any fix yet ?
I just ran into this on AWS CodeBuild (for CI), so it was also on a fresh install of everything. I cannot replicate it locally.
EDIT: I was able to replicate it locally by deleting all node_modules
folders, .yarn/cache
, and .yarn/install-state.gz
.
v3.2.x
and v3.3.1
(I had tried updating to resolve the issue, since that fixed it for someone else, to no avail).project.json
, whose folder was also the working directory.yarn node --version
(which works locally for me)package.json
script. In my case, the command was yarn ci:install
yarn.lock
file already, so that was not the problem./
, and there were no package.json
, yarn.lock
, or other node/npm/yarn-related files in any parent.✅ I resolved the issue by directly running my commands, instead of doing it through a package.json
script.
Previously I had something like:
// ...
"scripts": {
"ci:install": "yarn workspaces focus root @myScope/package1 @myScope/package2"
}
// ...
And I was running the command yarn ci:install
on the server. This caused the error to be thrown. By directly running the command yarn workspaces focus root @myScope/package1 @myScope/package2
I was able to avoid the error.
To add onto my prior comment, I was able to confirm that the issue is:
When .yarn/install-state.gz
is missing, yarn run ...
fails and throws the error initially described in this issue.
This can be resolved by directly doing some sort of an install, without going through a package.json
script. For example, yarn install
for an entire repo or yarn workspaces focus ...
for a subset of packages. Once any kind of install is directly run, the .yarn/install-state.gz
file appears and future yarn run
calls work as expected.
Note that the docs say that .yarn/install-state.gz
should be gitignored, so this is presumably an unintended behavior.
My environment info:
Relevant parts of my .yarnrc.yml
:
nodeLinker: pnpm
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
spec: '@yarnpkg/plugin-version'
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: '@yarnpkg/plugin-workspace-tools'
To me this whole topic is still unresolved. As @adam-coster has mentioned, the docs explicitly say that .yarn/install-state.gz
should be .gitignored.
In my case, my CI-job fails if there is no node_modules
directory available - which is the default PnP behavior. Only getting this fixed when adding the nodeLinker: node-modules
setting in my .yarnrc.yml
config, which leads to the node_modules
directory to be created.
I'd rather like to not have the node_modules
directory but then my CI job fails with this mentioned error.
I found a solution for myself:
According to this article: https://yarnpkg.com/features/caching#zero-installs
When using the PnP (Plug and Play) feature in addition to the offline mirror, the node_modules
directory won't be created unless configured via nodeLinker
config.
Within my CI setup, I was caching the .yarn
directory (with it's .yarn/cache
directory, since my enableGlobalCache
config is set to false
) but I was not caching the .pnp.cjs
and .pnp.loader.mjs
files.
These files resolve package files without the need for going into the network and fetching the packages from e.g. the npm registry -> therefore the name zero install.
These files, .pnp.cjs
and .pnp.loader.mjs
are being generated automatically. While running yarn install
in my CI job, these files will be created. Adding them to my CI cache allowed these files to exist in the build
job.
Lesson learned. Please check if your .pnp.cjs
and .pnp.loader.mjs
files are being created @Dentrax .
Let me know if you have further insights into your issue. @adam-coster maybe that also fixes your issue?
Adding them to my CI cache allowed these files to exist in the
build
job
I don't seem to be caching anything during build. I don't have cache/
inside ./yarn
Adding them to my CI cache allowed these files to exist in the
build
jobI don't seem to be caching anything during build. I don't have
cache/
inside./yarn
If you don't have .yarn/cache
that is probably because you don't have:
enableGlobalCache: false
set in your .yarnrc.yml
file. That might be useful if you are planning to use it in your CI jobs. You can try it out locally:
.yarnrc.yml
if it doesn't exist yetenableGlobalCache: false
to ityarn install
Bug Description Yarn throws the following error on fresh install:
What I've tried so far:
npm cache clean
rm -rf node_modules
yarn install
(exits 0)Steps to Reproduce
yarn create eth-app my-eth-app
Expected Behavior It should build?
Additional Context Add any other context about the problem here (screenshots, whether the bug only occurs only in certain mobile/desktop/browser environments, etc.)
OS:
macOS 12.1 (Intel)
yarn:3.1.0
node:17.3.1
npm:8.3.0
commit: 89a9f219f210dde636e076fd2daa5882671e012b terminal:iTerm2 3.4.14
user:no permission issues