-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
yarn install --frozen-lockfile
should be the default behavior
#4147
Comments
I tend to agree with this. First I thought this should be the default only on CI but now, I think may be we should expect the user to pass a flag like Thoughts @yarnpkg/core ? |
I think there is some suspicion that a lot of people directly add dependencies to Though, I'm curious how common it is for someone to unintentionally That said, this does seem like a nice safeguard against a constantly changing lockfile, which is a problem I'm having in NPM5 (my NPM generated lockfile constantly changes depending on which dev on the team last ran it 😢 ). I'm fine either way on this one. |
@rally25rs The new dependency was added by a fellow developer via their local They should have used The whole point is that I want to enforce that |
You can add |
We would have to set it up for each repository of everyone running Yarn ... 😉 |
This alone tells me that it needs to be the default. |
So we discussed it a bit with @BYK and thought of the following option which we both agree looks sensible and should cover most cases:
This way, Yarn would stay easy to use by developers, while still providing you a way to ensure your lockfiles are always kept up to date and you never have this kind of unpredictable behavior. How does that sound? |
@arcanis I am a bit confused though as to why making The added warning is nice, though I highly suspect it becoming nothing but logging noise on a lot of build machines nobody will notice unless the build fails due to an unexpected version bump. I can understand that there is some restraint in wanting to change a default behavior of a command, and if it was to change, I assume the builds of quite a few people are about to break. Yet I'd consider that a good thing. As on the yarn's main page, I find claims about yarn being ultra fast, mega secure, and super reliable:
The current default is at odds with that claim. Nowhere is it stated that yarn is easy to use ;) In the end, having a strict option would be fine with me, even though I detest having to enable that setting in the Or what do you mean by when you "roll the |
My 2 cents. In other threads, Our CI does use In practice, setting |
Yep, this is an important use case. |
I should also add, that humorously / ironically, someone just came to me about 2 unrelated commits altering In this case, I personally believe it's less alarming to generate the altered |
@k0pernikus not sure if this will help your situation, but you could also try to prevent NPM use by erroring out of a
|
Yep, totally agree! :) That's why the option we've came upon is to keep the default as it is (running |
If one would change the default behavior of yarn, it doesn't necessarily mean that the current default cannot become its own flag, e.g. Or have the generation of the lockfile as its own command:
|
I'm also +1 for keeping current default behavior as is. If I understand your issue correctly @k0pernikus , having |
Let me clarify my view on this a bit. I wasn't suggesting removing the option of directly editing a All that said, I think we have some consensus around keeping the existing behavior and moving forward with just a warning and expecting people to set their CI up responsibly via |
We moved to npm-shrinkwrap, yarn, etc. to lock down dependency versions. My team was surprised by the auto-merge-conflict-resolution feature. An accidental un-merged yarn.lock file was checked in, and instead of failing the build our CI happily used some algorithm to decide how to merge the file. I can't fathom a safe automated merge algorithm for Being able to disable this with |
@ProdigySim, couldn't overriding the frozen option be achieved by deleting yarn.lock before running yarn install? |
I'm not sure where this PR is going, so I'll just add my two cents. At first, I was going to argue that "--frozen-lockfile" should be the default for the "install" command because specifying the option in .yarnrc would apply to all commands, not just install. However, I found the doc for .yarnrc and you can specify options per command. So, my group will be adding "--install.frozen-lockfile true" to ".yarnrc" resolves the issue for us. The concern that this has to be done for each repository is minimal as there is already a slew of work that needs to be done to setup a project. |
I totally missed that somehow. Restricting
in |
Having a look at the big sibling Since May 2018 they they have added the Reverting my example in my very first post:
Running
Running Maybe this is also a way for
|
We have started moving towards making Yarn a developer tool rather than a production tool. The end goal (early next year) is that running Yarn on CI will not be needed anymore. So no Check the Plug'n'Play rfc, which is tightly connected to this goal: yarnpkg/rfcs#101 |
@arcanis The linked goal has been closed, but it doesn't seem that the issue discussed in this thread has been resolved. Could you share some updates? |
@arcanis @BYK Can you please give an update of the status of this issue? The only thing that I noticed recently is that in the meantime is that this weird behavior has been better documented via #5847 at the yarn cli docs:
and:
While this is helpful and awesome, it still feels like a workaround and not a solution. The default is neither "super reliable" nor "deterministic". We have safeguarded most our projects against many of the issues, though we still sometimes run into troubles esp. in conjunction with #4570 making it impossible to use the proposed config of adding |
There is no plan to change this in a non-major release. The next one is currently in development, but even though we'll likely make changes to how frozen lockfiles work I'm not sure the CI mode will be part of it (next release will already be rather large as it is, so I'd prefer to slate it for 3.x). |
If I could add my thoughts to this discussion...
In my opinion, we should use two different commands for the two cases:
Every time yarn install runs, it should read from the lock file and change the |
Noticed a discussion on this in another thread. It's best not to mix yarn and npm. You should also use `--frozen-lockfile` or `--pure-lockfile` when installing into a docker image. yarnpkg/yarn#4147
Agreeing with @afdev82 here, I can see 2 different use cases.
I encourage everyone to look around how other package managers work. I'm a ruby guy so here is how Bundler does it.
Not saying bundler is the best BUT why even have a lockfile if installing dependencies modifies the lockfile? |
I think installing dependencies when there is a lockfile in place, should only install what the lockfile says it should. Nothing else. For additional behaviours we can always pass a flag (like -u or something). |
Definitely feel like this should be default... Anything else defeats the purpose of the lock file in the first place |
Just ran into this and wasted a bunch of hours figuring out that this was the issue. Would love to see this behavior implemented as the default. |
any updates on this? just started using yarn and was surprised no one was finding this an issue. Why introduce a lock file then. what exactly are you locking? The thing that you are going to then update. |
Locking, as we have no intent to change the default in 1.x since it'd be a breaking change. There's however a good chance something similar will be implemented for CI exclusively in the next major release (which is developed on a separate repository).
The lockfile is only modified if your package.json references packages that aren't part of your lockfile. In other, it's only modified if you messed up the state, for example by committing a new dependency without running an install. |
@arcanis would it make sense to close this issue and link people to the relevant issue in yarnpkg/berry? |
Do you want to request a feature or report a bug?
It's a feature-request due to a default behavior that leads to unexpected behavior during:
What is the current behavior?
On
yarn install
the default behavior is that the yarn.lock file is mutated ifpackage.json
andyarn.lock
are out of sync:The
yarn.lock
contains:Now if one runs
the
yarn.lock
will be unexpectedly updated with an unknown future version of a dependency, only defined by the range of the provided semvar potentially breaking the build in the future, esp. if run on a build machine (jenkins):The
yarn.lock
now contains the following on the build machine, yet the version oflodash
is not locked in and prone to change in the future:What is the expected behavior?
The one that the
frozen-lockfile
provides, as it yields an error. This is quite helpful on build machine, i.e. Jenkins as those builds should fail. It is up to the developer on how to resolve the dependencies.As @BYK pointed out it would also be already helpful if yarn detects if it is running are in CI mode.
My in detail rationale for the change of the default behavior was posted in the already closed issue making a case for pure-lockfile.
Here's the gist of it:
NOTE: The highest-rated comment's solution has its own problems: #4570
The text was updated successfully, but these errors were encountered: