Konubinix' opinionated web of thoughts

Yarn Link Does Not Work Because of Broken Symlinks

Fleeting

yarn link does not work because of broken symlinks

yarn link
yarn link v1.22.19
success Registered "@playwright/test".
info You can now run `yarn link "@playwright/test"` in the projects where you want to use this package and it will be used instead.

then in my project

yarn link "@playwright/test"
yarn link v1.22.19
error No registered package found called "@playwright/test".
info Visit https://yarnpkg.com/en/docs/cli/link for documentation about this command.

then, looking at the link directory

ls -l ${XDG_DATA_HOME}/yarn/link/@playwright
total 4
lrwxrwxrwx 1 sam sam 61 Aug  8 11:46 test -> ../../../../../../../test/playwright/packages/playwright-test

test -e ${XDG_DATA_HOME}/yarn/link/@playwright/test && echo "Exists" || echo "Does not exist"
Does not exist

Then, manually fixing the symlink (removing an extra parent directory).

ls -l ${XDG_DATA_HOME}/yarn/link/@playwright
total 4
lrwxrwxrwx 1 sam sam 58 Aug  8 11:47 test -> ../../../../../../test/playwright/packages/playwright-test
test -e ${XDG_DATA_HOME}/yarn/link/@playwright/test && echo "Exists" || echo "Does not exist"
Exists

Then, the link works as expected.

yarn link "@playwright/test"
yarn link v1.22.19
success Using linked package for "@playwright/test".
Done in 0.14s.