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

Inconsistent work with local (file:)/ remote (git) dependencies #1794

Open
wclr opened this issue Nov 12, 2016 · 3 comments
Open

Inconsistent work with local (file:)/ remote (git) dependencies #1794

wclr opened this issue Nov 12, 2016 · 3 comments

Comments

@wclr
Copy link
Contributor

wclr commented Nov 12, 2016

I decided to create this issue following #1214 to make a consistent description of yarn's (probably inconsistent) behaviour when dealing with local (file:) dependencies.

If we have dependency in package.json:

"my-local": "file:../relative/path/to/my-local"

I On first install, or when the dependency is added (using yarn add), happens following:

  1. in yarn creates node_modules/my-local and copies the full content of the source folder, then install dependencies that are in my-local/package.json
  2. places in cache *full content (including my-local/node_modules) in the cache under the name like npm-my-local-1.0.0 (considering version in my-local/package.json)

II Then suppose we made some changes to my-local (original source folder):

  1. added some new code
  2. added new dependency
  3. did not change package.json version (1.0.0)

III Then we want to update the content of my-local dependency in the project.
we may do it by yarn upgrade (but will try to upgrade other package) so we do yarn upgrade file:../relative/path/to/my-local or yarn add file:../relative/path/to/my-local, while this yarn does folling:

  1. takes (changed) package.json from original sources my-local folder, parses changed dependencies, links them
  2. then it does strange thing (in my view): it just takes version from cache npm-my-local-1.0.0 and copies its content to our project node_modules/my-local

So you may see inconsistency here - it takes new package.json from source and handles dependencies, but takes old content from cache.

IV If we would change the version in my-local/package.json (-> 1.0.1) and would try to upgrade it we would got what wee need:

  1. new version say npm-my-local-1.0.1 would be placed in cache
  2. new content is in project's node_modules/my-local
  3. new dependencies installed

Absolutely the same behaviour is happening when dealing with remote git dependencies: it too checks source package.json (and apppies it) and gets content from cache.

Symlinks problems

As described in #1214 and other issues
Of course we are in a trouble when we use symlinks, when we add local dependency and make simklink
/relative/path/to/my-local <==> node_modules/my-local and after upgrade procedure (step III) yarn will replace content for node_modules/my-local (and that means in linked source folder) with a version from cache.

Probably yarn shouldn't be using cache for local ('file:')/ git remote dependencies at all. I consider this as a kind of critical bug in yarn that should be fixed ASAP.

@guncha
Copy link

guncha commented Nov 13, 2016

I'm seeing the same issue with Yarn caching the local folder and ignoring all changes to it until I run yarn cache clean. What's interesting is that the actual dependencies in node_modules reflect the changes to the package.json file in the local folder, but yarn.lock still has the old dependencies listed.

@wclr
Copy link
Contributor Author

wclr commented Nov 13, 2016

What's interesting is that the actual dependencies in node_modules reflect the changes to the package.json file in the local folder, but yarn.lock still has the old dependencies listed.

Yes, behaviour is inconsistent.

@eTorAken
Copy link

Related to #2165.

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

No branches or pull requests

5 participants