You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using docker or podman on a Windows machine (run from Git bash or CMD, likely also Powershell), the container engine fails to change directories to the mounted project directory. Although the mount directories for the same locations are properly mounted, the -w flag fails. This is an issue if using /mnt/c or C:\ for the provided path. The attempted workdir attempted to be found relative to Git bash.
On CMD, the workpath is properly found, so the CMD, and CMD is properly mounted, however other issues still seem to exist, since it produces the same error.
None of these issues manifest with cargo directly.
The simplest example is to do:
$ git clone https://github.com/cross-rs/test-workspace
$ cd test-workspace/workspace
$ crossbuild --target x
Oddly, this does not fail with the following invocation:
```bash$ cross build --target x86_64-unknown-linux-gnu -v --manifest-path="./workspace/Cargo.toml" --workspace
What target(s) are you cross-compiling for?
No response
Which operating system is the host (e.g computer cross is on) running?
Note that this also reproduces on Windows CMD as well as Git bash, so it's not exclusively a Git bash problem.
$ /c/Users/ahusz/git/cross/target/debug/cross.exe build --target x86_64-unknown-linux-gnu --workspace -v
+ cargo metadata --format-version 1 --filter-platform x86_64-unknown-linux-gnu
+ rustc --print sysroot
+ "C:\Program Files\Docker\Docker\resources\bin\docker.exe"
+ "C:\Program Files\Docker\Docker\resources\bin\docker.exe" version -f '{{ .Server.Os }},,,{{ .Server.Arch }}'
+ rustup toolchain list
+ rustup target list --toolchain stable-x86_64-unknown-linux-gnu
+ rustup component list --toolchain stable-x86_64-unknown-linux-gnu
+ "C:\Program Files\Docker\Docker\resources\bin\docker.exe" run --userns host -e 'PKG_CONFIG_ALLOW_CROSS=1' -e 'XARGO_HOME=/mnt/c/Users/ahusz/.xargo' -e 'CARGO_HOME=/mnt/c/Users/ahusz/.cargo' -e 'CROSS_RUST_SYSROOT=/mnt/c/Users/ahusz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu' -e 'CARGO_TARGET_DIR=/target' -e 'CROSS_RUNNER=' -e TERM -e 'USER=ahusz' -e 'CROSS_RUSTC_MAJOR_VERSION=1' -e 'CROSS_RUSTC_MINOR_VERSION=64' -e 'CROSS_RUSTC_PATCH_VERSION=0' -v 'C:\Users\ahusz\git\cross\target\tmp\tmp.5z26cWTEes\external\external_lib:/mnt/c/mnt/c/Users/ahusz/git/cross/target/tmp/tmp.5z26cWTEes/external/external_lib:z' --name cross-stable-x86_64-unknown-linux-gnu-9de56-a55dd71d5-x86_64-unknown-linux-gnu-12695-1669472749478 --rm --user 1000:1000 -v 'C:\Users\ahusz\.xargo:/mnt/c/Users/ahusz/.xargo:z' -v 'C:\Users\ahusz\.cargo:/mnt/c/Users/ahusz/.cargo:z' -v /mnt/c/Users/ahusz/.cargo/bin -v 'C:\Users\ahusz\git\cross\target\tmp\tmp.5z26cWTEes\workspace:/mnt/c/Users/ahusz/git/cross/target/tmp/tmp.5z26cWTEes/workspace:z' -v 'C:\Users\ahusz\.rustup\toolchains\stable-x86_64-unknown-linux-gnu:/mnt/c/Users/ahusz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu:z,ro' -v 'C:\Users\ahusz\git\cross\target\tmp\tmp.5z26cWTEes\workspace\target:/target:z' -w /mnt/c/Users/ahusz/git/cross/target/tmp/tmp.5z26cWTEes/workspace -t ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main sh -c 'PATH="$PATH":"/mnt/c/Users/ahusz/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin" cargo build --target x86_64-unknown-linux-gnu --workspace -v'
error: failed to load manifest for workspace member `/mnt/c/Users/ahusz/git/cross/target/tmp/tmp.5z26cWTEes/workspace/binary`
Caused by:
failed to load manifest for dependency `test-workspace`
Caused by:
failed to load manifest for dependency `external_lib`
Caused by:
failed to read`/mnt/c/Users/ahusz/git/cross/target/tmp/tmp.5z26cWTEes/external/external_lib/Cargo.toml`
Caused by:
No such file or directory (os error 2)
+ rustup component list --toolchain stable-x86_64-unknown-linux-gnu
Note that running the following works:
$ "C:\Program Files\Docker\Docker\resources\bin\docker.exe" run --userns host \
-v 'C:\Users\ahusz\git\cross\target\tmp\tmp.5z26cWTEes\external\external_lib:/mnt/c/mnt/c/Users/ahusz/git/cross/target/tmp/tmp.5z26cWTEes/external/external_lib:z' \
-it ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main bash
$ ls /mnt/c/mnt/c/Users/ahusz/git/cross/target/tmp/tmp.5z26cWTEes/external/external_lib
Cargo.toml src
As does:
$ "C:\Program Files\Docker\Docker\resources\bin\docker.exe" run --userns host \
-v 'C:\Users\ahusz\git\cross\target\tmp\tmp.5z26cWTEes\workspace:/mnt/c/Users/ahusz/git/cross/target/tmp/tmp.5z26cWTEes/workspace:z' \
-it ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main bash
$ ls /mnt/c/Users/ahusz/git/cross/target/tmp/tmp.5z26cWTEes/workspace/binary/
Cargo.toml src
So clearly, the issue extends a bit past just the basic error messages reported. However, the failing step is:
$ "C:\Program Files\Docker\Docker\resources\bin\docker.exe" run --userns host \
-v 'C:\Users\ahusz\git\cross\target\tmp\tmp.5z26cWTEes\workspace:/mnt/c/Users/ahusz/git/cross/target/tmp/tmp.5z26cWTEes/workspace:z' \
-w '/mnt/c/Users/ahusz/git/cross/target/tmp/tmp.5z26cWTEes/workspace' \
-it ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main bash
docker: Error response from daemon: the working directory 'C:/Program Files/Git/mnt/c/Users/ahusz/git/cross/target/tmp/tmp.5z26cWTEes/workspace' is invalid, it needs to be an absolute path.
See 'docker run --help'.
Meanwhile, a similar issue occurs when using Podman:
$ podman run --userns host -v 'C:\Users\ahusz\git\cross\target\tmp\tmp.5z26cWTEes\workspace:/mnt/c/Users/ahusz/git/cross/target/tmp/tmp.5z26cWTEes/workspace:z' -w '/mnt/c/Users/ahusz/git/cross/target/tmp/tmp.5z26cWTEes/workspace' -it ghcr.io/cross-rs/x86_64-unknown-linux-gnu:main bash
Error: error preparing container f2ad9a0ac2a0aa6666f69ea52311f7cef253d8e489bcff6909cad98152d2bac7 for attach: workdir "C:/Program Files/Git/mnt/c/Users/ahusz/git/cross/target/tmp/tmp.5z26cWTEes/workspace" does not exist on container f2ad9a0ac2a0aa6666f69ea52311f7cef253d8e489bcff6909cad98152d2bac7
However, when using CMD, the above command works perfectly fine:
EDIT: The relative paths seem to be invalid, it just seems to be an artifact of using Git bash. The major issue, however, remains. It also seems on CMD and Git bash that /mnt/c/mnt/c is duplicated, but this only occurs for external_lib: 'C:\Users\ahusz\git\cross\target\tmp\tmp.5z26cWTEes\external\external_lib:/mnt/c/mnt/c/Users/ahusz/git/cross/target/tmp/tmp.5z26cWTEes/external/external_lib:z'.
That is, it's an issue of dependencies being mounted outside the current workspace.
It might be worth adding ci/test.sh to our Windows and macOS CI.
It seems the issue is in /docker/shared.rs with the mount function, since everything up to there works perfectly fine.
as_posix_absolute probably needs a way to detect if the path starts with /c/ or /mnt/c. This was an issue with wsl -e wslpath before, since this isn't a new bug:
1157: Fix mount paths on Windows. r=Emilgardis a=Alexhuszagh
Fixes mount paths outside of the workspace mount directory on Windows and those provided as a WSL path. This also adds unittests for Windows outside of WSL2.
Closes#1145.
Closes#1156.
Co-authored-by: Alex Huszagh <[email protected]>
Checklist
Describe your issue
When using docker or podman on a Windows machine (run from Git bash or CMD, likely also Powershell), the container engine fails to change directories to the mounted project directory. Although the mount directories for the same locations are properly mounted, the
-w
flag fails. This is an issue if using/mnt/c
orC:\
for the provided path. The attempted workdir attempted to be found relative to Git bash.On CMD, the workpath is properly found, so the CMD, and CMD is properly mounted, however other issues still seem to exist, since it produces the same error.
None of these issues manifest with
cargo
directly.The simplest example is to do:
What target(s) are you cross-compiling for?
No response
Which operating system is the host (e.g computer cross is on) running?
What architecture is the host?
What container engine is cross using?
cross version
cross 0.2.4 (b238b21 2022-10-12)
Example
Note that this also reproduces on Windows CMD as well as Git bash, so it's not exclusively a Git bash problem.
Note that running the following works:
As does:
So clearly, the issue extends a bit past just the basic error messages reported. However, the failing step is:
Meanwhile, a similar issue occurs when using Podman:
However, when using CMD, the above command works perfectly fine:
Additional information / notes
Presumably this also affects other engines, such as lima.
The text was updated successfully, but these errors were encountered: