You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Better report success when nodejs.exe creation fails #303
C:\Users\bers>nodeenv x
* Install prebuilt node (17.8.0) ..... done.
You do not have sufficient privilege to perform this operation.
You do not have sufficient privilege to perform this operation.
Error: Failed to create nodejs.exe link
C:\Users\bers>nodeenv x
* Environment already exists: x
To me, this looks like the first operation failed, and I only see that upon trying again.
(I have the impression that this hinders pyright startup on my system, but I am not experienced enough with either to say if that is in fact working as intended or not.)
install_activate calls it with show_stdout=True, so mklink's single line of output is echoed twice. That is the duplication you are seeing, not two separate attempts.
The OSError is then caught and turned into logger.error('Error: Failed to create nodejs.exe link'). Per #180 this is intentionally non-fatal, but between the doubled output and the Error: prefix at ERROR level it reads like the run failed, while nodeenv in fact exits 0 and the env is usable.
A second way the same call fails
#190 hit the same code path with a different message:
Invalid switch - "Temp".
Invalid switch - "Temp".
Error: Failed to create nodejs.exe link
and with in_shell=Truecallit does a bare cmd = ' '.join(cmd). The quoting loop above it only builds cmd_desc for the debug log, it is not applied to what actually runs. So if the env path was given with forward slashes (nodeenv C:/Temp/.../nenv), cmd parses /Temp as a switch. An env path containing a space breaks the same way.
Suggestion
mklink is a cmd builtin, which is the only reason this needs a shell at all. Python can do it directly, the way the non-Windows branch already does:
ifnotos.path.exists(shim_nodejs):
ifis_WIN:
try:
os.symlink('node.exe', shim_nodejs)
exceptOSError:
try:
os.link(join(bin_dir, 'node.exe'), shim_nodejs)
exceptOSError:
logger.warning('Could not create the nodejs.exe link; ''this is harmless unless something on your ''system invokes node as "nodejs"')
else:
os.symlink('node', shim_nodejs)
That gets rid of the shell entirely, so the quoting bug and both duplicated lines go away. os.symlink also succeeds without elevation when Developer Mode is on (documented for 3.8+), and the hard link needs no privilege at all, so the common case in this report stops failing rather than just reporting more nicely. The remaining message is a warning that says what the user loses, which I think is what you were asking for here.
Activity
ekalinin commentedon Sep 19, 2026
Digging into this while closing #190, which quotes the same failure plus a second flavour of it. Some findings that might help.
Why the message is printed twice
callitprints every line of the child's output as it reads it, and then, if the exit code is nonzero, prints the whole buffer again before raising:install_activatecalls it withshow_stdout=True, somklink's single line of output is echoed twice. That is the duplication you are seeing, not two separate attempts.The
OSErroris then caught and turned intologger.error('Error: Failed to create nodejs.exe link'). Per #180 this is intentionally non-fatal, but between the doubled output and theError:prefix atERRORlevel it reads like the run failed, whilenodeenvin fact exits 0 and the env is usable.A second way the same call fails
#190 hit the same code path with a different message:
That one is a quoting bug. The call is
and with
in_shell=Truecallitdoes a barecmd = ' '.join(cmd). The quoting loop above it only buildscmd_descfor the debug log, it is not applied to what actually runs. So if the env path was given with forward slashes (nodeenv C:/Temp/.../nenv),cmdparses/Tempas a switch. An env path containing a space breaks the same way.Suggestion
mklinkis acmdbuiltin, which is the only reason this needs a shell at all. Python can do it directly, the way the non-Windows branch already does:That gets rid of the shell entirely, so the quoting bug and both duplicated lines go away.
os.symlinkalso succeeds without elevation when Developer Mode is on (documented for 3.8+), and the hard link needs no privilege at all, so the common case in this report stops failing rather than just reporting more nicely. The remaining message is a warning that says what the user loses, which I think is what you were asking for here.fix(nodeenv): link nodejs.exe without mklink
chore(release): bump nodeenv version to 1.11.0