open-simulation-platform / cosim-cli

Command-line interface for libcosim
https://open-simulation-platform.github.io/cosim
Mozilla Public License 2.0
10 stars 4 forks source link

cosim inspect requires absolute paths only #84

Closed frl000 closed 2 years ago

frl000 commented 3 years ago

The current build from master branch requires an absolute path to FMU file. It only succeeds in the form C:\>cosim.exe inspect C:\PATH\Spring.fmu instead of C:\>cosim.exe inspect .\Spring,fmu or C:\>cosim.exe inspect Spring.fmu Same for release cosim v0.5.0. Tested on W10.0.17763, command.exe

SSkjong commented 2 years ago

I have the same problem when running cosim run-single without absolute path (on Windows). Just tested with release v0.5.0.

ljamt commented 2 years ago

The inspect and run-single sub commands requires either a URI or an absolute path, meaning that relative paths can be used like this: cosim.exe inspect file:///../../example.fmu

I assume we could detect when users give a relative path (uri_or_path argument starts with .), and build the corresponding URI under the hood. As the original author @kyllingstad, what do you think?

kyllingstad commented 2 years ago

As far as I can tell, this seems to be a Windows-only problem. The error originates in tools.cpp, line 27, where we call cosim::path_to_file_uri() on the user-provided path. It seems this function doesn't support relative paths. I have an idea of how to fix this, and I'll try to have a PR ready soon.