Trouble using Fortran Package Manager

I am trying to use fpm on WSL2.

In the directory /mnt/c/fortran/linux_fpm/call_sort the fpm.toml is

name = "call_sort"
author = "Beliavsky"

[build]
auto-executables = true
auto-tests = true
auto-examples = true

[install]
library = false

[dependencies]
orderpack.git = "https://github.com/urbanjost/orderpack"
orderpack.branch = "orderpack-fpm"

I ran the following git commands:

git add app/main.f90
(base) /mnt/c/fortran/linux_fpm/call_sort$ git commit -m "initial commit"
On branch master
nothing to commit, working tree clean

Trying to use fpm I get

fpm run
fatal: your current branch 'master' does not have any commits yet
<ERROR>*cmd_run*:model error:Error while retrieving commit information
STOP 1

and I don’t know what to do. I’ll admit to not knowing how to use git. Is that a prerequisite for using fpm?

You can use fpm without git if you have no remote dependencies, but you do. Once you did the add you need to do one commit, like in “git commit -m init” and then you should be pretty much able to ignore git after that; but you can probably get by with just that at first; and then use “git status”, “git add”, “git commit” gets you pretty far. If working with a group of people you will need to know how to make a branch pretty quickly; if working with a remote reposititory you will have to at least do a simple “git push” and “git pull” immediately. There are GUIs available; but I admit to not using them.

Hi @Beliavsky ,

Your specification of the orderpack dependency might be wrong in your fpm.toml file.

I’m not sure if this has been changed in the main repository since you commented, but looking at the README, the correct specification doesn’t have a branch:

[dependencies]
orderpack.git = "https://github.com/urbanjost/orderpack.git" 

After updating your fpm.toml manifest, you will need to delete the build directory, then it should work. Let me know if not.


The error from fpm here is a little confusing because you only get the error about the wrong branch specification the first time you run it:

$ fpm run
 + mkdir build\dependencies
Initialized empty Git repository in /home/lk12325/scratch/fpm-test/build/dependencies/orderpack/.git/
fatal: couldn't find remote ref orderpack-fpm
<ERROR>*cmd_build*:model error:Error while fetching git repository for remote dependency
STOP 1

$ fpm run
fatal: your current branch 'main' does not have any commits yet
<ERROR>*cmd_run*:model error:Error while retrieving commit information
STOP 1