Repository navigation
Unable to disable REPL history on Windows #25661
Description
Activity
I spoke too soon, the
setx NODE_REPL_HISTORY ""method doesn't work either. It does create a blank variable, and I can see it gets added to the Registry, but it's not actually visible in any launched process. I've confirmed this usingconsole.log(process.env);in Node and from viewing the process environment using Process Explorer. Presumably the Win32 loader removes blank variables when creating a process.The blank variable can be seen in the System Properties UI, presumably because it enumerates them from the Registry rather than its process environment, but it can only be deleted or a value set.
So as it stands it seems disabling the REPL history is not possible on Windows until an alternate non-blank value is recognised for the
NODE_REPL_HISTORYenvironment variable.- changed the title
[-]Add alternate recognised value to disable REPL history on Windows[/-][+]Unable to disable REPL history on Windows[/+]on Jan 23, 2019 - addedreplIssues and PRs related to the REPL subsystem.Issues and PRs related to the REPL subsystem.windowsIssues and PRs related to the Windows platform.Issues and PRs related to the Windows platform.
on Jan 23, 2019 Try
set NODE_REPL_HISTORY=@ralish setting the environment variable to an empty string or a string that contains only whitespace should work just fine (as documented). I guess the latter should work even if Windows does not recognize empty strings.
- addedquestionIssues asking questions about Node.js.Issues asking questions about Node.js.
on Jan 23, 2019 Sigh, my bad, missed a space: "
set NODE_REPL_HISTORY=" (with a space after '='). That will disable repl.@bzoz: You're right, this does work, thanks!
@BridgeAR: Yep, the fact whitespace is trimmed is the key.Can I suggest at least a documentation update to make it a bit more explicit that on Windows one or more space characters should be used? Right now it's implied on closer reading with the whitespace trimming, but making it concrete would I think be helpful as the empty string is not valid on Windows.
@ralish please feel encouraged to open a pull request to improve the wording :-)
- addeddocIssues and PRs related to Node.js documentation.Issues and PRs related to Node.js documentation.and removedquestionIssues asking questions about Node.js.Issues asking questions about Node.js.
on Jan 23, 2019 - added a commit that references this issue
on Jan 28, 2019 - added a commit that references this issue
on Apr 29, 2019 - added a commit that references this issue
on May 10, 2019 - added a commit that references this issue
on May 16, 2019 - added a commit that references this issue
on Jul 27, 2026
lib/internal/repl.js)Per the REPL documentation the history file path can be changed by setting the
NODE_REPL_HISTORYenvironment variable to a valid path or disabled by setting it to the empty string.On Windows platforms an empty environment variable is difficult to set. From my own testing:
sysdm.cpl).''or""will set it to a literal two single quotes or double quotes when using the System Properties UI.''will set it to a literal two single quotes when using thesetxCommand Prompt utility.I've found that a blank variable can be set using
setxwith two double quotes:setx NODE_REPL_HISTORY "". I haven't tried calling the underlying Win32 SetEnvironmentVariable function directly but given the behaviour ofsetxit presumably would work.It seems clear to me that setting blank environment variables is discouraged and the support for doing so is patchy at best. This being the case, it would be desirable to support an alternate value that's legal on Windows to indicate that the REPL history should not be saved. One possible option would be recognising the value
''(i.e. two single quotes) which in my view is the most intuitive setting, but there's of course other options.Thoughts?