Skip to content
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 upgrade-interactive fails with Invalid version: undefined error if a dependency has only prerelease versions #5955

Open
technicallyfeasible opened this issue Jun 8, 2018 · 8 comments

Comments

@technicallyfeasible
Copy link

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

What is the current behavior?
When running yarn upgrade-interactive and a dependency does not have a "latest" version then it fails with an error "Invalid version: undefined"

If the current behavior is a bug, please provide the steps to reproduce.

  • add a dependency that does not have a "latest" tag (only prerelease versions published with tag "beta")
  • run yarn upgrade-interactive

What is the expected behavior?
The command should run successfully and show the upgradeable versions of all packages.

If the package in question has a later prerelease version, that version should be suggested to be upgraded to.

Please mention your node.js, yarn and operating system version.

Arguments:
C:\Program Files (x86)\node\node.exe C:\Users\jens.elstner\AppData\Roaming\npm\node_modules\yarn\bin\yarn.js upgrade-interactive

Yarn version:
1.7.0

Node version:
8.11.1

Platform:
win32 x64

Trace:
TypeError: Invalid Version: undefined
at new SemVer (C:\Users\jens.elstner\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:2465:11)
at SemVer.module.exports.SemVer.compare (C:\Users\jens.elstner\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:2528:13)
at compare (C:\Users\jens.elstner\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:2752:31)
at Function.lt (C:\Users\jens.elstner\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:2786:10)
at isDepOld (C:\Users\jens.elstner\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:36817:134)
at Array.filter ()
at Function. (C:\Users\jens.elstner\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:36822:19)
at Generator.next ()
at step (C:\Users\jens.elstner\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:98:30)
at C:\Users\jens.elstner\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:109:13

@ghost ghost assigned kaylie-alexa Jun 8, 2018
@ghost ghost added the triaged label Jun 8, 2018
@rally25rs
Copy link
Contributor

Interesting. I'd never seen a package where the npm registry didn't return a latest. We should do something to handle those.
I suspect (but have not debugged to check) that this caused by this line: https://github.com/yarnpkg/yarn/blob/master/src/package-request.js#L443 which passes the value of latest to semver.lt() if someone wants to work up a PR 😸

@technicallyfeasible
Copy link
Author

this happened when we were using our own internal registry and had only published versions of some packages with a beta tag

@kpbl
Copy link

kpbl commented Jun 9, 2018

Can i try this one? Its my first time contributing to open source.

@rally25rs
Copy link
Contributor

@kpbl Sure! We appreciate the help! If you submit a PR, you should be able to mark me as a requested reviewer. Be sure to add a unit test too if you can. Thanks! 😸

@kpbl
Copy link

kpbl commented Jun 18, 2018

I do not really know how to test this because i have no private registry.
I want to add a test to https://github.com/yarnpkg/yarn/blob/master/__tests__/commands/upgrade-interactive.js is that the correct way?

@kpbl
Copy link

kpbl commented Jun 19, 2018

@rally25rs any tips?

@technicallyfeasible
Copy link
Author

I believe to test this it should be possible to add a new package to the official npm registry which only has a "beta" tag defined and is a prerelease version. Not sure how this would work in a unit test though.

@iam-prabha
Copy link

Is this issue still solved or not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants