Skip to content

Error: Unable to create cache directory #386

@James-Mart

Description

@James-Mart

Description

I build my repository in CI/CD by checking out the repository, and then mounting it into a docker container in which I execute the build using CMake/Make.
The image for the container used to have cargo-component v0.15.0, and everything worked fine.
I am in the process of trying to upgrade my build image to use cargo-component v0.21.1, and I suddenly started getting the following error:

[ 50%] Performing build step for 'MyComponent'
cd /home/.../src/MyComponent-build && cargo component build -r --target wasm32-unknown-unknown --manifest-path /home/.../my-component/Cargo.toml --target-dir /home/.../build/MyComponent
Error: Unable to create cache directory

Caused by:
    Permission denied (os error 13) 

Root cause

Presumably this is because I am running the build as a non-root user within the docker container and code was added that attempts to create a cache directory in a permissioned space.

Workaround

For anyone else experiencing this issue, I've found the following workaround:
Manually set a value for the CARGO_COMPONENT_CACHE_DIR environment variable. e.g. export CARGO_COMPONENT_CACHE_DIR=.cargo-component-cache

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