karate.config.dir on windows results in path-separator replaced by dot

Created on 15 Oct 2020  路  6Comments  路  Source: intuit/karate

refer https://stackoverflow.com/q/64363749/143475

would appreciate someone on windows debugging and fixing this - but able to confirm that mac / linux is ok with the fix

most likely this line is the problem: https://github.com/intuit/karate/blob/master/karate-core/src/main/java/com/intuit/karate/ScriptBindings.java#L108

wontfix

All 6 comments

@ptrthomas I would like to work on the fix if it's ok?

@Sudhish2607 yes go ahead

I tried to replicate the issue mentioned in StackOverflow. I believe it's not a bug!

It's happening because the command is being run on PowerShell instead of CMD.

Solution:

  • Update the default shell of VisualStudio from PowerShell to CMD
  • Update the system-properties parameter from -Dkarate.config.dir=test/resources/ to `-Dkarate.config.dir`=test/resources/
    i.e. from:
    java -Dkarate.config.dir=test/resources/ -cp karate.jar com.intuit.karate.Main
    to
    java `-Dkarate.config.dir`=test/resources/ -cp karate.jar com.intuit.karate.Main

More context over the issue:
PowerShell has a more standard rule to parse system-properties parameters which are different from CMD. In a PowerShell command, the parameter names always begin with a hyphen. The hyphen tells PowerShell that the item in the command is a parameter name.

Here, we are passing the parameter as -Dkarate.config.dir, PowerShell sights the parameter name-tag as -Dkarate and not -Dkarate.config.dir; hence the error.

@Sudhish2607 makes total sense. thank you so much for looking into this and for adding a good stack-overflow answer ! I will close this then.

cc @kirksl just for information, I didn't know about the back-ticks thing in powershell

@ptrthomas, PowerShell could be a trouble for setting up the plugin on VS. Should we add the VS-plugin installation instructions here?

@Sudhish2607 thanks, I just did that and linked to a page where is a lot of detail: https://github.com/intuit/karate/wiki/Karate-Robot-Windows-Install-Guide#install-visual-studio-code

Was this page helpful?
0 / 5 - 0 ratings