FPM error during compilation

The following error suddenly displayed:

/opt/fpm/fpm build --profile "debug" (in directory: /home/.../projects/fortran/spas)
<ERROR>*cmd_build*:model error:Key test is not allowed in [build]
Compilation failed.

Version: 0.7.0, alpha

The content of fpm.toml file as follows (no changes and no dependencies update since the last time I successfully compiled the source):

# This is a TOML document

name = "..."

auto-examples = true
auto-executables = true
auto-tests = true
external-modules = ["_3rd_mod"]
link = []

# plenty of dependencies

test-drive.git = "https://github.com/fortran-lang/test-drive"
test-drive.tag = "v0.4.0"

library = false


Any suggestions/ideas? Tia

I have installed 0.8.1. Now I get the following:

/opt/fpm/fpm build --profile "debug" (in directory: /home/.../projects/fortran/spas)
# Dependency change detected: ...
# Dependency change detected: ...
# Dependency change detected: ...
# Dependency change detected: ...
# Dependency change detected: ...
<ERROR>*cmd_build* Model error: Key test is not allowed in [build]
Compilation failed.

Note: There are more dependencies than those 5 have displayed.

Is it a matter of some dependency? Tia

That looks like a typo in an fpm.toml file in your dependencies. It is surprising it is not saying which dependency the error occurred in. Are you deleting messages? Try adding the --verbose option. You should be able to go into the build/dependencies directory and look at the fpm.toml files. If cannot see the error you can cd into each dependency directory and enter ‘fpm build’ until you get the same error. If it is not showing it, we need to improve the error messages so you know which file is failing to be read.

1 Like

What that message means is you apparently have a key named test in the [build] section of your fpm.toml. That does not seem true from the example you have posted above though.

EDIT fully agree with @urbanjost comment: the typo is probably in one of the dependencies’ fpm.toml. If you get more information, we can definitely improve the output to point to the exact file/dependency where this is happening.

EDIT #2: an improvement is proposed here.

While building one by one the dependencies, I got the following errors in some fpm.toml:

  • @ FACE and FLAP incl. dep. FACE again: [[ test ]] blank spaces; so I removed them ie [[test]]
  • @ M_CLI ; I just commented it out


PS: I will inform the three projects about the errors soon.

This one was already merged Merge pull request #13 from jalvesz/master · szaghi/FACE@1455c54 · GitHub

@hkvzjal Ok, tal.
@urbanjost I see that M_CLI project is yours, so you are already aware of the error.

Ha! Somewhat ironically M_CLI did have an issue a few days ago. I
had a [build] before a line with test in it temporarily a few days ago because of a too-simple script that was used to change fpm.toml files automatically while testing fpm 0.8.0. that did not distinguish between test as used in test = {…} and [test]. It was changed days ago; so you need to clean or update the build/directory to get the correct version. The script was not clever
enough to realize a [build] had to go after, not before the lines

# unit test program
test = [ { name="runTests", source-dir="test", main="main.f90" } ]

Until your note I did not suspect M_CLI because the changes were being done with an automated script and there were over fifty repositories being tested. I changed the script to create a new branch for the testing, (which it should have done in the first place) so that cannot happen again.

but the important thing is that should just require refreshing the dependency to git rid of it.

The good news is as noted that the message should change shortly that makes it a lot easier to tell which dependency is at fault. You might also want to include a rev on your dependency so changes do not affect it; although that prevents you from automatically getting updates to a package.

I was thinking about a tool that would take a list of dependencies without revs and automatically update the fpm.toml file to lock it to a particular set of dependencies just a while ago; but my first try lost the comments in the fpm.toml file and I never went back to finish it but I know I would like to be able to do that, as I have had problems with some changes too.

1 Like