Task summary
I ended up in a broken setup that caused this error on ide env:
An unexpected error occurred!
We are sorry for the inconvenience.
Please check the error below, resolve it and try again.
If the error is not on your end (network connectivity, lack of permissions, etc.) please file a bug:
[https://github.com/devonfw/IDEasy/issues/new?assignees=&labels=bug&projects=&template=b…](https://github.com/devonfw/IDEasy/issues/new?assignees=&labels=bug&projects=&template=bug.md&title=IllegalStateException%3A+Running+command+%27D%3A%5Cprojects%5Csalog%5Csoftware%5Cnpm%5Cbin%5Cnpm.cmd%27+with+arguments+%27--version%27%0Afailed+with+exit+code+1%21)
java.lang.IllegalStateException: Running command 'D:\projects\salog\software\npm\bin\npm.cmd' with arguments '--version'
failed with exit code 1!
at com.devonfw.tools.ide.process.ProcessContextImpl.performLogging(ProcessContextImpl.java:366)
at com.devonfw.tools.ide.process.ProcessContextImpl.run(ProcessContextImpl.java:207)
at com.devonfw.tools.ide.process.ProcessContext.runAndGetSingleOutput(ProcessContext.java:205)
at com.devonfw.tools.ide.process.ProcessContext.runAndGetSingleOutput(ProcessContext.java:154)
at com.devonfw.tools.ide.tool.npm.Npm.computeInstalledVersion(Npm.java:32)
at com.devonfw.tools.ide.cache.CachedValue.get(CachedValue.java:49)
at com.devonfw.tools.ide.tool.node.NodeBasedCommandlet.getInstalledVersion(NodeBasedCommandlet.java:68)
at com.devonfw.tools.ide.commandlet.EnvironmentCommandlet.setEnvironmentVariablesInLocalTools(EnvironmentCommandlet.java:138)
at com.devonfw.tools.ide.commandlet.EnvironmentCommandlet.run(EnvironmentCommandlet.java:86)
at com.devonfw.tools.ide.context.AbstractIdeContext.applyAndRun(AbstractIdeContext.java:1136)
at com.devonfw.tools.ide.context.AbstractIdeContext.run(AbstractIdeContext.java:1046)
at com.devonfw.tools.ide.cli.Ideasy.runOrThrow(Ideasy.java:95)
at com.devonfw.tools.ide.cli.Ideasy.run(Ideasy.java:59)
at com.devonfw.tools.ide.cli.Ideasy.main(Ideasy.java:133)
The EnvironmentCommandlet must be extremely robust. If errors like this happen, then entire IDEasy is broken.
Instead, we should add try/catch error handling to avoid that such errors break the entire usage of IDEasy but only the according tool (here npm) does not work.
Additional context
The command ide env shall not even raise error or warning log messages on such error.
However, when this code is invoked from regular commandlet, we should however see a log message indicating that something is wrong (at least on debug level but IMHO even on warning).
At least here we will need the try-catch:
|
tool.setEnvironment(environmentContext, toolInstallation, false); |
Task summary
I ended up in a broken setup that caused this error on
ide env:The
EnvironmentCommandletmust be extremely robust. If errors like this happen, then entire IDEasy is broken.Instead, we should add try/catch error handling to avoid that such errors break the entire usage of IDEasy but only the according tool (here
npm) does not work.Additional context
The command
ide envshall not even raise error or warning log messages on such error.However, when this code is invoked from regular commandlet, we should however see a log message indicating that something is wrong (at least on debug level but IMHO even on warning).
At least here we will need the try-catch:
IDEasy/cli/src/main/java/com/devonfw/tools/ide/commandlet/EnvironmentCommandlet.java
Line 142 in 03c8a30