News for hackers. Stuff that matters.
Re:What NPM should do to stop a new colors attack by MattPalmer1086 on Monday January 10, 2022 @06:04PM (#29884274)
No, we really don't need a way to say get the last version from 5 minutes ago.

We need to get the version that we tested with and know works, which is what it does. When we need to update, we say what version we want.

Java can be a pain, but I'm very glad it doesn't handle dependencies like npm.

Re:What NPM should do to stop a new colors attack by acdha on Monday January 10, 2022 @06:13PM (#29884408)
This is also saying you can't easily update from 1.2.3 to 1.2.4 without all of your dependencies which specify 1.2.3 also being updated without having an override mechanism. This isn't a simple problem where one option has no downsides.
Re:What NPM should do to stop a new colors attack by MattPalmer1086 on Monday January 10, 2022 @07:15PM (#29885174)
Oh, I agree that there's no simple solution that solves everything.

I'm still glad that basically noone else handles dependencies like npm.

Re:What NPM should do to stop a new colors attack by remram on Monday January 10, 2022 @11:18PM (#29887477)
Everybody else handles dependencies like npm, e.g. installs the latest versions that satisfy constraints. Some package managers have the ability to install from a lock file (e.g. Python's Poetry, Python's Pipenv, Rust's Cargo, npm) but will still grab the latest version when the lockfile doesn't exists (e.g. cloned a project with no lock file, or just added the dependency yourself), and have a command to update which updates every single package to the latest compatible versions.

You can argue that npm's commands are poorly named and guide users towards bad defaults, but saying that it works in a unique way is not true.

Re:What NPM should do to stop a new colors attack by MattPalmer1086 on Tuesday January 11, 2022 @03:25AM (#29888971)
I guess my experience is limited. For example, maven dependencies usually specify the exact version required in the pom files. At least, on all the projects I've ever dealt with.
Re:What NPM should do to stop a new colors attack by acdha on Tuesday January 11, 2022 @07:45AM (#29890851)
I’ve seen plenty of pom.xml files which are unversioned — not having a standard command to update means less disciplined developers say it’s too much work – but increasingly in other languages (and Gradle IIRC) there’s a distinction between the metadata file listing your direct dependencies and a lock file detailing exactly what was installed. The idea is that (using Node as an example) I’d say “I depend on the AWS SDK” in the main file, which changes infrequently when I add or remove direct dependencies, but my tool would use the lock file (npm-shrinkwrap) to record the exact versions of every package, preferably even by file hash, so you can have a highly repeatable build.

Separating the two is handy both due to frequent churn and to avoid transitive dependencies being kept unnecessarily — I’ve seen projects where libfoo stopped depending on libbar a while back but they were still installing it because someone had copy-pasted that block years before and was just incrementing the version.

Re:What NPM should do to stop a new colors attack by MattPalmer1086 on Wednesday January 12, 2022 @03:40PM (#29912384)
Thanks for the explanation, makes a lot of sense :)
Re:What NPM should do to stop a new colors attack by acdha on Wednesday January 12, 2022 @04:04PM (#29912653)
You’re welcome!
Re:What NPM should do to stop a new colors attack by bogeholm on Monday January 10, 2022 @06:14PM (#29884430)
Well, in a log4j situation or similar, I am sure there are cases where it is preferred to update first, and fix production later.

So that would be “get the one from 5 minutes ago, no questions asked”

Re:What NPM should do to stop a new colors attack by MattPalmer1086 on Monday January 10, 2022 @07:13PM (#29885145)
Nothing stops you from updating to the latest version and not testing it if it's urgent.

You just specify the latest version. But you do it explicitly.