Replies: 5 comments 4 replies
-
@oversize thanks for this... I'll keep using it as a reference this week, will ask for further clarification about any of the above it it seems unworkable or unclear, and then when happy with every detail I'll plan to "Update the docs" so it's explicit for both developers and contributors. |
Beta Was this translation helpful? Give feedback.
-
UpdateAfter some more reading and playing around with yarn install i realized that
So while having a lockfile, yarn seems to interpret its use differently from what i was used to (coming from other package managers with lockfiles. That is: It just does not bother at all that there is a lockfile, because it always will recalculate and install the versions it sees from package.json and then just update (or not) the lockfile. There is some interesting discussion about this here: yarnpkg/yarn#5847 Especially this comment sums it up pretty well: yarnpkg/yarn#5847 (comment) At this point i have no idea what the lockfile in yarn is good for then. My conclusion is to update the above docs (and our docs) so that the developers should always use Sidenote: In the npm world is a special command Another Sidenote: I am not a Frontend Developer. I have no real usage/exposure to yarn outside of this project. So all that i have written is from reading and playing around over the last days or so. If there is someone with better knowledge about how yarn/npm is supposed to work i am happy to learn how this should be dealt with. |
Beta Was this translation helpful? Give feedback.
-
I think I touched on this topic somewhere earlier but cannot find it. In my experience - it's good to have lock files committed to repository, but at the same time add those to .gitignore file. That's usually the only middle ground that satisfies both node and git standards for projects where node development isn't the primary use-case (in this case, this being an average builder wanting to add an entry or update doc) Yarn/package lock files as described above are quite notorious for source code versioning wherein different machines can land up with very different order of packages and thus, differences in node_modules. Advantage of having them added to .gitignore:
|
Beta Was this translation helpful? Give feedback.
-
OK I'm replying mostly to #876 (comment) (directly above) but need some of these things to be considered independently. This is timely (before Christmas holiday leave I hope) because I'm testing this actively with a PR I've just submitted (#898) in all which the advice above (which I agree with completely) has not been sufficient to avoid the deadlock in the local build process which I've reported before in the threads @katomm highlighted above. Mainly, once You can see the difficulty caused by this with the commit history in #898: as of this moment, I've attempted to fix this by downloading the "canonical" So yes I do think for this & many other reasons, we need (unless I've missed something):
If everybody can agree, I will submit ASAP (or one of the "maintainers" if that's more proper) a PR that does these changes and hopefully we can push it through immediately. Otherwise anyone testing or submitting from a local branch will run into the problem that I'm currently having in #876. What I reported in the threads that @katomm quoted is this "oscillation" state... resulting in inappropriately deleted / added / modified On the remaining note: with |
Beta Was this translation helpful? Give feedback.
-
I want to open this discussion to allow others to understand my intentions and have the possibility for others for feedback, since in the original PR that might not be done enough.
With the merge of #832 the yarn.lock file was commited to the repository again.
Why add the lockfile
The yarn.lock file holds an exact tree of the projects dependencies locked to a specific version. Commiting that lock file to the repository provides a way to have deterministic builds. Meaning everybody will end up with the same dependency tree as defined in the lockfile. The workflow added above wants to ensure that the current build is functioning. It therefore is crucial to have that deterministic build where everyone (including the workflow) ends up on the same page. That is every developer and also the workflow.
A much better explanation of whats going on under the hood can be found in the npm docs: https://docs.npmjs.com/cli/v6/configuring-npm/package-locks
Yarn Docs about why it should be included: https://classic.yarnpkg.com/blog/2016/11/24/lockfiles-for-all/
Existing branches should update
What should existing branches that have not yet added the yarn.lock file do? Ideally they should merge from main to have the lockfile. If not, they should not provide a lockfile because the main lockfile represents the "current state of dependencies".
Should branches have the need to update the lockfile, because they want to change some dependecy (see below) a new lockfile should be generated after the merge to main and commited to main to reflect the new dependecies.
When does the lockfile change?
The lockfile should never be changed by any PR unless it deliberately changes some of the projects dependencies (add/remove/update) or a version bump like this one #862
Should anyone that is unintentionally altering the dependencies end up with a change in his local lockfile, he almost always should revert that change and not commit it. See below "update docs"
There was a bug in yarn that would cause that to happen. yarnpkg/yarn#4379 But that should be fixed now. He should use the --frozen-lockfile option to yarn install.
Update the docs
The docs that currently say you should not commit the yarn.lock file should be updated.
If the yarn.lock file is in the repository it might very well be that the checkout cant happen because there is a local version already. That local version should be removed first to allow the checkout to happen. Should that break something in you local install, then the dependency update should be noted in the PR. See above for what to do if a PR changes dependencies.
To ensure that deterministic build behaviour, we should advise people to always use the--frozen-lockfile
option to yarn install.There is no option to ensure deterministic builds in yarn. The easiest option for devs seems to be the
--pure-lockfile
option since it will not change the existing yarn.lock. There is a discussion about ´--frozen-lockfile´ to be the default behaviour that gives some insights into this: yarnpkg/yarn#4147@rphair regarding your question:
No Branch should just add its own yarn.lock file if the branch currently does not have one (as the revamp-stake-pool. It could either merge main (which would make sense anyhow since its 102 commits behind already) or wait until its merged into main without bringing in its own yarn.lock!
The yarn.lock of the main branch should always reflect the "current state of dependencies" everybody agreed upon.
Other projects with lockfiles
The concept of a lockfile is not unique to yarn/npm. Other projects use that as well and all recommend the lockfile to be commited for the exact same reason.
@rphair @rdlrt @fill-the-fill @katomm @os11k Not sure how active you guys look into the discussions so i marked you here to get your thoughts on this.
Beta Was this translation helpful? Give feedback.
All reactions