Skip to content

installers: busybox cp in Alpine fails due to unsupported --preserve flags #13480

@736-c41-2c1-e464fc974

Description

@736-c41-2c1-e464fc974

Platform

  • Linux: Alpine 3.22 (BusyBox v1.37.0)

Additional information

Runs inside an Alpine 3.22 Docker container. Uses BusyBox cp, which doesn’t support --preserve=ownership,timestamps and fails during Nix multi-user install.

Output

Output
...
8.271 ---- sudo execution ------------------------------------------------------------
8.271 I am executing:
8.272 
8.272     $ sudo cp -RP --preserve=ownership,timestamps ./store/01y8ib2djdafbvb700lznikipq2dpm45-nix-2.30.1 ./store/0369qr470fzidifvg53082zy6n37zj2s-s2n-tls-1.5.12 ./store/056kf3y6n9q5i7gdiynwdj6wrmb7b4kx-curl-8.12.1 ./store/0x600292yi5qzg389nan9j4dvzlh8785-gcc-14.2.1.20250322-libgcc ./store/132yjkbgnirm9riwd1cwvvgr33a6sphf-zstd-1.5.7 ./store/1i5cz1bqy7g9kaq6dkaqchn857b2h8cs-libssh2-1.11.1 ./store/25mgr0zphrz92ccs5dzwpki2i4dylx0z-aws-crt-cpp-0.29.4 ./store/2g1l5rwbpvgdz7ykx9ryfajamnhbcgw5-aws-c-io-0.15.3 ./store/2risglirc1di21134b0pyaxcn1z76xqd-aws-c-auth-0.8.1 ./store/2wmmwdbxp6myhdbrqsan7nbpsfazszvl-nss-cacert-3.108 ./store/38jbvjqj4qwp1lpdhki4brvxqxlyc4f1-aws-c-http-0.9.2 ./store/3dxf3h6dfkji265h3yfwsp4rcl2zkf0c-aws-c-sdkutils-0.2.1 ./store/45m0syxl368gqmnhxxpqpnpng9yvpf84-boehm-gc-8.2.8 ./store/49dxdr3ln7xfna1b94vi5hra6rgqk6h1-attr-2.5.2 ./store/4cyin7qmw12xmd25xlq9fp4sgc7mn3mc-boost-1.87.0 ./store/63lan55wm3n1h5r9rn7gbihpzfsnkmi1-libarchive-3.7.8-lib ./store/8birdx7fkbs0zdg378mmq8phwk85id4r-krb5-1.21.3-lib ./store/8dr41ckl7sbv2v5aim3csxzql03z68hk-zlib-1.3.1 ./store/8ms1zkkidmvnghnvdx07yjzj8cvi4dzm-llhttp-9.2.1 ./store/92nka5n8v45kj803v28h55zmgabg8r55-nix-store-2.30.1 ./store/92qr85qfacrjxkyp21y42yw1w4hxyx2v-aws-c-event-stream-0.5.0 ./store/9jjs7crz7mlw3k97gy696qh85bfizkdx-nix-main-2.30.1 ./store/acia13s3psa6hyl0n3an25syz55qwwjp-libsodium-1.0.20 ./store/arv0cbngl4sa4w349166bq1x6dh6b7jy-nghttp2-1.65.0-lib ./store/bj4jsc89w5gl4c63cs823ydj3fksjw89-tbb-2021.11.0-dev ./store/br3j52aw0njxi03s9ppmxcil3bw929g6-aws-sdk-cpp-1.11.448 ./store/chg330wi4p9g0r9bab2186wwhbgmlm5z-pcre2-10.44 ./store/cjs7mgw6q8zp75qapfmqhqnbf62b3fwa-libgit2-1.9.0-lib ./store/czg92d6mb88mp89vnmbf2ddnm8m0pbly-editline-1.17.1 ./store/ddnrpqdpfm1nsrfji3hr4aqmd93y6xkv-brotli-1.1.0-lib ./store/fdsndp18qa1fk375vcd4vrn00c0p4zpr-xgcc-14.2.1.20250322-libgcc ./store/g3s0z9r7m1lsfxdk8bj88nw8k8q3dmmg-glibc-2.40-66 ./store/g5cplv55bx1ajr9cai1arjfl8gpml311-libblake3-1.8.2 ./store/g84kpx8gpvmbj88r8jchz15vgw7w1fgq-nix-cmd-2.30.1 ./store/gk2b0g62xkrvzm47hlfzl919063m2z69-lowdown-1.3.2-lib ./store/gqss03q9pvhg560rwiinrwmvkaj64qls-aws-c-common-0.10.3 ./store/gv7z0km39q3fgzavpic8vrl7smh5n2w6-gcc-14.2.1.20250322-lib ./store/hzfjla4v6x1851jh0wakajlqif0jxrgy-xz-5.8.1 ./store/id64gslv6xwm2ylsb6s1zmjq3d5cc1n6-libxml2-2.13.8 ./store/k524klxgb2zyqf1kcq1xm68gxnjw70jy-aws-c-cal-0.8.0 ./store/kfqq6m8i6wm82g52dbbvpdgkx6xgnx73-aws-c-s3-0.7.1 ./store/l76031qldfvf2cr8xvpyp0652w0inp3r-libcpuid-0.7.1 ./store/mjsdsjml26kk2zhwjnfp20vvs43ackdh-aws-c-compression-0.3.0 ./store/mk2ddhh8z5fkx9wpm36mibrxqsmkd723-publicsuffix-list-0-unstable-2025-03-12 ./store/mq1680dppidpggmaqaklwapvgm6iw3a6-bzip2-1.0.8 ./store/n57pk92cs22w8q47rnfy72kppc8m6f4a-libseccomp-2.6.0-lib ./store/n8kngjvvbs2pa9ls6shm92crz2lkq8qs-keyutils-1.6.3-lib ./store/nff52xidq9f2qf93x5r5sr8zc8iwwa5j-sqlite-3.48.0 ./store/np1bpjysbx7269m0qm5zfjhk4zci2iwg-aws-checksums-0.2.2 ./store/ppc918vidrg62y17xgb6gbd4bxcn15zp-nix-flake-2.30.1 ./store/qjvmk7hav4j7x7z0sj3kvncm1mrdjnkj-aws-c-mqtt-0.11.0 ./store/qvvhrji1hzavdarn0mn53437jkp64whx-nix-expr-2.30.1 ./store/s8sxvzb0x6nm8m4ck6f61r2za1240zy1-nix-fetchers-2.30.1 ./store/sb4iq5n1w57qfn12svpms4xfxdhsyp9r-nix-util-2.30.1 ./store/vzdd455zm255kx85hg1cvci3bbn8adwj-libunistring-1.3 ./store/wph1pwdzril0vfazpa58f6m9shwv9233-busybox-1.36.1 ./store/xg75pc4yyfd5n2fimhb98ps910q5lm5n-bash-5.2p37 ./store/xy8x4g472i5n1bh24c5ixhbnk6qlm9vz-openssl-3.4.1 ./store/y0ii7yfaxi2k2vnfyknb64rcczsdyjkf-libidn2-2.3.8 ./store/y3qvisadf9w5wrdpa8v2vdx5ypa8v8d2-tbb-2021.11.0 ./store/yi6n5l389cg5nh4vy2hdzffhkvinr9l7-libpsl-0.21.5 ./store/z8fzi165wkivbikld909bl5zk6r29vsx-acl-2.3.2 /nix/store/
8.273 
8.273 to copy the basic Nix files to the new store at /nix/store
8.273 
8.278 cp: unrecognized option: preserve=ownership,timestamps
8.295 BusyBox v1.37.0 (2025-05-26 20:04:45 UTC) multi-call binary.
8.295 
8.295 Usage: cp [-arPLHpfinlsTu] SOURCE DEST
8.295 or: cp [-arPLHpfinlsu] SOURCE... { -t DIRECTORY | DIRECTORY }
8.295 
8.295 Copy SOURCEs to DEST
8.295 
8.295 	-a	Same as -dpR
8.295 	-R,-r	Recurse
8.295 	-d,-P	Preserve symlinks (default if -R)
8.295 	-L	Follow all symlinks
8.295 	-H	Follow symlinks on command line
8.295 	-p	Preserve file attributes if possible
8.295 	-f	Overwrite
8.295 	-i	Prompt before overwrite
8.295 	-n	Don't overwrite
8.295 	-l,-s	Create (sym)links
8.295 	-T	Refuse to copy if DEST is a directory
8.295 	-t DIR	Copy all SOURCEs into DIR
8.295 	-u	Copy only newer files
8.306 
8.306 ---- oh no! --------------------------------------------------------------------
8.306 Oh no, something went wrong. If you can take all the output and open
8.309 an issue, we'd love to fix the problem so nobody else has this issue.
8.309 
8.309 :(
8.310 
8.313 We'd love to help if you need it.
8.313 
8.313 You can open an issue at
8.313 https://github.com/NixOS/nix/issues/new?labels=installer&template=installer.md
8.313 
8.313 Or get in touch with the community: https://nixos.org/community
8.313 
------
...

Checklist

  • checked [latest Nix manual] ([source])
  • checked [open installer issues and pull requests] for possible duplicates

Description

A recent commit (87299e4, July 7 2025) removed -p in favor of --preserve=ownership,timestamps on non-Darwin platforms. This fails on Alpine’s BusyBox cp, which only supports the short -p flag to preserve mode, ownership and timestamps.

Impact

The Nix installer breaks in Alpine (and other BusyBox-based environments), preventing installation in Docker or embedded contexts where GNU cp isn’t available.


Minimal reproducible example

FROM alpine:3.22

ARG BASH_VERSION="5.2.37-r0"
RUN apk add --no-cache bash=${BASH_VERSION}
SHELL ["/bin/bash", "--login", "-c"]

ARG SUDO_VERSION="1.9.17_p1-r0"
RUN apk add --no-cache sudo=${SUDO_VERSION}

ARG SHADOW_VERSION="4.17.3-r0"
RUN apk add --no-cache shadow=${SHADOW_VERSION}

ARG CURL_VERSION="8.14.1-r1"
ARG XZ_VERSION="5.8.1-r0"
RUN apk add --no-cache curl=${CURL_VERSION} xz=${XZ_VERSION}

RUN sh <(curl -L https://nixos.org/nix/install) --daemon

Build with:

docker build -t nix-alpine .

It fails in the cp step copying Nix store contents.


Suggested fix

Detect BusyBox or lack of GNU cp --preserve support and fall back to:

cp -Rp ./store/* "$NIX_ROOT/store/"

The shorthand -p is equivalent to --preserve=mode,ownership,timestamps and is supported by BusyBox .


Please consider this change to ensure compatibility with BusyBox environments. Thanks for reviewing!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions