nodist icon indicating copy to clipboard operation
nodist copied to clipboard

"nodist latest" looks buggy to me.

Open ashidaharo opened this issue 3 years ago • 6 comments

Log

PS C:\Users\ashida.DESKTOP-MTMA9GA> nodist --version
0.9.1
PS C:\Users\ashida.DESKTOP-MTMA9GA> nodist
  (x64)
  11.13.0
  12.22.6
  14.17.6
> 16.9.1  (global: 16.9.1)
PS C:\Users\ashida.DESKTOP-MTMA9GA> node --version
v16.9.1
PS C:\Users\ashida.DESKTOP-MTMA9GA> nodist latest
latest
latest (global)
PS C:\Users\ashida.DESKTOP-MTMA9GA> node --version
v11.13.0
PS C:\Users\ashida.DESKTOP-MTMA9GA> nodist remove 11.13.0
PS C:\Users\ashida.DESKTOP-MTMA9GA> nodist
  (x64)
  12.22.6
  14.17.6
> 16.9.1  (global: latest)
PS C:\Users\ashida.DESKTOP-MTMA9GA> node --version
v12.22.6

After getting the list of installed versions, it looks like the sort direction is wrong when finding the latest?

ashidaharo avatar Sep 20 '21 15:09 ashidaharo

https://github.com/nullivex/nodist/blob/32ad8e588c4d429ce49312d4d4537b15841fd976/src/lib/nodist/nodist.go#L202 If this behavior is reproduced in other environments than mine, then the cause of this problem is probably here. However, since I only have one computer, I can't determine if this is a problem that only occurs in my environment, so I threw an Issue.

ashidaharo avatar Sep 20 '21 15:09 ashidaharo

Hello,

First of all, thank you for the report. If that code is the cause according to Git history it has been there for a very long time. I will test on my local computer as I finish this new release that people have been waiting for.

I will let you know my findings.

nullivex avatar Sep 20 '21 17:09 nullivex

If that code is the cause according to Git history it has been there for a very long time.

Well... it certainly looks right to me at first glance, as far as the changelog for this file is concerned. But it sounds very strange to me, because I don't remember this kind of behavior in previous versions. From there, I thought that I was mistaken and that the real cause might be somewhere else, so I did a control experiment with the previous version.

PS C:\Users\ashida.DESKTOP-MTMA9GA> nodist --version
0.8.8
PS C:\Users\ashida.DESKTOP-MTMA9GA> nodist
  (x64)
  11.13.0
  12.22.6
  14.17.6
> 16.9.1  (global: 16.9.1)
PS C:\Users\ashida.DESKTOP-MTMA9GA> node --version
v16.9.1
PS C:\Users\ashida.DESKTOP-MTMA9GA> nodist latest
latest
Default global pacakge update dsuccessful.
PS C:\Users\ashida.DESKTOP-MTMA9GA> node --version
v16.9.1

This is conclusive proof. The part I pointed out was not the root cause of the problem that has come to be caused by the current version. (Of course, perhaps just fixing this part would solve the problem.) I am not able to build a build environment (as I am not familiar with the go language) to verify this issue further, but I change my opinion that it is probably a build issue or a library dependency issue of the go language. ...Of course, this opinion is meaningless unless the problem can be reproduced in other environments.

ashidaharo avatar Sep 21 '21 03:09 ashidaharo

No, it's not. There's something fundamentally wrong. ...This. #210 This fix was probably the real mistake in this problem. As far as I can tell from the logs mentioned in this PR, this was not a problem with shim, but with the nodist CLI. But in fact the fix was made to shim. This seems to have been the biggest mistake.

ashidaharo avatar Sep 21 '21 04:09 ashidaharo

Now that we know the cause, we don't need to think about the differences in the environment. The following experiment reproduces that the #210 problem itself has not been solved.

PS C:\Users\ashida.DESKTOP-MTMA9GA> nodist npm use latest
PS C:\Users\ashida.DESKTOP-MTMA9GA> nodist npm ls
> 6.9.0  (global: latest)
  7.21.1

Therefore we need to do the following two things

  1. revert the fix we made in #210
  2. fix the problem that the latest in lib/npm.js is not handled correctly

ashidaharo avatar Sep 21 '21 04:09 ashidaharo

2. fix the problem that the latest in lib/npm.js is not handled correctly

And it's this. https://github.com/nullivex/nodist/blob/32ad8e588c4d429ce49312d4d4537b15841fd976/lib/npm.js#L142 We can reapply a fix like #210 here. At this level, I think I can implement the fix even if I don't have a build environment for the go language. ...since this fix doesn't require the go language.

ashidaharo avatar Sep 21 '21 04:09 ashidaharo