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

Most upvoted comments

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.toml looks pretty similar to what we do. I’d suggest to try the following:

  • Run the above configure target, and then run the configure target used for standard CMake projects.
  • After both configure targets are finished, try to set $CARGO_HOME to ${WRKDIR}/.cargo.
  • Run the build target suitable for standard CMake projects.

make sure that crate is built and the executable is in a place where the build process will find it

To clarify: the cxxbridge executable must be exactly the same version as specified in the lockfile.

One difference here is that corrosion / taskwarrior uses a cxxbridge commandline 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.

Update corrosion to support some kind of CXXBRIDGE_CMD_BIN env variable that can just point to the binary, avoiding all of the search and any issues about CARGO_HOME

Corrosion searches for cxxbridge in PATH, so I don’t think such an environment variable would help much. I think the CARGO_HOME thing is about when cxxbridge is not installed OR the version does not match the required version. In this case the cxxbridge-cmd binary needs to be built from source first. As I understand based on the previous discussion (I have not tested this myself) setting CARGO_HOME (or alternatively probably also an override for the crates.io registry) allows cargo install cxxbridge-cmd to use the local vendored sources for an offline build instead of fetching from crates.io.

Update Corrosion docs to be more clear about the requirements and how this search works

Improvements to the corrosion documentation regarding offline builds would definitely be useful.

Glad to report that after investigation the cxxbridge-cmd issue was easily fixed via simply setting CARGO_HOME to a correct value. Now continue to debug #3707 .

It’s worth filing a bug for even if you can’t work on it!