yalc
yalc copied to clipboard
`yalc add` on Mac can (rarely) fail with ENOTDIR invalid cwd, treating .DS_Store as a version directory.
I saw this for the first time today on running yalc add
on several packages in a new repo (MacOS 11.6.8). All the packages worked except one, which gave this error:
Error: ENOTDIR invalid cwd /Users/alan/.yalc/packages/{package_name}/.DS_Store at Glob._readdirError (/Users/alan/.npm/_npx/8971ede65c5d814d/node_modules/glob/glob.js:589:21) at /Users/alan/.npm/_npx/8971ede65c5d814d/node_modules/glob/glob.js:550:12 at FSReqCallback.oncomplete (node:fs:188:23) { path: '/Users/alan/.yalc/packages/{package_name}/.DS_Store', code: 'ENOTDIR' }
Deleting the Mac OS generated .DS_Store
file in the Yalc package directory (the one that contains all the yalc-published versions) fixed this.
It's strange because:
- All the other packages worked fine and they all had
.DS_Store
files in their directories of version directories - All the packages came from the same monorepo, which had
.DS_Store
in its gitignore
I think I've figured it out - I can replicate it by causing a yalc package directory to have a .DS_Store
file with a creation date more recent than any of the version directories.
Example replication steps (on a Mac):
-
yalc add
some package - it works - Delete the .DS_Store file in that package's directory of version directories
- Regenerate it (for example, Get Info, then tick and untick "Locked")
-
yalc add
the same package again - this time, it fails on trying tocd
into.DS_store
.
So it looks like the problem is, the function yalc add
uses to find the latest version is just taking all the contents of the directory, getting the most recent, and assuming it's a version directory. 99% of the time this works fine, but if for whatever reason some system file like .DS_Store
comes to be the most recent item in the directory, this crash happens.
Suggested fix: filter the array of directory contents to be only directories before finding the newest and cd
ing into it.
@AlanSl Did you find a workaround for this issue?
Not really. It might be possible to work around by forcing the version folders to have a more recent created date than .DS_Store
, e.g. by deleting the published versions then yalc publish
again?
Not really. It might be possible to work around by forcing the version folders to have a more recent created date than
.DS_Store
, e.g. by deleting the published versions thenyalc publish
again?
Yeah, it might work but it feels like it's going to be cumbersome and unstable... Im wondering if there is a fork addressing this.