-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"jenv use" doesn't work in powershell #52
Comments
seems failed to set |
seems invoking ps1 script via > pwsh -Command '& {$Env:var=1; echo "Inner: $Env:var"}' ; echo "outer: $Env:var"
Inner: 1
outer: I think the root cause is here. When
|
hi @FelixSelter, I came upon a solution which might be not elegant. Each time run IF %1==use (
%ps% -executionpolicy remotesigned -NoExit --NoLogo -File "%~dp0/src/jenv.ps1" %* --output
) ELSE (
%ps% -executionpolicy remotesigned -File "%~dp0/src/jenv.ps1" %* --output
) My question is, why we just ditch bat entirely, and use pwsh/powershll directly? |
We still need to use batch because there are windows users using cmd. Normally the powershell script can change the env vars of powershell. The batch file is not ment to be used by powershell users as stated in the readme. Please call jenv.ps1 directly. Then no batch file is called and your env vars will be set correctly. At least I hope so. :) The batch scripts only purpose is to be called by cmd users |
Thx for the explanation. The awkward situation is when |
You may just delete or rename jenv.bat for now. All of these issues will be
fixed once I have time to do a proper rewrite
kid1412621 ***@***.***> schrieb am Do., 25. Mai 2023, 17:39:
… We still need to use batch because there are windows users using cmd.
Normally the powershell script can change the env vars of powershell. The
batch file is not ment to be used by powershell users as stated in the
readme. Please call jenv.ps1 directly. Then no batch file is called and
your env vars will be set correctly. At least I hope so. :) The batch
scripts only purpose is to be called by cmd users
Thx for the explanation. The awkward situation is when JEnv-for-Windows
directory put into PATH, the jenv.bat precedes the jenv.ps1(even putting
JEnv-for-Windows/src before JEnv-for-Windows). If it's possible to
provide jenv by installing it as PowerShell module.
—
Reply to this email directly, view it on GitHub
<#52 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ANHZIAVWSQYXJRXM76O7CU3XH54JHANCNFSM6AAAAAAXGOPDZU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
need minor change in where /q pwsh
IF ERRORLEVEL 1 (
where /q powershell
IF ERRORLEVEL 1 (
echo Neither pwsh.exe nor powershell.exe was found in your path.
echo Please install powershell it is required
exit /B
) ELSE (
set ps=powershell
)
) ELSE (
set ps=pwsh
)
for /f "delims=" %%i in ('%ps% -Command & {jenv getjava}') do set "var=%%i"
Thanks, no worries. Take your time, and I'd glad to help. |
Thank you for your suggestion. I`ll keep this in mind when doing the proper rewrite. Its planned to add a fully functional powershell integration as well as many more for other shells. Tomorrow holidays will start so I have two weeks of partially spare time to enhance this tool |
@FelixSelter I see this same issue while using Git Bash on Windows |
This problem can be solved by adding a jenv.ps1 at the top level of this project: $jenv_path = "${PSScriptRoot}/src/jenv.ps1" -replace ' ','` '
Invoke-Expression "${jenv_path} $args" |
if you use git bash on windows, you should use https://www.jenv.be/ instead of this project. |
powershell
cmd
The text was updated successfully, but these errors were encountered: