Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote docker throws "sh: 1: cargo: not found" error if cargo comes from nix distribution #1383

Open
6 of 11 tasks
david9991 opened this issue Dec 12, 2023 · 2 comments
Open
6 of 11 tasks
Labels
A-nixos-host Area: NixOS hosts A-remote

Comments

@david9991
Copy link

Checklist

Describe your issue

When executing the command DOCKER_HOST=... CROSS_REMOTE=1 ~/.cargo/bin/cross --verbose build --target arm-unknown-linux-gnueabi, I encountered the error sh: 1: cargo: not found.

With verbose output enabled, I discovered that the following command was executed:

/home/gitlab-workspaces/.nix-profile/bin/docker exec cross-stable-x86_64-unknown-linux-gnu-ae81e-79e9716c9-arm-unknown-linux-gnueabi-plcc-blockchain-tools-c1946 sh -c 'mkdir -p '\''/cross/cargo'\'''
/home/gitlab-workspaces/.nix-profile/bin/docker cp -a /home/gitlab-workspaces/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin cross-stable-x86_64-unknown-linux-gnu-ae81e-79e9716c9-arm-unknown-linux-gnueabi-plcc-blockchain-tools-c1946:/cross/rust

The second command copies the /home/gitlab-workspaces/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin directory as /cross/rust instead of copying the folder to /cross/rust/ if the /cross/rust directory does not exist. (Only 'cross/cargo' was created in the previous command)

This behavior will cause the subsequent command:

/home/gitlab-workspaces/.nix-profile/bin/docker exec --user 5001:5001 -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 BROWSER -e 'USER=gitlab-workspaces' -w /project cross-stable-x86_64-unknown-linux-gnu-ae81e-79e9716c9-arm-unknown-linux-gnueabi-plcc-blockchain-tools-c1946 sh -c 'PATH=$PATH:/rust/bin cargo --verbose build --target arm-unknown-linux-gnueabi --target-dir /cross/project/target`

which attempt to use the cargo executable from the /rust/bin folder to fail.

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

No response

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

No response

Additional information / notes

No response

@Emilgardis
Copy link
Member

I'm not sure if there was a specific fix for this done, but can you try cross installed from the main branch?

This shouldn't happen, as we create the directories here

@david9991
Copy link
Author

@Emilgardis You're right. It's a Nix related issue. the cargo was patched by Nix, so the error message isn't about the cargo itself, but its elf interpreter cannot be found in the container. It can be worked around by setting the interpreter back to /lib64/ld-linux-x86-64.so.2 before being copied from Nix environment.

@Emilgardis Emilgardis changed the title Remote docker throws "sh: 1: cargo: not found" error Remote docker throws "sh: 1: cargo: not found" error if cargo comes from nix distribution Dec 12, 2023
@Emilgardis Emilgardis added the A-nixos-host Area: NixOS hosts label Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-nixos-host Area: NixOS hosts A-remote
Projects
None yet
Development

No branches or pull requests

2 participants