Azure / azure-libraries-for-java

Azure Management Libraries for Java
https://docs.microsoft.com/en-us/java/azure/
MIT License
94 stars 98 forks source link

[BUG] FunctionCliResolver unable to handle spaces in the path #1437

Closed thomasmillercf closed 2 years ago

thomasmillercf commented 2 years ago

Describe the bug FunctionCliResolver is unable to handle spaces in the path. Found this out due to WSL adding a bunch windows PATH on the end of the ubuntu PATH. Then an expectation is return which is not very clear

To Reproduce Using WSL: Ubuntu

Install Func tools export PATH=$PATH:some path with spaces

Code Snippet

 val cliExec = FunctionCliResolver.resolveFunc();
        if (StringUtils.isEmpty(cliExec)) {
            throw RuntimeException("dead");
        }

Expected behavior It should either be able to handle spaces and return me the path to the func tools.

Looking into the code, why is the PATH even being modified? As i personally think this is a hack. As if the PATH was not being modified there would not be a issue

CommandUtils.class

        final String commandWithPath = isWindows() ? commandWithArgs : String.format("export PATH=$PATH:/usr/local/bin ; %s", commandWithArgs);

Work Around In my env make sure i have no spaces in the path.

weidongxu-microsoft commented 2 years ago

there is no FunctionCliResolver in this lib?