Skip to content
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

devon.bat stopped adding PATH #1066

Closed
hohwille opened this issue Mar 8, 2023 · 5 comments · Fixed by #1067
Closed

devon.bat stopped adding PATH #1066

hohwille opened this issue Mar 8, 2023 · 5 comments · Fixed by #1067
Assignees
Labels
blocker severe bug that blocks users in their daily work and has to be fixed asap bug Something isn't working windows specific for Microsoft Windows OS

Comments

@hohwille
Copy link
Member

hohwille commented Mar 8, 2023

On windows when using devon.bat (e.g. typing devon in CMD) it stopped setting the PATH properly.

D:\projects\mmm>devon
devonfw-ide environment variables have been set for D:\projects\mmm in workspace main

D:\projects\mmm>mvn -v
'mvn' is not recognized as an internal or external command,
operable program or batch file.

D:\projects\mmm>dir software
 Volume in drive D is DATADRIVE1
 Volume Serial Number is 120F-6414

 Directory of D:\projects\mmm\software

07.03.2023  12:43    <DIR>          .
07.03.2023  12:43    <DIR>          ..
06.02.2023  18:35    <DIR>          eclipse
30.11.2022  22:33    <DIR>          java
30.11.2022  18:36    <DIR>          maven
07.03.2023  12:43    <DIR>          node
09.01.2023  16:35    <DIR>          vscode
09.01.2023  16:38    <DIR>          vscode-extensions
               0 File(s)              0 bytes
               8 Dir(s)  262.994.305.024 bytes free

D:\projects\mmm>

This is a severe bug and it breaks the entire *.bat support of devonfw-ide.

@hohwille hohwille added bug Something isn't working windows specific for Microsoft Windows OS blocker severe bug that blocks users in their daily work and has to be fixed asap labels Mar 8, 2023
@hohwille hohwille added this to the release:2023.02.001 milestone Mar 8, 2023
@hohwille
Copy link
Member Author

hohwille commented Mar 8, 2023

I can already confirm:

  • The bug is originated from the devon.bat script
  • When I install the old release 2022.04.003 and use the devon.bat script from there, the error does not occur and it is working.

@hohwille
Copy link
Member Author

hohwille commented Mar 8, 2023

The bug was already in 2022.11.002 but on in 2022.11.001.
OMG, I have been so used to git-bash that I never used CMD since such a long time and never noticed the bug in my daily work!

@hohwille
Copy link
Member Author

hohwille commented Mar 8, 2023

It seems that PR #975 broke it and we never properly tested that and also our nightly windows tests do not reveal the error.

@hohwille
Copy link
Member Author

hohwille commented Mar 8, 2023

As a first analysis, I hacked this block in devon.bat as following:

if exist scripts\environment-project.bat (
  echo %CD%
  echo set DEVON_IDE_HOME=%CD%
  set DEVON_IDE_HOME=%CD%
  echo DEVON_IDE_HOME=%DEVON_IDE_HOME%
  echo DEVON_IDE_HOME=!DEVON_IDE_HOME!
  call scripts\environment-project.bat
  echo devonfw-ide environment variables have been set for %CD% in workspace %WORKSPACE%
  popd
  goto :eof
)

Result:

D:\projects\devonfw\workspaces>devon
D:\projects\devonfw
set DEVON_IDE_HOME=D:\projects\devonfw
DEVON_IDE_HOME=
DEVON_IDE_HOME=D:\projects\devonfw
devonfw-ide environment variables have been set for D:\projects\devonfw in workspace

D:\projects\devonfw\workspaces>mvn -v
'mvn' is not recognized as an internal or external command,
operable program or batch file.

I hate CMD and ENABLEDELAYEDEXPANSION is the gate to hell.
Whenever we change a single line in *.bat files of devonfw-ide we have to do very intensive testing next time...

@alfeilex
Copy link
Member

alfeilex commented Mar 9, 2023

I have removed the delayed expansion and found a possible solution to fix this issue.

The native problem relied on the %USER_PATH% variable.

for /F "tokens=2* delims= " %%f IN ('reg query HKCU\Environment /v PATH ^| findstr /i path') do set USER_PATH=%%g

We used the delayed expansion to get the correct value for this variable, as the variable was previously empty but there were entries in the user path.

I find a solution with an external label. Example:

@echo off
if 1==1 (

    for /F "tokens=2* delims= " %%f IN ('reg query HKCU\Environment /v PATH ^| findstr /i path') do set USER_PATH=%%g
	echo PATH=%USER_PATH%
    call :USERPATH
)
pause
exit

:USERPATH
    echo CALLED_PATH=%USER_PATH%
goto :EOF

Result:

PATH=
CALLED_PATH=%USERPROFILE%\scripts;
Press any key to continue . . .

The PATH is empty and the variable called in the external label is correct. So with an external label we should fix this error without using delay expansion.

Check the commits in PR https://github.com/devonfw/ide/pull/1067/files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker severe bug that blocks users in their daily work and has to be fixed asap bug Something isn't working windows specific for Microsoft Windows OS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants