Troubleshooting Dependency Issues with http-client in FPM Projects: Resolving stdlib_optval Error

Hello everyone,

I’m currently involved in the http-client project, which allows Fortran programmers to make HTTP requests. The project relies on the stdlib library as a dependency.

Recently, I encountered an issue while using http-client as a dependency in a new fpm project. When attempting to build the project with fpm build, I encountered the following error:

$ fpm build
<ERROR> *cmd_build* Target error: Unable to find the source for the module dependency: "stdlib_optval," which is used by "build/dependencies/http/src/http/http_client.f90"
STOP 1

I added http as a dependency in the fpm.toml file like this:

[dependencies]
http.git = "https://github.com/fortran-lang/http-client.git"

It seems that the error was related to the stdlib. To fix the problem, I added stdlib="*" to the fpm.toml file of the new project, and now the project builds successfully:

[dependencies]
http.git = "https://github.com/fortran-lang/http-client.git"
stdlib = "*"

This addition of stdlib="*" allows the new project to utilize the necessary stdlib features and resolve the build issue.

3 Likes

I had to replace:

stdlib = "*"

with

stdlib = { git = "https://github.com/fortran-lang/stdlib.git", branch="stdlib-fpm" }

Otherwise, it won’t work. Maybe, my fpm version is too old.

Edit: Updated from 0.8.1 to 0.9.0, works now.

after replacing it, while building the project I am getting this error :

<ERROR> *cmd_build* Package error: Could not retrieve version string for metapackage key <stdlib>. Check syntax
STOP 1

my fpm version is also 0.9.0

  • For fpm <= 0.8.2: use git syntax
  • For fpm == 0.9.0: use metapackage syntax (dependencies not supported)
  • HEAD currently supports both those cases, but we have not released a new version yet.

Regarding handling dependencies with metapackages, I hope we can find consensus on the implementation during the upcoming monthly call: what should be done, for example, if one dependency requires a metapackage, but another one has it specified as a standard dependency? Which should have precedence?
Maybe at some point fpm will have better version constraint resolution, but I don’t see it implemented in the short term

2 Likes