How to modify the shell PATH of the command line?
已回答
In the Settings > Tools > Terminal menu, you can read here that you can change the Shell path and there are example of how to add parameters.
I want to be able to launch the default "cmd.exe" with the option that changes the PATH like this:
cmd.exe /k "set PATH=C:\Python35;C:\Python35\Scripts;%PATH%"
However when I add those option I get "java.io.IOException: Couldn't create PTY"
I've tried many things, including enclosing everything with quotes, simple quotes, double quotes...
How to run cmd.exe with those options? (Note: I don't want to change my global PATH settings (where I use Python36), I just want to change the path for this specific project)
请先登录再写评论。
Answered here: https://stackoverflow.com/questions/49872537/pycharm-windows-how-to-modify-the-shell-path-of-the-command-line
Can you tell me how to do the same with the powershell terminal? On my Windows machine, I have multiple Java versions installed and different projects require different versions. I thought of setting JAVA_HOME and PATH in the project settings for the terminal.
1. I can define Environment variables in that dialog. That works well for JAVA_HOME, but I don't see an option to _prepend_ the current path. Clone and modify it seems a bit ugly as from time to time, the path should change, also for all my terminals..
2. I thought of the same idea as above. I actually developed two variants. Both work fine, if I open my powershell.exe on Windows (not from within IntelliJ) and execute the following (java version will be as expected) but if I paste that command 1:1 exactly to "Shell path", it looks like the commands are executed but have no effect, JAVA_HOME and PATH will still have their old values.
2.1:
2.2:
powershell.exe -NoExit -command '& {[Environment]::SetEnvironmentVariable(''JAVA_HOME'',''C:\PROGRA~1\Java\jdk-13.0.1'',''Process''); [Environment]::SetEnvironmentVariable(''Path'',$env:JAVA_HOME + ''\bin;'' + $env:Path,''Process'')}'@...
1. Here is the feature request for that: https://youtrack.jetbrains.com/issue/IDEA-211527. Feel free to watch and follow.
2. It is better to ask that on StackOverflow, as the question seems to be PowerShell-specific.