Background
Nowadays, it is very common to use a docker container with bind mounts to develop programs, where the bind mounts contain the source code and docker container itself takes charge of environment setup.
For example:
docker run --mount type=bind,source=host/path/to/src,target=guest/path/to/src my-image
Using the command above, we can modify source codes without docker commit
each time, and my-image
just stores all other environment-related things.
Problem
In a Windows container (not just a docker container in Windows, it is a container running Windows inside Windows using hyper-V), if we put rust source code in a bind mounts, and the rust project contains build.rs
, then cargo build
will fail because of "access denied".
There is an issue I found in cargo's GitHub repo: cargo#9193, which contains detailed information about this problem.
Root cause
After searching for similar problems, I thought the root cause for this problem is illustrated in this issue, which says that rustc can't deal with some Windows symlinks, while bind mounts inside Windows container is a symlink which can't be handled properly.
There is a feature request in rust which is also related to this issue.
Microsoft has a web page about permissions inside bind mounts of Windows container, but changing permissions to "Authenticated Users" doesn't work for me.
I am quite frustrated about this problem, since the rust project I worked with is Windows specific (which requires a specific Windows version), so I can't use other OS to develop.
I think this problem is quite general (which is not a crate-specific or version-specific), and if there is a workaround, it may helps a lot for developers who design Windows rust project.