Skip to content

Permission denied: failed to create directory /target/debug #1698

@pjpawel

Description

@pjpawel

Checklist

Describe your issue

I attempted to build for aarch64 architecture, but permission denied happened.
I think /target is ./target, because:

  • After cargo clean: error to create dir
  • with existing previous build failed to open cargo.lock

Changing permission for one file causes to permission denied for another file.
I used docker on root and rootless.

What target(s) are you cross-compiling for?

aarch64-unknown-linux-gnu

Which operating system is the host (e.g computer cross is on) running?

  • macOS
  • Windows
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • docker
  • podman
  • other container engine (specify in description)

cross version

cross 0.2.5

Example

``cross build --target aarch64-unknown-linux-gnu -vvv`

+ cargo metadata --format-version 1 --filter-platform aarch64-unknown-linux-gnu
+ rustc --print sysroot
+ rustup toolchain list
+ rustup --verbose toolchain add stable-x86_64-unknown-linux-gnu --profile minimal
debug: read metadata version: '12'
debug: updating existing install for 'stable-x86_64-unknown-linux-gnu'
debug: toolchain directory: '/home/pp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu'
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
debug: creating temp file: /home/pp/.rustup/tmp/blnc4hofk3q1bbr__file
debug: downloading file from: 'https://static.rust-lang.org/dist/channel-rust-stable.toml.sha256'
debug: downloading with reqwest
debug: deleted temp file: /home/pp/.rustup/tmp/blnc4hofk3q1bbr__file
debug: toolchain is already up to date

  stable-x86_64-unknown-linux-gnu unchanged - rustc 1.89.0 (29483883e 2025-08-04)

info: checking for self-update
+ rustup target list --toolchain stable-x86_64-unknown-linux-gnu
+ rustup component list --toolchain stable-x86_64-unknown-linux-gnu
+ /usr/local/bin/docker
+ /usr/local/bin/docker run --userns host -e 'PKG_CONFIG_ALLOW_CROSS=1' -e 'XARGO_HOME=/xargo' -e 'CARGO_HOME=/cargo' -e 'CARGO_TARGET_DIR=/target' -e 'CROSS_RUNNER=' -e TERM -e 'USER=pp' --rm --user 1000:1000 -v /home/pp/.xargo:/xargo:z -v /home/pp/.cargo:/cargo:z -v /cargo/bin -v /home/pp/programs/rust/simple-cam:/project:z -v /home/pp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu:/rust:z,ro -v /home/pp/programs/rust/simple-cam/target:/target:z -w /project -i -t ghcr.io/cross-rs/aarch64-unknown-linux-gnu:0.2.5 sh -c 'PATH=$PATH:/rust/bin cargo build --target aarch64-unknown-linux-gnu -vvv'
warning: failed to save last-use data
This may prevent cargo from accurately tracking what is being used in its global cache. This information is used for automatically removing unused data in the cache.

attempt to write a readonly database

Caused by:
  Error code 8: Attempt to write a readonly database
error: failed to create directory `/target/debug`

Caused by:
  Permission denied (os error 13)
+ rustup component list --toolchain stable-x86_64-unknown-linux-gnu

Additional information / notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions