clibyang

Sysrepo sr_install_module() not considering search_dirs parameter


I'm trying to install a sysrepo module with sr_install_module()

When calling the following code though, the function seems to dismiss the search dirs parameter as the call fails with the error libyang[0]: Failed to open file "iana-if-type.yang" (No such file or directory).

#include "sysrepo.h"
#include "libyang/libyang.h"

sr_conn_ctx_t *srContext;
sr_connect(SR_CONN_CACHE_RUNNING, &srContext);


char *moduleName = "ietf-interfaces.yang";
char *searchDir = "/path/to/dir"
sr_install_module(srContext, moduleName, searchDir, NULL);

The module exists in "/path/to/dir" but is not found by the call. If I instead use "/path/to/dir/ietf-interfaces.yang as the value of moduleName the module is found correctly. What am I missing here?


Solution

  • Judging by the documentation of sr_install_module() this is quite expected. The following is said about the parameter search_dirs:

    [in] search_dirs Optional search directories for import schemas, supports the format <dir>[:<dir>]*.

    So, this parameter (directory) is only used to look up any modules that are imported by the module you are importing. Hope that makes sense.

    Regardless of that, the second parameter is called schema_path and not module_name for a reason.