Hi,
here are the steps to reproduce (including error description). This happens on x64 system,
nvm install x.y.z (6.10.0 or alike, but version doesn't matter)
nvm uninstall x.y.z
=> uninstallation successful, no leftover
nvm install x.y.z
nvm use x.y.z
nvm use u.v.w (another version - just to be sure x.y.z is not used - this step is probably not necessary)
nvm uninstall x.y.z
=> need to remove folder x.y.z manually from nvm path, which always contains node.exe alone
IMO, this happens because before the "use" there is a node64.exe, which is renamed on "use" into node.exe. This node.exe remains from this point on and obviously blocks removal of folder.
I hope the description is clear enough.
Thanks
If you run nvm ls
after this, does it show the uninstalled version?
Yes, indeed - after install/use/uninstall, nvm ls still shows the
uninstalled version.
BTW, if I rename node.exe to node64.exe prior to uninstallation, the
version is removed completely (without having to manually remove the
folder).
OK, I've marked this as a bug. Which version of Windows are you running?
Which version of Windows are you running?
Windows 10 (anniversary update) x64
Hi,
afaict (but I'm not a Go developer) in arch.go:SearchBytesInFile the
opened file is never closed. So when os.RemoveAll tries to delete the
files there is a sharing violation.
I'm somewhat surprised though that this has not been reported before,
because I think that the bug should occur everytime a "used" version
(which contains node.exe) shall be uninstalled.
Once the executable completes an operation, it is no longer associated to any files. In other words, the executable runs one operation, then closes all file connections by exiting. However; I have not had a chance to personally test this on the latest Windows build. If Windows is now using a file lock for this operation, then you may be right... that could be lingering.
I'll try to debug this as soon as I can, but I'm on a contract job this week and have SXSWi obligations. So, it may be awhile before I can actually sit down with this.
Once the executable completes an operation, it is no longer associated to any files. In other words, the executable runs one operation, then closes all file connections by exiting.
IMO: nvm.exe opens node.exe (and only that, not node64.exe or alike)
and scans a couple of bytes, but it doesn't close the file handle.
Then nvm.exe tries to remove the folder (but of course hasn't exited
in between, so the file handle is still open).
However; I have not had a chance to personally test this on the latest Windows build. If Windows is now using a file lock for this operation, then you may be right... that could be lingering.
It's not really a file lock. I let nvm.exe output the error and it
reads "The process cannot access the file because it is being used by
another process" (which is the same message if it is in the very same
process).
I'll try to debug this as soon as I can, but I'm on a contract job this week and have SXSWi obligations. So, it may be awhile before I can actually sit down with this.
Okay, no problem. If you just could fix it in the next version.
Thanks!
I did a little testing and this only occurs if you nvm use x.x.x the version to be removed AND you are using arch 64. As has been mentioned the node64.exe is renamed to node.exe and not removed. However, if you use another version and manually rename node.exe to node64.exe (as ujaroe mentions) then the uninstall is completed successfully.
This means there is a couple of ways to correct the problem. I would recommend 'nvm use' restoring the version folder the use command is moving FROM back to the original state. The other is having uninstall check arch and make sure the node executable matches the arch of the version. There are a couple other things that could be done with symlinks but I think these are the best two options. My Go skill is pretty low but I will attempt to build one or both of these soon.
edit: spelling
Same issue here. CLI output:
❯ nvm list
* 8.4.0 (Currently using 64-bit executable)
6.11.2
6.10.0
❯ nvm uninstall 6.10.0
Uninstalling node v6.10.0...Error removing node v6.10.0
Manually remove C:\Users\darsain\AppData\Roaming\nvm\v6.10.0.
❯ nvm list
* 8.4.0 (Currently using 64-bit executable)
6.11.2
6.10.0
After running the uninstall
command, the v6.10.0
folder had only node.exe
file in it. I'm 99% sure nothing was using it. Deleting manually worked fine.
But, the v6.10.0
version was installed a while ago on nvm 1.1.1 I think. Today I upgraded to 1.1.6. Installing and removing node 6.11.2 which I did today after the upgrade worked fine though.
I can confirm this one. Also happened to me on Win10 x64 using node v6.9.1 and nvm 1.1.3
Also happened on Win10 x64 (version 1709) using node v8.11.1 and nvm 1.1.6
Hi, @coreybutler,the bug also happened on Windows10 x64, and if i use nvm use x.y.z
command to switch the version of nodejs, the x.y.z will not be uninstalled, while the a.b.c's version if i could not use nvm use
command, it can be uninstalled
need to reopen due to same issue on macOS
Most helpful comment
need to reopen due to same issue on macOS