NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.73k stars 1.52k forks source link

nix from git tries to write to system root at build time: cannot open output file /usr/lib/libnixutil.so: Permission denied #5184

Open trofi opened 3 years ago

trofi commented 3 years ago

When building on a non-nixos for system-wide installation build system fails to write to /usr:

$ cd /tmp
$ git clone https://github.com/NixOS/nix.git
$ cd nix
$ ./bootstrap.sh
$ ./configure --prefix=/usr ac_cv_header_aws_s3_S3Client_h=no
$ make
...
$ LANG=C make
  LD     /usr/lib/libnixutil.so
/usr/lib/gcc/x86_64-pc-linux-gnu/12.0.0/../../../../x86_64-pc-linux-gnu/bin/ld: cannot open output file /usr/lib/libnixutil.so: Permission denied
collect2: error: ld returned 1 exit status
make: *** [mk/lib.mk:117: /usr/lib/libnixutil.so] Error 1

I think that is not expected.

trofi commented 3 years ago

I think it comes from doc/manual/nix.json target:

$ make -r -d doc/manual/nix.json
...
Considering target file 'doc/manual/nix.json'.
 File 'doc/manual/nix.json' does not exist.
  Considering target file '/usr/bin/nix'.
    Considering target file 'src/build-remote/build-remote.o'.
     Looking for an implicit rule for 'src/build-remote/build-remote.o'.
...

I guess the intent was to use local nix binary instead of already installed (and outdated) one. Seemingly problematic rule:

doc/manual/local.mk:$(d)/nix.json: $(bindir)/nix
grawlinson commented 3 years ago

Just run into this issue using the 2.4 tarball from GitHub.

Here's build output from make on Arch Linux:

config.status: creating config.h
  GEN    Makefile.config
  GEN    src/libexpr/parser-tab.cc
  GEN    src/libexpr/parser-tab.hh
  GEN    src/libexpr/lexer-tab.cc
  GEN    src/libexpr/lexer-tab.hh
  GEN    src/nix/get-env.sh.gen.hh
