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

vscode rust devcontainer: cargo build resulting in "failed to link or copy.." #9900

Open
dss010101 opened this issue May 18, 2024 · 2 comments
Assignees
Labels
containers Issue in vscode-remote containers

Comments

@dss010101
Copy link

dss010101 commented May 18, 2024

Description

Im not sure if should be reaching out here or vscode for help on this...but i will start here and let me know if im int he wrong location..

image

i have built a vs code devcontainer based on mcr.microsoft.com/devcontainers/rust:1-1-bullseye, running under Docker Desktop on windows 11. I am able to run a basic example using this without any dependencies

i have the following structure (Note: the target and Cargo.lock do not exist until after i attempt a cargo build:

My toml looks like this:

[package]
name = "aipg_client"
version = "0.1.0"
edition = "2021"

#[dependencies]
#tokio-postgres = "0.7.10"

when i do Cargo build or run from command line, i see this:

vscode ➜ /workspaces/aipg_client $ cargo clean
     Removed 19 files, 3.7MiB total
vscode ➜ /workspaces/aipg_client $ cargo build
   Compiling aipg_client v0.1.0 (/workspaces/aipg_client)
warning: error copying object file `/workspaces/aipg_client/target/debug/deps/aipg_client-29a466bd116893b1.2wavitxjlghb5boo.rcgu.o` to incremental directory as `/workspaces/aipg_client/target/debug/incremental/aipg_client-cn2ostj37iq8/s-gw2y4x6qjv-d1xpw0-working/2wavitxjlghb5boo.o`: Operation not permitted (os error 1)

warning: error copying object file `/workspaces/aipg_client/target/debug/deps/aipg_client-29a466bd116893b1.340xt2kclbcozwj5.rcgu.o` to incremental directory as `/workspaces/aipg_client/target/debug/incremental/aipg_client-cn2ostj37iq8/s-gw2y4x6qjv-d1xpw0-working/340xt2kclbcozwj5.o`: Operation not permitted (os error 1)

warning: error copying object file `/workspaces/aipg_client/target/debug/deps/aipg_client-29a466bd116893b1.3nlg3iffbximniu8.rcgu.o` to incremental directory as `/workspaces/aipg_client/target/debug/incremental/aipg_client-cn2ostj37iq8/s-gw2y4x6qjv-d1xpw0-working/3nlg3iffbximniu8.o`: Operation not permitted (os error 1)

warning: error copying object file `/workspaces/aipg_client/target/debug/deps/aipg_client-29a466bd116893b1.57xak5150to06626.rcgu.o` to incremental directory as `/workspaces/aipg_client/target/debug/incremental/aipg_client-cn2ostj37iq8/s-gw2y4x6qjv-d1xpw0-working/57xak5150to06626.o`: Operation not permitted (os error 1)

warning: error copying object file `/workspaces/aipg_client/target/debug/deps/aipg_client-29a466bd116893b1.ele9p2lo4vgyfma.rcgu.o` to incremental directory as `/workspaces/aipg_client/target/debug/incremental/aipg_client-cn2ostj37iq8/s-gw2y4x6qjv-d1xpw0-working/ele9p2lo4vgyfma.o`: Operation not permitted (os error 1)

warning: error copying object file `/workspaces/aipg_client/target/debug/deps/aipg_client-29a466bd116893b1.eyyxtxgek58rknf.rcgu.o` to incremental directory as `/workspaces/aipg_client/target/debug/incremental/aipg_client-cn2ostj37iq8/s-gw2y4x6qjv-d1xpw0-working/eyyxtxgek58rknf.o`: Operation not permitted (os error 1)

warning: `aipg_client` (bin "aipg_client") generated 6 warnings
error: failed to link or copy `/workspaces/aipg_client/target/debug/deps/aipg_client-29a466bd116893b1` to `/workspaces/aipg_client/target/debug/aipg_client`

Caused by:
  Operation not permitted (os error 1)

i checked these folders and they are all r/w.
What am i doing wrong?

Reproduce

  1. Create a vscode dev container: CTRL+SHIFT+P -> devcontainer:new -> rust
  2. Note: i jused a Dockerfile + Docker Compose along with .devcontainer.json. but the issue is reproducible with just a .devcontainer.json file
  3. Install rust analyzer extension in the container
  4. from bash terminal: cargo new test
  5. run cargo build twice

###Version Info
Version: 1.89.1 (user setup)
Commit: dc96b837cf6bb4af9cd736aa3af08cf8279f7685
Date: 2024-05-07T05:13:33.891Z
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Windows_NT x64 10.0.22621

Dev Containers v0.362.0
Docker Desktop 4.29.0 (145265)

@dss010101
Copy link
Author

though i dont know if its relevant here i are my docker file and docker-compose:
docker file:

FROM mcr.microsoft.com/devcontainers/rust:1-1-bullseye as aipg_client_base
ENV TZ=America/New_York

ARG ENV
ARG USER_ID
ARG GROUP_ID
ARG USER_NAME
ARG APP_HOME="/apps/aipg_client_base"
RUN echo "env: $ENV, user: $USER_NAME, user_id: $USER_ID, app_home: $APP_HOME"

RUN apt-get update && apt-get -y install acl iputils-ping less libpq-dev nano postgresql-client sudo

RUN groupadd -g $GROUP_ID -o $USER_NAME
RUN useradd -m -s /bin/bash -u $USER_ID -g $GROUP_ID $USER_NAME

FROM aipg_client_base as aipg_client_local


#attempt at handling this target folder issue...
RUN mkdir -p /workspaces/aipg_client/target
RUN chown -R vscode:vscode /workspaces/aipg_client/target
RUN chmod -R 777 /workspaces/aipg_client/target

docker-compose:

networks:
  aipg_client_net:
    driver: bridge

services:
  aipg_client:
    container_name: aipg_client_${ENV}
    image: "aipg_client:${VERSION}"
    build:
      context: ..
      dockerfile: .devcontainer/Dockerfile
      target: aipg_client_local
      args:
        ENV: ${ENV:-local}
        USER_ID: ${USER_ID:-1000}
        GROUP_ID: ${GROUP_ID:-1000}
        USER_NAME: ${USER_NAME}
      shm_size: '2gb'
    env_file:
      - ./.env
    volumes:
      - ../..:/workspaces
      - ~/.ssh:/home/${USER_NAME}/.ssh
      - //var/run/docker.sock:/var/run/docker.sock
    command: sleep infinity
    shm_size: 0.94gb
    ports: 
      - "${SVC_PORT}:5000"    
    networks:
      - aipg_client_net

.env file:

VERSION=local
ENV=local
USER_ID=197609
#USER_ID=1001
GROUP_ID=1000
USER_NAME=user1
SVC_PORT=6000

if i add a .cargo/config.toml with the target anywhere outside my project workspace, it seems to work fine

[build]
target-dir = "/tmp/target"

But of course that means anytime i restart/rebuild the container, i have to rebuild the project/binaries. which makes it not seem like a good solution

@VSCodeTriageBot VSCodeTriageBot added the containers Issue in vscode-remote containers label May 18, 2024
@dss010101
Copy link
Author

Anyone with any advice on how to go about resolving this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
containers Issue in vscode-remote containers
Projects
None yet
Development

No branches or pull requests

3 participants