open-simulation-platform / cosim-cli

Command-line interface for libcosim

Home Page:https://open-simulation-platform.github.io/cosim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cosim inspect requires absolute paths only

frl000 opened this issue · comments

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

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

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?

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.