taskwarrior: cxxbridge related build errors when building offline (Nix)
Hello,
On NixOS, when we build packages, we disallow the usage of the internet. Since dependencies of Rust packages such as this and of course the source code itself of packages must be fetched from the internet, we have a mechanism to download in advance all sources required, and use a hash computed from the contents of the fetched sources, to verify these don’t change.
So for example the rust dependencies of this package, are all downloaded to a cargo cache, and get a hash. Then this cache is used when we build Taskwarrior (offline, just like any other package).
Weirdly, we get this issue when using the above mechanism (which works well for an uncountable number of packages):
error: download of config.json failed
Caused by:
failed to download from `https://index.crates.io/config.json`
Caused by:
[6] Could not resolve hostname (Could not resolve host: index.crates.io)
make[2]: *** [src/taskchampion-cpp/CMakeFiles/cxxbridge_v1.0.128.dir/build.make:74: corrosion/cxxbridge_v1.0.128/bin/cxxbridge] Error 101
make[1]: *** [CMakeFiles/Makefile2:617: src/taskchampion-cpp/CMakeFiles/cxxbridge_v1.0.128.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Do you have an idea what exactly that CMake file is trying to download? We should be able to fix our build if CMake will be able to detect that nothing should be downloaded, as the files are already there - because we’ll put them there ourselves.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 42 (24 by maintainers)
Commits related to this issue
- taskwarrior3: 3.1.0 -> 3.2.0-unstable-2024-12-17 Updated to this unstable version due to: https://github.com/GothenburgBitFactory/taskwarrior/issues/3705 Diff: https://github.com/GothenburgBitFacto... — committed to doronbehar/nixpkgs by doronbehar 2 years ago
- Add offline build notes to INSTALL (#3705) (#3740) Document additional steps that have been successful for NixOS and Ravenports. — committed to GothenburgBitFactory/taskwarrior by jrmarino 2 years ago
My opinion is adding a new section of the INSTALL file to cover this topic would be sufficient. Maybe I’ll take a crack at it (in the form of a PR) later today.
OK so yes your technique with the
.cargo/config.tomllooks pretty similar to what we do. I’d suggest to try the following:$CARGO_HOMEto${WRKDIR}/.cargo.To clarify: the
cxxbridgeexecutable must be exactly the same version as specified in the lockfile.One difference here is that corrosion / taskwarrior uses a
cxxbridgecommandline tool, which needs to be either installed beforehand or built from source during the build. In the broader ecosystem that does not use CMake, cxxbridge is often used as a library from build scripts. This is mainly necessary, since corrosion / CMake wants to know which (header) files get generated, which would be difficult if they are just byproducts from an opaque build script.Corrosion searches for
cxxbridgeinPATH, so I don’t think such an environment variable would help much. I think theCARGO_HOMEthing is about whencxxbridgeis not installed OR the version does not match the required version. In this case thecxxbridge-cmdbinary needs to be built from source first. As I understand based on the previous discussion (I have not tested this myself) settingCARGO_HOME(or alternatively probably also an override for the crates.io registry) allowscargo install cxxbridge-cmdto use the local vendored sources for an offline build instead of fetching from crates.io.Improvements to the corrosion documentation regarding offline builds would definitely be useful.
Glad to report that after investigation the
cxxbridge-cmdissue was easily fixed via simply settingCARGO_HOMEto a correct value. Now continue to debug #3707 .It’s worth filing a bug for even if you can’t work on it!