intellij-community icon indicating copy to clipboard operation
intellij-community copied to clipboard

IDEA-304758 - Add support for Nushell when loading environment

Open shyim opened this issue 1 year ago • 4 comments

This fixes https://youtrack.jetbrains.com/issue/IDEA-304758, by adjusting the script when the shell is Nushell to | save <path>. Also escaped paths requires a ^ in nushell, otherwise it just outputs the path as a string.

I tested the change with Nushell and Bash. For every other shell, the generated script is exactly the same as before.

shyim avatar Jan 19 '24 19:01 shyim

Any reason it can't be merged?

ultinous-kszegi avatar Apr 18 '24 16:04 ultinous-kszegi

I'd love for nushell support to get added; but I think there is a smaller adjustment that can fix the bug in a more platform-agnostic manner.

The flaw which is at fault for causing nushell not to be supported is that the process being spawned in order to extract the environment is expecting the user's shell to be POSIX compliant. The mechanism for extracting the environment, for some reason, uses shell programming to forward the output of the executable into a temporary file. For some reason this is done through the command passed into the shell, rather than performing this task in java land. Because of that the forward-info-file notation (program > file) must be supported by the user's shell. Not the case with nushell.

Here the fix proposed changes the shell command into one that is nushell compliant. This means that the same problem will occur with any other non-posix shell. I'd argue that instead the problem that needs to be addressed is that the IDE is relying on shell programming to extract the environment data into a file, while it could do this perfectly itself.

For example:

  1. Passing the output location as an argument to the environment extraction program.
  2. Reading the extraction program's stdout into the IDE memory and not using a temp file at all.
  3. Some hidden setting to modify the shell extraction in corner cases, like non-posix shells.

I haven't been able to think any reason why the environment extraction is written the way it is; relying on posix for the shell while you could also just read the program's stdout into java seems much more sane.

EDIT: This is not a critique of @shyim, but the JetBrains code that is causing the problem in the first place.

blended-bram avatar Jul 08 '24 12:07 blended-bram