-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Checking in the yarn.lock file #1067
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
Comments
As detailed in the links @mcwhittemore posted, the conventional wisdom for Bundler and Cargo is to check in the lockfile in applications, but not check in the lockfile for libraries. The links go into detail about the rationale, and it would seem that similar considerations apply to yarn. Is there a reason not to make similar recommendations, i.e. update the documentation to distinguish between applications and libraries? |
libraries shoudn't use yarn.lock if they expect their dependencies to be installed separately yarn can benefit from yarn.lock because it packages all of its dependencies within release (i'm guessing that's happening for .rpm .dev and other builds. it doesn't do so for npm build, but I think it should do so (just like bower). So the answer is:
|
contradicts to
"Fully deterministic environment" only if |
@develar only applications require a fully deterministic environment. Libraries should not lock in specific module versions unless it's absolutely required. If all libs bundled their lockfile then no one would get patch updates and it would significantly effect the entire node ecosystem. |
@palmerj3 That would be true if Yarn respected If I'm understanding correctly, that means libraries can safely check in Whether libraries should check in |
It sounds like a problem with checking in your Assuming all of your dependencies follow semvar very well this is ok, but the moment a bad release lets sip an accidental breaking change new users will find out about it but maybe not you as your ci tests won't be plagued downstream change. |
The problem with not checking in your yarn.lock file is that CI failures will be attributed to innocent commits. Ex:
At a glance, the blame is attributed to commit 2 even though it's bug-free. CI also discovers the bug a few days after the problem -- wouldn't it be nicer to discover the problematic dependency closer to when it was published? win-winOne solution to this is a service like Greenkeeper that updates your dependencies in your package.json when new versions are published. Greenkeeper would need to update yarn.lock as well, but the timeline would look like this:
In this scenario, you've correctly attributed failing tests to their root causes (which you get by committing yarn.lock) and quickly discovered an accidental breaking change and defended against it (which you get by omitting yarn.lock). Sort of a "best of both worlds" outcome. Plus |
@develar The But that doesn't mean every library should use These are the facts (some of which have already been pointed out by @sheerun, @mcwhittemore, and @ide):
|
yarn.lock is poor choice for file name, easily mistaken for unix lock files (used to "lock" a directory for specific process). Caused me lot of frustration before I realized that these are not lock files and you are actually supposed to check them in. |
I think this question has been pretty well answered so I'm going to close this. Other convos about lock files should probably be in their own issues. |
@mcwhittemore I disagree. Yes the question has been answered in this issue, but the Yarn documentation has not been changed. That means that anybody else who has the same question has to ask it again. I think it would be useful for the Yarn docs to clarify how libraries should handle |
@Pauan, that issue should be opened on yarnpkg/website to add documentation. |
@wyze That makes sense, thanks for the link. 👍 |
Shouldn't the comment |
The proper way to deal with it is checkout -f HEAD yarn.lock , and running
yarn install. Just like bundler from ruby
…On Thu, 8 Dec 2016 at 17:53, Geoffrey Plitt ***@***.***> wrote:
Shouldn't the comment THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS
FILE DIRECTLY. be removed from the yarn.lock file? We should encourage
engineers to be comfortable editing it in the event of branch/merge
conflicts, and treat it like a source file (OK to edit) instead of an
auto-generated file (never edit).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1067 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAR2DXe80-Zvhwf1V7OmYhxyyyFPTzFIks5rGDYigaJpZM4KXLBz>
.
|
I'm talking about when 2 branches made changes to it and you have to merge and handle conflicts. Requires manual editing. |
In those cases, the second person should rebase on top of the firsts merged changes, and use yarn to manually recreate their commit - not manually editing to fix the conflicts. |
Gotcha, thanks! |
The current version controls docs say that the lock file should be checked in.
But looking at yarn's own lock file it looks like it was only checked in recently.
I work on a team that is trying to decide if we should be checking in our lock file. While the docs make it clear that this is what is expected, the docs of other package managers make it clear that this should not happen and give good explanation for why it should not.
I've tried to find a discussion about why yarn decided to act differently than these other managers, but it doesn't seem to be laying around.
Is this still something in flux?
If not, is there a place where we can learn why yarn has made this decision?
The text was updated successfully, but these errors were encountered: