yalc icon indicating copy to clipboard operation
yalc copied to clipboard

yalc remove does not remove yalc symlinks from packages

Open benchesh opened this issue 4 years ago • 13 comments

Removing one or more linked yalc packages with the yalc remove command will not remove any yalc symlinks from the node_modules directory. These packages will effectively be pointing to a directory that no longer exists, rendering them corrupt. The user will either need to manually reinstall these packages, run yarn install --check-files or delete node_modules & run yarn install to fix. The latter two options will of course overwrite both linked and unlinked packages, so a yalc update will be required to bring any active yalc symlinks back.

I believe the solution to this problem will be for yalc remove to also reinstall the relevant packages according to their defined versions in package.json. This could take the form of an additional argument, for example yalc remove <package> --reinstall-pkg.

I'm not sure if there are different implications for npm users.

benchesh avatar Jul 12 '20 23:07 benchesh

Ok, will check it.

wclr avatar Jul 13 '20 05:07 wclr

@wclr Love this project so far, but wanted to touch base about this issue to see if you have a solution to yalc remove to strip symlinks rather than yarn install --check-files?

I suppose yalc remove could/should just remove the symlinks leaving the user to yarn install afterwards .. but it looks like yarn install --check-files basically replaces the symlinks with the legit packages anyhow.

revgum avatar Jan 11 '21 20:01 revgum

Not sure I get the problem and the use case.

wclr avatar Jan 12 '21 09:01 wclr

@wclr yalc link leaves me wondering, "ok after I'm done with local development, what now?".. expecting a yalc unlink or yalc remove or something similar to remove symlinks and cause whatever package is specified in package.json to (re)install. A plain yarn install didn't seem to overwrite the symlinks and left me in a position where the links were still there unexpectedly, whereas a yarn install --check-files did replace the links with the actual node module specified in package.json.

So, maybe I'm just too new to the utility to have understood that or I'm doing it wrong? 😄

Bottom line, yalc is awesome, thank you for it!

revgum avatar Jan 12 '21 21:01 revgum

I don't tend to use yalc link but yalc add as it makes things more consistent, thus the workflow with yalc link may be not well thought out.

To sum up yalc link case: currently yalc remove just removes "linked" package from .yalc and yalc.lock and does nothing with a symlink in node_modules, and simple running after yarn will not bring things back, though running yarn --check-files will fix things.

So what is the proposal? Should yalc remove run yarn --check-files?

wclr avatar Jan 13 '21 15:01 wclr

Yea I think yarn --check-files would make sense for yalc remove for the case I bumped into.

revgum avatar Jan 19 '21 20:01 revgum

This is something we've found is also affecting us and our workflow. We use npm and after yalc remove the linked directory stays there. If we try to do an npm install it will error because it's not sure what to do with that linked directory. So we have to blow away node_modules and do a fresh install which takes a lot longer.

Could the npm flow just remove the linked directory? npm uninstall/unlink does that and has no concept of the --check-files that yarn does

Fernker avatar Jul 15 '21 19:07 Fernker

Same problem when using yalc link:

/Users/me/Sites/www/.yalc is not empty, not removing it

Undistraction avatar Jul 07 '22 08:07 Undistraction

Not sure if yalc still under maintenance?

We are using yalc link instead of yalc add with npm because yalc link make the webpack hot reload works while yalc add doesn't take effect. The pain is when revert the dev env, after yalc remove, the symlink folder under node_modules still exists, and now we have to manually remove it 'rm -rf'. npm has no command like yarn can do that.

I agree with @wclr that add is better than link on consistent part.

I think the fix should be straightforward:

  1. yalc add --link, or yalc link to add the symlink.
  2. Then yalc add --unlink, or yalc unlink should remove the symlink. Pure add command should not be affected.

Changes should be arround here: remove.ts

helloint avatar Feb 03 '23 06:02 helloint

any news?

MontoyaAndres avatar Mar 24 '23 15:03 MontoyaAndres