Yarn: Yarn upgrade-interactive --latest now has the same output than yarn upgrade-interactive

Created on 21 May 2018  ยท  5Comments  ยท  Source: yarnpkg/yarn

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
I have this in my package.json

"dependencies": {
  "@babel/core": "^7.0.0-beta.46",
}

and this in my yarn.lock

"@babel/core@^7.0.0-beta.46":
  resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.0.0-beta.47.tgz#b9c164fb9a1e1083f067c236a9da1d7a7d759271"
    "@babel/core" "^7.0.0-beta.46"

I see there is a new babel version with yarn info @babel/core versions, the 7.0.0-beta.47, and I want to update my package.json to reflect it, so I run

yarn upgrade-interactive --latest

But the newer babel version doesn't show up in the list!

It's behaving like the command yarn upgrade-interactive, related issue is #4390

Maybe it has something to do with the resolved url in the yarn.lock?

What is the expected behavior?
I want my package.json to be updated

Please mention your node.js, yarn and operating system version.
Node v10.1.0, yarn v1.6.0, OSX

cat-bug

Most helpful comment

Weird, I don't know how it happened, I usually update the deps just with the upgrade-interactive command.

Anyway, I want a way to write the latest and installed version in the package.json, even when the semantic versioning is correct.

All 5 comments

Seems to work for me if I try to reproduce it:

~/Projects/yarn-test2 ๐Ÿ’   yarn
yarn install v1.6.0
[1/4] ๐Ÿ”  Resolving packages...
[2/4] ๐Ÿšš  Fetching packages...
[3/4] ๐Ÿ”—  Linking dependencies...
[4/4] ๐Ÿ“ƒ  Building fresh packages...
success Saved lockfile.
โœจ  Done in 3.00s.

~/Projects/yarn-test2 ๐Ÿ’   cat package.json
{
  "name": "yarn-test2",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "@babel/core": "^7.0.0-beta.46"
  }
}

~/Projects/yarn-test2 ๐Ÿ’   grep @babel/core@ yarn.lock
"@babel/core@^7.0.0-beta.46":

~/Projects/yarn-test2 ๐Ÿ’   yarn upgrade-interactive --latest
yarn upgrade-interactive v1.6.0
info Color legend :
 "<red>"    : Major Update backward-incompatible updates
 "<yellow>" : Minor Update backward-compatible features
 "<green>"  : Patch Update backward-compatible bug fixes
? Choose which packages to update. (Press <space> to select, <a> to toggle all, <i> to inverse selection)
 dependencies
   name         range   from              to             url
โฏโ—ฏ @babel/core  latest  7.0.0-beta.46  โฏ  7.0.0-beta.47  https://babeljs.io/

_Edit:_

though if you copy/paste from your lockfile is correct:

"@babel/core@^7.0.0-beta.46":
  resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.0.0-beta.47.tgz#b9c164fb9a1e1083f067c236a9da1d7a7d759271"
    "@babel/core" "^7.0.0-beta.46"

then it resolved to the beta.47.tgz so beta.47 is already installed. What does the version in the lockfile say? You seem to have omitted that line. Should actually look something like:

"@babel/core@^7.0.0-beta.46":
  version "????????"
  resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.0.0-beta.47.tgz#b9c164fb9a1e1083f067c236a9da1d7a7d759271"

Thanks for your time @rally25rs!

Here it is with the version:

"@babel/core@^7.0.0-beta.46":
  version "7.0.0-beta.47"
  resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.0.0-beta.47.tgz#b9c164fb9a1e1083f067c236a9da1d7a7d759271"
  dependencies:
    "@babel/code-frame" "7.0.0-beta.47"
    ...

It's actually the 47, but when I do yarn upgrade-interactive --latest I expect my package.json to be updated with the 7.0.0-beta.47 version also.


Here is the project repo
Here is the package.json with the @babel/core dep
To replicate run these commands:
git clone [email protected]:accurat/accurapp.git
cd accurapp
git checkout big-updates
yarn
yarn upgrade-interactive --latest

@babel/core isn't in the list:

Ah, yes, you've stumbled upon the edge case. I discussed this in a couple other issue threads, but I know the GitHub search leaves a lot to be desired...

The way the code works is that it first gets a list of outdated items (same as running yarn outdated. In your case it finds nothing outdated because latest is beta.47 and you have beta.47 installed.
Then, since there is nothing to update, the code returns.

If @babel/core had been outdated, then your package.json would have been updated. It's a bit of a weird case. I suppose it's a bug, but it never felt really critical since you'll still have the correct version actually installed.

Weird, I don't know how it happened, I usually update the deps just with the upgrade-interactive command.

Anyway, I want a way to write the latest and installed version in the package.json, even when the semantic versioning is correct.

Oh, I figured out how this happened, I removed the yarn.lock, the node_modules and run yarn again. So yarn installed the latest semantically correct version.

Was this page helpful?
0 / 5 - 0 ratings