cachix / devenv

Fast, Declarative, Reproducible, and Composable Developer Environments
https://devenv.sh
Apache License 2.0
3.56k stars 259 forks source link

aws-sdk-cpp unit test fails when installing DevEnv in a container #302

Closed leviable closed 1 year ago

leviable commented 1 year ago

Describe the bug I am new to nix/devenv, and attempting to follow the getting started guide for using DevEnv in a container. The error happens for both the Newcomer and Advanced flow, but I will detail the Newcomer installation.

To Reproduce I am following the getting started guide, using an M1 Macbook as the docker host:

docker run -it nixos/nix
nix-env -iA cachix -f https://cachix.org/api/v1/install
cachix use devenv
nix-env -if https://github.com/cachix/devenv/tarball/v0.5

It attempts to install aws-sdk-cpp, but errors out when executing the post-build tests, consistently failing HttpClientTest.TestRandomURLMultiThreaded

[ RUN      ] HttpClientTest.TestRandomURLMultiThreaded
/tmp/nix-build-aws-sdk-cpp-1.9.294.drv-0/source/aws-cpp-sdk-core-tests/http/HttpClientTest.cpp:142: Failure
Value of: hasPendingTasks
  Actual: true
Expected: false
[  FAILED  ] HttpClientTest.TestRandomURLMultiThreaded (10053 ms)
[----------] Global test environment tear-down
[==========] 400 tests from 65 test suites ran. (18753 ms total)
[  PASSED  ] 399 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] HttpClientTest.TestRandomURLMultiThreaded

 1 FAILED TEST
make[2]: *** [aws-cpp-sdk-core-tests/CMakeFiles/aws-cpp-sdk-core-tests.dir/build.make:900: aws-cpp-sdk-core-tests/aws-cpp-sdk-core-tests] Error 1
make[2]: *** Deleting file 'aws-cpp-sdk-core-tests/aws-cpp-sdk-core-tests'
make[1]: *** [CMakeFiles/Makefile2:396: aws-cpp-sdk-core-tests/CMakeFiles/aws-cpp-sdk-core-tests.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
error: builder for '/nix/store/k8hfbg72iq0w20s4fljh42gkzhcknxia-aws-sdk-cpp-1.9.294.drv' failed with exit code 2
error: 1 dependencies of derivation '/nix/store/1sjrhygbyf2w7rjkxzr5df6kxwckq8v6-nix-2.12.0pre20221221_51b770e.drv' failed to build
error: 1 dependencies of derivation '/nix/store/42a32v8j91pgc3qp5wsa0y0z96ax55vh-devenv.drv' failed to build

I was able to locate the following workaround:

same issue on NixOS:
gcc: 10.3.0 (compiled)
cmake: 3.19.7 (compiled)
aws-cpp-sdk: 1.8.121

Not behind firewall

for nixos users, to work around in an overlay:
aws-sdk-cpp = super.aws-sdk-cpp.overrideAttrs(superAttrs: {
cmakeFlags = superAttrs.cmakeFlags or [] ++ [ "-DAUTORUN_UNIT_TESTS=OFF" ];
});

However adding the above to~/.config/nixpkgs/overlays/default.nix doesn't change the output.

I am fairly certain I am somehow at fault, but have so far been able to troubleshoot my way out of it. Any guidance would be greatly appreciated.

Version

Cannot install DevEnv to generate the output

domenkozar commented 1 year ago

Hey @leviable.

This is horrible experience getting started and it's not your fault at all. I'll try to fix it ASAP.

I'm curious, why are you installing devenv/nix inside docker and not on your machine?

leviable commented 1 year ago

Thank you for the reply :)

Right now my team uses as hodgepodge of docker, bash, and make to get local developer and CI environments setup, and I'm evaluating nix and devenv as a replacement for that. I had planned to use containers as a clean slate to simulate a new user installing everything for the first time.

domenkozar commented 1 year ago

@leviable could you paste the full log, since it should be downloading the binaries instead of compiling?

leviable commented 1 year ago

@domenkozar Sure thing, here is the output:

https://pastebin.com/Mfh77w7n

domenkozar commented 1 year ago

If I follow the same steps it works for me, maybe you need to pull the latest Nix image?

$ nix-env --version
nix-env (Nix) 2.13.0
leviable commented 1 year ago

Ahhh, great catch:

bash-5.1# nix-env --version
nix-env (Nix) 2.12.0

Let me get 2.13.0 loaded and see how that works

leviable commented 1 year ago

Hmmm, same story unfortunately:

$ docker pull nixos/nix:latest
$ docker run -it nixos/nix:latest
bash-5.1# nix --version
nix (Nix) 2.13.0

Same result: https://pastebin.com/FxgLiH7y

domenkozar commented 1 year ago

It seems that for some reason dns is not working inside the container correctly. Let me look into it.

leviable commented 1 year ago

For what it's worth, I use colima as my container runtime.

domenkozar commented 1 year ago

It seems that networking stack is broken there, because I can't reproduce the issue and in your logs it's clearly failing to resolve DNS entries.

domenkozar commented 1 year ago

I'd recommend trying devenv directly on your machine since a major benefit is to avoid containers for local development.

j-minster commented 1 year ago

I'm getting the same error, but obviously nothing to do with this project:

[ FAILED ] HttpClientTest.TestRandomURLMultiThreaded

1 FAILED TEST
make[2]: *** [aws-cpp-sdk-core-tests/CMakeFiles/aws-cpp-sdk-core-tests.dir/build.make:898: aws-cpp-sdk-core-tests/aws-cpp-sdk-core-tests] Error 1
make[2]: *** Deleting file 'aws-cpp-sdk-core-tests/aws-cpp-sdk-core-tests'
make[1]: *** [CMakeFiles/Makefile2:396: aws-cpp-sdk-core-tests/CMakeFiles/aws-cpp-sdk-core-tests.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
error: builder for '/nix/store/lix5cb1s8gigcc463rzr9z7xbby8b8c8-aws-sdk-cpp-1.9.294.drv' failed with exit code 2;
       last 10 log lines:
       > [==========] 400 tests from 65 test suites ran. (160598 ms total)
       > [  PASSED  ] 399 tests.
       > [  FAILED  ] 1 test, listed below:
       > [  FAILED  ] HttpClientTest.TestRandomURLMultiThreaded
       >
       >  1 FAILED TEST
       > make[2]: *** [aws-cpp-sdk-core-tests/CMakeFiles/aws-cpp-sdk-core-tests.dir/build.make:898: aws-cpp-sdk-core-tests/aws-cpp-sdk-core-tests] Error 1
       > make[2]: *** Deleting file 'aws-cpp-sdk-core-tests/aws-cpp-sdk-core-tests'
       > make[1]: *** [CMakeFiles/Makefile2:396: aws-cpp-sdk-core-tests/CMakeFiles/aws-cpp-sdk-core-tests.dir/all] Error 2
       > make: *** [Makefile:136: all] Error 2
       For full logs, run 'nix log /nix/store/lix5cb1s8gigcc463rzr9z7xbby8b8c8-aws-sdk-cpp-1.9.294.drv'.
error: 1 dependencies of derivation '/nix/store/9jxh4y4lh3dm985shkhqij4zgjhkzjsh-nix-2.12.0.drv' failed to build

when trying to do: nix-env -iA nixpkgs.nixFlakes

I'm on an M1 Mac as well.

domenkozar commented 1 year ago

I've merged https://github.com/NixOS/nixpkgs/pull/211412, so this should hit the unstable channels in a few hours.

leviable commented 1 year ago

Thanks for this domenkozar, I really appreciate it