dub
dub copied to clipboard
Misleading error message when Curl not found.
System information
- dub version: 1.33.1
- OS Platform and distribution: Nixos 23.11
- compiler version ldc-1.34.0
Bug Description
$ dub build -v
Using dub registry url 'https://code.dlang.org/'
Note: Failed to determine version of package fps-godot-modules at .. Assuming ~master.
Version selection for dependency godot-dlang (godot-dlang) of fps-godot-modules is missing.
Missing dependency godot-dlang ~>0.6.0 of fps-godot-modules
Checking for missing dependencies.
Search for versions of godot-dlang (1 package suppliers)
Scanning local packages...
Warning Package godot-dlang not found in registry at https://code.dlang.org/ (fallbacks registry at https://codemirror.dlang.org/, registry at https://dub.bytecraft.nl/, registry at https://code-mirror.dlang.io/): Failed to download https://code.dlang.org/api/packages/infos?packages=%5B%22godot-dlang%22%5D&include_dependencies=true&minimize=true
Nothing found for godot-dlang
Error Failed to find any versions for package godot-dlang, referenced by fps-godot-modules ~master
An error message like this leads me to think I would have connection problems, code.dlang.org would be down, or the package would be missing. None of those was the case. Instead, Strace revealed the problem:
# Lots of openats like those below...
openat(AT_FDCWD, "/nix/store/sdhmm56jv7r449hf7f57cl3pvnsy3cbg-xgcc-12.3.0-libgcc/lib/libcurl-gnutls.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/1q6qwq8csbhyy0pv54sab00jxlmb3rw2-gcc-12.3.0-libgcc/lib/libcurl-nss.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/gqghjch4p1s69sv4mcjksb2kb65rwqjy-glibc-2.38-23/lib/libcurl-nss.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/sdhmm56jv7r449hf7f57cl3pvnsy3cbg-xgcc-12.3.0-libgcc/lib/libcurl-nss.so.4", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/1q6qwq8csbhyy0pv54sab00jxlmb3rw2-gcc-12.3.0-libgcc/lib/libcurl.so.3", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/gqghjch4p1s69sv4mcjksb2kb65rwqjy-glibc-2.38-23/lib/libcurl.so.3", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/nix/store/sdhmm56jv7r449hf7f57cl3pvnsy3cbg-xgcc-12.3.0-libgcc/lib/libcurl.so.3", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
write(2, "\33[1;33;49m Warning\33[0m Packa"..., 367 Warning Package godot-dlang not found in registry at https://code.dlang.org/ (fallbacks registry at https://codemirror.dlang.org/, registry at https://dub.bytecraft.nl/, registry at https://code-mirror.dlang.io/): Failed to download https://code.dlang.org/api/packages/infos?packages=%5B%22godot-dlang%22%5D&include_dependencies=true&minimize=true
) = 367
# ...
The real problem here is with the library search paths, as they obviously aren't patched to include curl, meaning something with the Nix derivation used to install it is wrong.
Dub didn't help diagnosing the problem, though. If it can't find curl, I'd expect it to report that in the error message instead of "download failed", or even worse "package not found in registry".
How to reproduce?
Hide the Curl library from DUB and try to build something that local caches aren't enough for.
So this lazy initialization is done by Phobos. If it can't find Curl, it throws an Exception.
Which we end up catching: https://github.com/dlang/dub/blob/a91307124eaa87d0fbdf47a5766c21ad00dfc4f3/source/dub/dub.d#L1804-L1807
I assume dub --verbose would help here, but we should probably handle this better.