如何诊断 nix-build 失败?
目前我看到输出为:
nix build -v
warning: dumping very large path (> 256 MiB); this may run out of memory
building '/nix/store/fdrm6kbm68vld3bhfjizv684ck725lyf-blog.drv'...
builder for '/nix/store/fdrm6kbm68vld3bhfjizv684ck725lyf-blog.drv' failed with exit code 1; last 5 log lines:
unpacking sources
unpacking source archive /nix/store/s7r5vlvp49ad6a9d5hqhsiaxw691iyhf-Blog
source root is Blog
patching sources
configuring
[0 built (1 failed), 0.0 MiB DL]
error: build of '/nix/store/fdrm6kbm68vld3bhfjizv684ck725lyf-blog.drv' failed
Run Code Online (Sandbox Code Playgroud)
我希望找到一些日志/错误,说明为什么它无法构建?
我已经尝试添加build-cache-failures = true;
到,default.nix
但是我仍然看不到以下输出:
nix-store --read-log
Run Code Online (Sandbox Code Playgroud)
而nix-store --query-failed-paths
结果:
error: no operation specified
Try 'nix-store --help' for more information.
Run Code Online (Sandbox Code Playgroud)
也可以看看:
eval "${!curPhase:-$curPhase}"
cd "${sourceRoot:-.}"
runPhase $curPhase
调试包的构建过程:
代替nix-build
nix-build -E 'with import <nixpkgs> {}; callPackage ./. {}'
Run Code Online (Sandbox Code Playgroud)
运行nix-shell
进入构建环境
nix-shell -E 'with import <nixpkgs> {}; callPackage ./. {}'
Run Code Online (Sandbox Code Playgroud)
然后运行构建阶段
# run build in tempdir
cd $(mktemp -d)
# dont install to /nix/store
for n in $outputs; do eval export $n=$PWD/result-$n; done
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh
phases="${prePhases[*]:-} unpackPhase patchPhase ${preConfigurePhases[*]:-} \
configurePhase ${preBuildPhases[*]:-} buildPhase checkPhase \
${preInstallPhases[*]:-} installPhase ${preFixupPhases[*]:-} fixupPhase installCheckPhase \
${preDistPhases[*]:-} distPhase ${postPhases[*]:-}";
echo writing nix-build-phases.txt
for curPhase in $phases; do
echo "eval \"\${$curPhase:-$curPhase}\""
if [ "$curPhase" = unpackPhase ]; then
echo '[ -n "${sourceRoot:-}" ] && chmod +x "${sourceRoot}"'
echo 'cd "${sourceRoot:-.}"'
fi
done >nix-build-phases.txt
echo "please manually run the build phases in nix-build-phases.txt"
echo
cat nix-build-phases.txt
Run Code Online (Sandbox Code Playgroud)
示例 nix-build-phases.txt
eval "${unpackPhase:-unpackPhase}"
[ -n "${sourceRoot:-}" ] && chmod +x "${sourceRoot}"
cd "${sourceRoot:-.}"
eval "${patchPhase:-patchPhase}"
eval "${updateAutotoolsGnuConfigScriptsPhase:-updateAutotoolsGnuConfigScriptsPhase}"
eval "${configurePhase:-configurePhase}"
eval "${buildPhase:-buildPhase}"
eval "${checkPhase:-checkPhase}"
eval "${installPhase:-installPhase}"
eval "${fixupPhase:-fixupPhase}"
eval "${installCheckPhase:-installCheckPhase}"
eval "${distPhase:-distPhase}"
Run Code Online (Sandbox Code Playgroud)
在此构建环境中,您可以
buildPhase
:运行type buildPhase
打印旧阶段、复制旧阶段、修改阶段、粘贴新阶段注意:构建者可以执行不同的构建阶段。实际的构建阶段存储在变量中,例如prePhases
或preConfigurePhases
问题:构建脚本运行,set -e
因此它将在出现第一个错误时退出,但这会退出交互式 shell。这是 bash shell 的限制,因此理想情况下,我们将在 bash 调试器中运行构建脚本,在出现第一个错误时停止执行,修改命令,后退并重复执行命令,并允许检查状态。
eval "${unpackPhase:-unpackPhase}"
[ -n "${sourceRoot:-}" ] && chmod +x "${sourceRoot}"
cd "${sourceRoot:-.}"
eval "${patchPhase:-patchPhase}"
eval "${updateAutotoolsGnuConfigScriptsPhase:-updateAutotoolsGnuConfigScriptsPhase}"
eval "${configurePhase:-configurePhase}"
eval "${buildPhase:-buildPhase}"
eval "${checkPhase:-checkPhase}"
eval "${installPhase:-installPhase}"
eval "${fixupPhase:-fixupPhase}"
eval "${installCheckPhase:-installCheckPhase}"
eval "${distPhase:-distPhase}"
Run Code Online (Sandbox Code Playgroud)
阅读日志应该有效。你有具体说明推导过程吗? nix-store --read-log /nix/store/fdrm6kbm68vld3bhfjizv684ck725lyf-blog.drv
归档时间: |
|
查看次数: |
2660 次 |
最近记录: |