ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
33.51k stars 2.45k forks source link

zig reports error: AccessDenied when compiling from source on netbsd #20612

Open nikkicoon opened 1 month ago

nikkicoon commented 1 month ago

Zig Version

0.13.0

Steps to Reproduce and Observed Behavior

I think I reported this before... zig fails to install since at least 0.12.0. This is 0.13.0, on NetBSD, but should be reproducible on any other OS through pkgsrc:

=> Bootstrap dependency digest>=20211023: found digest-20220214
===> Skipping vulnerability checks.
WARNING: No /usr/pkg/pkgdb/pkg-vulnerabilities file found.
WARNING: To fix run: `/usr/sbin/pkg_admin -K /usr/pkg/pkgdb fetch-pkg-vulnerabilities'.
===> Installing for zig-0.13.0
=> Generating pre-install file lists
[ 36%] Built target zigcpp
[ 47%] Built target zig-wasm2c
[ 68%] Built target zig1
[ 94%] Built target zig2
[100%] Built target stage3
Install the project...
-- Install configuration: "Release"
error: AccessDenied
::
:: ERROR: 1
:: (execute_process)
::
:: argv: /tmp/work/zig-0.13.0/cmake-pkgsrc-build/zig2 build --prefix /usr/pkg --zig-lib-dir /tmp/work/zig-0.13.0/lib -Dversion-string=0.13.0 -Dtarget=native -Dcpu=baseline -Denable-llvm -Dconfig_h=/tmp/work/zig-0.13.0/cmake-pkgsrc-build/config.h -Dno-langref -Dstd-docs=false -Doptimize=ReleaseFast -Dstrip
::
:: argv[0]: /tmp/work/zig-0.13.0/cmake-pkgsrc-build/zig2
:: argv[1]: build
:: argv[2]: --prefix
:: argv[3]: /usr/pkg
:: argv[4]: --zig-lib-dir
:: argv[5]: /tmp/work/zig-0.13.0/lib
:: argv[6]: -Dversion-string=0.13.0
:: argv[7]: -Dtarget=native
:: argv[8]: -Dcpu=baseline
:: argv[9]: -Denable-llvm
:: argv[10]: -Dconfig_h=/tmp/work/zig-0.13.0/cmake-pkgsrc-build/config.h
:: argv[11]: -Dno-langref
:: argv[12]: -Dstd-docs=false
:: argv[13]: -Doptimize=ReleaseFast
:: argv[14]: -Dstrip
::
CMake Error at /tmp/work/zig-0.13.0/cmake/install.cmake:26 (message):
Call Stack (most recent call first):
  cmake_install.cmake:57 (include)

*** Error code 1

Stop.
make[2]: stopped in /tmp/work/zig-0.13.0/cmake-pkgsrc-build
*** Error code 1

Stop.
make[1]: stopped in /usr/pkgsrc/lang/zig
*** Error code 1

Stop.
make: stopped in /usr/pkgsrc/lang/zig

Expected Behavior

zig installs.

zhylmzr commented 1 month ago

It looks like you are compiling zig from source. Have you tried changing the global cache directory? https://github.com/ziglang/zig/issues/19400#issuecomment-2016282007

nikkicoon commented 1 month ago

I should mention this is for pkgsrc, a package manager.

the global cache directory is changed from any default to control files: http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/lang/zig/Makefile?rev=1.41&content-type=text/x-cvsweb-markup

MAKE_ENV+= ZIG_GLOBAL_CACHE_DIR=${WRKDIR}/zig-global-cache MAKE_ENV+= ZIG_LOCAL_CACHE_DIR=${WRKDIR}/zig-local-cache

where WRKDIR is the directory pkgsrc builds in

"expected to be found in $HOME by default" I understand this as you can change it, as seen in other package managers unless that changed in recent versions.

This happens when you run it inside the pbulk chroot. It does not happen (ie it installs successfully) when you run it as a user outside of the chroot.

nikkicoon commented 1 month ago

Or are you telling me that stage3 is special, it ignores any previous cache files from stage1 and stage2 if any exist, and when $HOME does not exist, it just fails to complete stage3 install? Your own CI scripts do the same.

andrewrk commented 1 month ago

I think a good first step here would be obtaining an error return trace, and using that to improve the error reporting instead of just printing "access denied" with no other information.

nikkicoon commented 1 month ago

do you need more verbose cmake output then?

nikkicoon commented 1 month ago

I should mention this is for pkgsrc, a package manager.

the global cache directory is changed from any default to control files: http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/lang/zig/Makefile?rev=1.41&content-type=text/x-cvsweb-markup

MAKE_ENV+= ZIG_GLOBAL_CACHE_DIR=${WRKDIR}/zig-global-cache MAKE_ENV+= ZIG_LOCAL_CACHE_DIR=${WRKDIR}/zig-local-cache

where WRKDIR is the directory pkgsrc builds in

"expected to be found in $HOME by default" I understand this as you can change it, as seen in other package managers unless that changed in recent versions.

This happens when you run it inside the pbulk chroot. It does not happen (ie it installs successfully) when you run it as a user outside of the chroot.

Worth mentioning: this happens regardless of ZIG_(GLOBAL,LOCAL)_CACHE_DIR being set to a different location or not, I just verified this.