Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symlinking packages may lead to invalid states #937

Closed
jiripospisil opened this issue Oct 12, 2016 · 10 comments
Closed

Symlinking packages may lead to invalid states #937

jiripospisil opened this issue Oct 12, 2016 · 10 comments

Comments

@jiripospisil
Copy link

Do you want to request a feature or report a bug?

Bug.

What is the current behavior?

An unlinked (but added) package is missing from node_modules and yarn will not install.

If the current behavior is a bug, please provide the steps to reproduce.

  1. Link a random package

    git clone git@github.com:tj/co.git
    cd co && yarn link
    

    As a side note, yarn will not install the package's dependencies. The default npm client would do that. I'm not sure whether that's expected or not given that the linking process is slightly different already.

  2. Create a new directory and use the linked package from there

    yarn link co
    
  3. Add the package again but this time via add

    yarn add co
    

    The linked package is still used at this point (and that's consistent with the default client).

  4. Unlink the package

    yarn unlink co
    

    This will remove the link from node_modules as expected.

  5. Run yarn to get the added (locked) package back

    yarn
    yarn install v0.15.1
    warning No license field
    success Already up-to-date.
    Done in 0.13s.
    
    ls node_modules
    

    At this point, the package is not present in node_modules but yarn seems to be okay with that and won't install it. Doing yarn add co again will install it.

What is the expected behavior?

The package should be installed after unlinking it and running yarn.

Please mention your node.js, yarn and operating system version.

Node.js 6.7.0
Yarn 0.15.1
Ubuntu 12.04

@andybluntish
Copy link

This still seems to be an issue with yarn v0.18.1.

@JulianLeviston
Copy link

@andybluntish only workaround I've found is to either delete the node_modules folder entirely, or to yarn add something then revert changes.

@miskreant
Copy link

You can also workaround by deleting yarn.lock, instead of nuking node_modules

@bwittenberg
Copy link

The following command was a sufficient workaround for me:

yarn install --check-files

https://yarnpkg.com/en/docs/cli/install#toc-yarn-install-check-files

@bestander
Copy link
Member

Can repro.
The problem is in linkedModules field in node_modules/.yarn-integrity.
Yarn would ignore a missing folder if it is a modules globally registered as linked.

It should at least check if symlink exists

@BYK
Copy link
Member

BYK commented Oct 27, 2017

I feel like @arcanis addressed this in PR not too long ago. @arcanis can you confirm?

@chaimleib
Copy link

Any updates here?

@jasononeil
Copy link

I can still reproduce this with 1.8.0

@GongT
Copy link

GongT commented Nov 1, 2018

PS my-scripts> yarn unlink @gongt/stillalive
yarn unlink v1.12.1
success Removed linked package "@gongt/stillalive".
info You will need to run `yarn` to re-install the package that was linked.
Done in 0.10s.
PS my-scripts> yarn
yarn install v1.12.1
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.20s.
PS my-scripts> dir .\node_modules\@gongt\
PS my-scripts>

Still problem v1.12.1

justinsacbibit added a commit to justinsacbibit/yarn that referenced this issue Jan 16, 2019
arcanis pushed a commit that referenced this issue Jan 23, 2019
* Fix suggested command after unlinking a package

Fixes #937, #1957

* Update en.js

* Update CHANGELOG.md

* Update CHANGELOG.md
@danwenzel
Copy link

Hi @arcanis . Based on the comments in #1957 and #6931, I think this issue should be reopened. The messaging is better now, but ultimately a yarn install should restore any unliked packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests