Fornax
Fornax copied to clipboard
dotnet fornax build unable to find config.fsx on CI servers
Describe the bug Installing fornax as a local tool on a CI server and trying to build a site throws an error "Couldn't find or load config".
To Reproduce
- Create a fornax site (e.g. using
fornax new
) - Add a
dotnet-tools.json
with instructions to install fornax locally - Add a config file for your chosen CI platform which runs
dotnet tool restore
anddotnet fornax build
- Push your site to a git repo and build using the CI service of your choice (e.g. TravisCI, Netlify, Azure Pipelines, etc.)
- Watch the build fail and observe the printed error
Couldn't find or load config
.
Expected behaviour The site should build.
Build Output Below is the output from TravisCI. The same problem occurs on Azure Pipelines as well as Netlify.
dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.1.201
Commit: b1768b4ae7
Runtime Environment:
OS Name: ubuntu
OS Version: 16.04
OS Platform: Linux
RID: ubuntu.16.04-x64
Base Path: /usr/share/dotnet/sdk/3.1.201/
Host (useful for support):
Version: 3.1.3
Commit: 4a9f85e9f8
.NET Core SDKs installed:
3.1.201 [/usr/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
$ dotnet tool restore
$ pwd
/home/travis/build/LukeBurgessYeo/fsharp-tutorial
The command "pwd" exited with 0.
$ ls
config.fsx images _lib loaders README.md style
generators js LICENSE posts Script.fsx
The command "ls" exited with 0.
$ dotnet fornax build
Couldn't find or load config
The command "dotnet fornax build" exited with 1.
Notice that the working directory contains a config.fsx
.
Additional Thoughts
Fornax works as expected locally with the globally installed dotnet tool, as well as with the locally installed dotnet tool. It seems that on these CI servers, the directory which dotnet fornax build
is being run from is not the same as the directory which is being passed into the build process (i.e. this path from Directory.GetCurrentDirectory()
).
I ran into this same problem trying to build with GitHub actions, and after doing some research, I can see with strace
on the fornax command that the problem is that it doesn't find the _lib\fornax.dll. It seems a little strange to check in a binary, though. How is this supposed to work?
I confirmed this all works fine on CI servers if you commit the _lib directory and it's contents. Is there a better way to be able to restore those during CI rather than include these binaries in source control?
Came up with this trick to get the current version of the tool to create the _lib/
directory so those binaries are available on the CI server:
mkdir temporary && cd temporary && dotnet tool run fornax new && cp -r _lib ../ && cd - && rm -r temporary
Confusing error message, but after realizing it was the missing _lib
directory rather than config.fsx, the fix isn't too bad.