src/libexpr/lexer.l:295: warning, -s option given but default rule can be matched
src/libexpr/lexer.l:295: warning, -s option given but default rule can be matched
  GEN    src/nix-env/buildenv.nix.gen.hh
  GEN    doc/manual/generate-manpage.nix.gen.hh
  GEN    src/nix-channel/unpack-channel.nix.gen.hh
  GEN    doc/manual/utils.nix.gen.hh
  GEN    src/libexpr/flake/call-flake.nix.gen.hh
  GEN    src/libexpr/imported-drv-to-derivation.nix.gen.hh
  GEN    src/libexpr/fetchurl.nix.gen.hh
  CXX    src/libutil/affinity.o
  CXX    src/libutil/archive.o
  GEN    src/libexpr/primops/derivation.nix.gen.hh
  CXX    src/libutil/args.o
  CXX    src/libutil/compression.o
  CXX    src/libutil/compute-levels.o
  CXX    src/libutil/hash.o
  CXX    src/libutil/config.o
  CXX    src/libutil/error.o
  CXX    src/libutil/rust-ffi.o
  CXX    src/libutil/json.o
  CXX    src/libutil/serialise.o
  CXX    src/libutil/logging.o
  CXX    src/libutil/thread-pool.o
  CXX    src/libutil/tarfile.o
  CXX    src/libutil/url.o
  CXX    src/libutil/util.o
  CXX    src/libutil/xml-writer.o
  CXX    src/libstore/binary-cache-store.o
  CXX    src/libstore/build/derivation-goal.o
  CXX    src/libstore/build/drv-output-substitution-goal.o
  CXX    src/libstore/build/entry-points.o
  CXX    src/libstore/build/goal.o
  CXX    src/libstore/build/hook-instance.o
  CXX    src/libstore/build/local-derivation-goal.o
  CXX    src/libstore/build/substitution-goal.o
  CXX    src/libstore/build/worker.o
  CXX    src/libstore/builtins/buildenv.o
  CXX    src/libstore/builtins/fetchurl.o
  CXX    src/libstore/builtins/unpack-channel.o
  CXX    src/libstore/content-address.o
  CXX    src/libstore/crypto.o
  CXX    src/libstore/daemon.o
  CXX    src/libstore/derivations.o
  CXX    src/libstore/dummy-store.o
  CXX    src/libstore/derived-path.o
  CXX    src/libstore/filetransfer.o
  CXX    src/libstore/gc.o
  CXX    src/libstore/globals.o
  CXX    src/libstore/export-import.o
  CXX    src/libstore/http-binary-cache-store.o
  CXX    src/libstore/legacy-ssh-store.o
  CXX    src/libstore/local-binary-cache-store.o
  CXX    src/libstore/local-fs-store.o
  GEN    src/libstore/schema.sql.gen.hh
  GEN    src/libstore/ca-specific-schema.sql.gen.hh
  CXX    src/libstore/lock.o
  CXX    src/libstore/machines.o
  CXX    src/libstore/misc.o
  CXX    src/libstore/names.o
  CXX    src/libstore/nar-accessor.o
  CXX    src/libstore/nar-info-disk-cache.o
  CXX    src/libstore/nar-info.o
  CXX    src/libstore/optimise-store.o
  CXX    src/libstore/parsed-derivations.o
  CXX    src/libstore/path-info.o
  CXX    src/libstore/path-with-outputs.o
  CXX    src/libstore/path.o
  CXX    src/libstore/pathlocks.o
  CXX    src/libstore/profiles.o
  CXX    src/libstore/realisation.o
  CXX    src/libstore/references.o
  CXX    src/libstore/remote-fs-accessor.o
  CXX    src/libstore/remote-store.o
  CXX    src/libstore/s3-binary-cache-store.o
  CXX    src/libstore/sqlite.o
  CXX    src/libstore/ssh-store.o
  CXX    src/libstore/ssh.o
  CXX    src/libstore/store-api.o
  CXX    src/libstore/uds-remote-store.o
  CXX    src/libfetchers/attrs.o
  CXX    src/libfetchers/cache.o
  CXX    src/libfetchers/fetchers.o
  CXX    src/libfetchers/git.o
  CXX    src/libfetchers/github.o
  CXX    src/libfetchers/indirect.o
  CXX    src/libfetchers/mercurial.o
  CXX    src/libfetchers/path.o
  CXX    src/libfetchers/registry.o
  CXX    src/libfetchers/tarball.o
  CXX    src/libmain/common-args.o
  CXX    src/libmain/loggers.o
  CXX    src/libmain/progress-bar.o
  CXX    src/libmain/shared.o
  CXX    src/libmain/stack.o
  CXX    src/libcmd/command.o
  CXX    src/libcmd/installables.o
  CXX    src/libcmd/legacy.o
  CXX    src/libcmd/markdown.o
  CXX    src/libutil/tests/closure.o
  CXX    src/libutil/tests/compression.o
  CXX    src/libutil/tests/config.o
  CXX    src/libutil/tests/hash.o
  CXX    src/libutil/tests/json.o
  CXX    src/libutil/tests/logging.o
  CXX    src/libutil/tests/lru-cache.o
  CXX    src/libutil/tests/pool.o
  CXX    src/libutil/tests/tests.o
  CXX    src/libutil/tests/url.o
  CXX    src/libutil/tests/xml-writer.o
  LD     src/libutil/libnixutil.so
  CXX    src/libstore/tests/references.o
  GEN    scripts/nix-http-export.cgi
  GEN    scripts/nix-profile.sh
  GEN    scripts/nix-reduce-build
  GEN    doc/manual/nix-env.1
  GEN    doc/manual/nix-build.1
  GEN    doc/manual/nix-shell.1
  GEN    doc/manual/nix-store.1
  GEN    doc/manual/nix-instantiate.1
  GEN    doc/manual/nix-collect-garbage.1
  GEN    doc/manual/nix-channel.1
  GEN    doc/manual/nix-prefetch-url.1
  GEN    doc/manual/nix-hash.1
  GEN    doc/manual/nix-copy-closure.1
  GEN    doc/manual/nix-daemon.8
  CXX    src/build-remote/build-remote.o
  CXX    src/nix-build/nix-build.o
  CXX    src/nix-channel/nix-channel.o
  CXX    src/nix-collect-garbage/nix-collect-garbage.o
  CXX    src/nix-copy-closure/nix-copy-closure.o
  CXX    src/nix-env/nix-env.o
  CXX    src/nix-env/user-env.o
  CXX    src/nix-instantiate/nix-instantiate.o
  CXX    src/nix-store/dotgraph.o
  CXX    src/nix-store/graphml.o
  CXX    src/nix-store/nix-store.o
  CXX    src/nix/add-to-store.o
  CXX    src/nix/app.o
  CXX    src/nix/build.o
  CXX    src/nix/bundle.o
  CXX    src/nix/cat.o
  CXX    src/nix/copy.o
  CXX    src/nix/daemon.o
  CXX    src/nix/describe-stores.o
  CXX    src/nix/develop.o
  CXX    src/nix/diff-closures.o
  CXX    src/nix/doctor.o
  CXX    src/nix/dump-path.o
  CXX    src/nix/edit.o
  CXX    src/nix/eval.o
  CXX    src/nix/flake.o
  CXX    src/nix/hash.o
  CXX    src/nix/log.o
  CXX    src/nix/ls.o
  CXX    src/nix/main.o
  CXX    src/nix/make-content-addressable.o
  CXX    src/nix/nar.o
  CXX    src/nix/optimise-store.o
  CXX    src/nix/path-info.o
  CXX    src/nix/ping-store.o
  CXX    src/nix/prefetch.o
  CXX    src/nix/profile.o
  CXX    src/nix/realisation.o
  CXX    src/nix/registry.o
  CXX    src/nix/repl.o
  CXX    src/nix/run.o
  CXX    src/nix/search.o
  CXX    src/nix/show-config.o
  CXX    src/nix/show-derivation.o
  CXX    src/nix/sigs.o
  CXX    src/nix/store-delete.o
  CXX    src/nix/store-gc.o
  CXX    src/nix/store-repair.o
  CXX    src/nix/store.o
  CXX    src/nix/upgrade-nix.o
  CXX    src/nix/verify.o
  CXX    src/nix/why-depends.o
  CXX    src/libexpr/attr-path.o
  CXX    src/libexpr/attr-set.o
  CXX    src/libexpr/common-eval-args.o
  CXX    src/libexpr/eval-cache.o
  CXX    src/libexpr/eval.o
  CXX    src/libexpr/flake/config.o
  CXX    src/libexpr/flake/flake.o
  CXX    src/libexpr/flake/flakeref.o
  CXX    src/libexpr/flake/lockfile.o
  CXX    src/libexpr/function-trace.o
  CXX    src/libexpr/get-drvs.o
  CXX    src/libexpr/json-to-value.o
  CXX    src/libexpr/lexer-tab.o
  CXX    src/libexpr/nixexpr.o
  CXX    src/libexpr/parser-tab.o
  CXX    src/libexpr/primops.o
  CXX    src/libexpr/primops/context.o
  CXX    src/libexpr/primops/fetchMercurial.o
  CXX    src/libexpr/primops/fetchTree.o
  CXX    src/libexpr/primops/fromTOML.o
  CXX    src/libexpr/value-to-json.o
  CXX    src/libexpr/value-to-xml.o
  LD     /usr/lib/libnixutil.so
/usr/bin/ld: cannot open output file /usr/lib/libnixutil.so: Permission denied
collect2: error: ld returned 1 exit status
make: *** [mk/lib.mk:117: /usr/lib/libnixutil.so] Error 1
make: *** Waiting for unfinished jobs....
stale[bot] commented 2 years ago

I marked this as stale due to inactivity. → More info