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

[Issue] Error opening sample in devcontainer in local M1 MacBookPro VS Code #952

Closed
pamelafox opened this issue Oct 21, 2022 · 6 comments · Fixed by #1284
Closed

[Issue] Error opening sample in devcontainer in local M1 MacBookPro VS Code #952

pamelafox opened this issue Oct 21, 2022 · 6 comments · Fixed by #1284
Assignees
Labels
bug Something isn't working devcontainer engsys
Milestone

Comments

@pamelafox
Copy link
Member

Output from azd version
(I don't believe it would be accurate to report this, since this issue is about azd in the Docker)

Describe the bug

When I git clone https://github.com/Azure-Samples/todo-python-mongo locally and open in VS Code with the Devcontainer extension, it prompts me to reopen in the devcontainer.

I then reopen in devcontainer, but it always errors out on the stage of installing azd with "ERROR: Architecture not supported: aarch64 on platform: linux"

Here is the full output:

[7879 ms] Start: Run: docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /var/folders/nq/2sq7jzp17tl97sgxzbptr2d80000gn/T/devcontainercli/container-features/0.20.0-1666369393358/Dockerfile-with-features -t vsc-todo-python-mongo-9aff2b5753343f2815ef2f6193e7e488 --target dev_containers_target_stage --build-arg VARIANT=bullseye --build-context dev_containers_feature_content_source=/var/folders/nq/2sq7jzp17tl97sgxzbptr2d80000gn/T/devcontainercli/container-features/0.20.0-1666369393358 --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label --build-arg _DEV_CONTAINERS_IMAGE_USER=root --build-arg _DEV_CONTAINERS_FEATURE_CONTENT_SOURCE=dev_container_feature_content_temp /Users/pamelafox/todo-python-mongo/.devcontainer
[+] Building 5.7s (12/18)                                                       
 => [internal] load build definition from Dockerfile-with-features         0.0s
 => => transferring dockerfile: 3.36kB                                     0.0s
 => [internal] load .dockerignore                                          0.0s
 => => transferring context: 2B                                            0.0s
 => resolve image config for docker.io/docker/dockerfile:1.4               1.3s
 => [auth] docker/dockerfile:pull token for registry-1.docker.io           0.0s
 => CACHED docker-image://docker.io/docker/dockerfile:1.4@sha256:9ba7531b  0.0s
 => [internal] load build definition from Dockerfile-with-features         0.0s
 => [internal] load .dockerignore                                          0.0s
 => [internal] load metadata for mcr.microsoft.com/vscode/devcontainers/b  0.1s
 => [context dev_containers_feature_content_source] load .dockerignore     0.0s
 => => transferring dev_containers_feature_content_source: 2B              0.0s
 => CACHED [dev_container_auto_added_stage_label 1/2] FROM mcr.microsoft.  0.0s
 => [context dev_containers_feature_content_source] load from client       0.0s
 => => transferring dev_containers_feature_content_source: 75.89kB         0.0s
 => ERROR [dev_container_auto_added_stage_label 2/2] RUN curl -fsSL https  3.9s
------                                                                          
 > [dev_container_auto_added_stage_label 2/2] RUN curl -fsSL https://aka.ms/install-azd.sh | bash:
#0 3.886 install-azd: ERROR: Architecture not supported: aarch64 on platform: linux
#0 3.887 install-azd: ERROR: Unhandled error
#0 3.901 main: line 27: no_telemetry: unbound variable
------
ERROR: failed to solve: executor failed running [/bin/sh -c curl -fsSL https://aka.ms/install-azd.sh | bash]: exit code: 1
[14112 ms] Error: Command failed: docker buildx build --load --build-arg BUILDKIT_INLINE_CACHE=1 -f /var/folders/nq/2sq7jzp17tl97sgxzbptr2d80000gn/T/devcontainercli/container-features/0.20.0-1666369393358/Dockerfile-with-features -t vsc-todo-python-mongo-9aff2b5753343f2815ef2f6193e7e488 --target dev_containers_target_stage --build-arg VARIANT=bullseye --build-context dev_containers_feature_content_source=/var/folders/nq/2sq7jzp17tl97sgxzbptr2d80000gn/T/devcontainercli/container-features/0.20.0-1666369393358 --build-arg _DEV_CONTAINERS_BASE_IMAGE=dev_container_auto_added_stage_label --build-arg _DEV_CONTAINERS_IMAGE_USER=root --build-arg _DEV_CONTAINERS_FEATURE_CONTENT_SOURCE=dev_container_feature_content_temp /Users/pamelafox/todo-python-mongo/.devcontainer
[14112 ms]     at Vse (/Users/pamelafox/.vscode/extensions/ms-vscode-remote.remote-containers-0.255.4/dist/spec-node/devContainersSpecCLI.js:1869:1635)
[14112 ms]     at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
[14112 ms]     at async ZA (/Users/pamelafox/.vscode/extensions/ms-vscode-remote.remote-containers-0.255.4/dist/spec-node/devContainersSpecCLI.js:1868:1973)
[14112 ms]     at async jO (/Users/pamelafox/.vscode/extensions/ms-vscode-remote.remote-containers-0.255.4/dist/spec-node/devContainersSpecCLI.js:1868:901)
[14112 ms]     at async Xse (/Users/pamelafox/.vscode/extensions/ms-vscode-remote.remote-containers-0.255.4/dist/spec-node/devContainersSpecCLI.js:1874:2030)
[14113 ms]     at async Uf (/Users/pamelafox/.vscode/extensions/ms-vscode-remote.remote-containers-0.255.4/dist/spec-node/devContainersSpecCLI.js:1874:3193)
[14113 ms]     at async Cae (/Users/pamelafox/.vscode/extensions/ms-vscode-remote.remote-containers-0.255.4/dist/spec-node/devContainersSpecCLI.js:1994:10350)
[14113 ms]     at async yae (/Users/pamelafox/.vscode/extensions/ms-vscode-remote.remote-containers-0.255.4/dist/spec-node/devContainersSpecCLI.js:1994:10104)
[14115 ms] Exit code 1
[14119 ms] Command failed: /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper.app/Contents/MacOS/Code Helper --ms-enable-electron-run-as-node /Users/pamelafox/.vscode/extensions/ms-vscode-remote.remote-containers-0.255.4/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /Users/pamelafox/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --workspace-folder /Users/pamelafox/todo-python-mongo --workspace-mount-consistency cached --id-label devcontainer.local_folder=/Users/pamelafox/todo-python-mongo --log-level debug --log-format json --config /Users/pamelafox/todo-python-mongo/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true
[14119 ms] Exit code 1

I assume this is related to the fact that my MBP is an M1, based on the error about aarch64.
I am able to install azd locally:

pamelafox@Pamelas-MBP-2 ~ % curl -fsSL https://aka.ms/install-azd.sh | bash
Archive:  /var/folders/nq/2sq7jzp17tl97sgxzbptr2d80000gn/T/tmp.cq09ydFD/azd-darwin-amd64.zip
  inflating: /var/folders/nq/2sq7jzp17tl97sgxzbptr2d80000gn/T/tmp.cq09ydFD/azd-darwin-amd64  

That downloads an AMD64 build, not an arm64 build, but it seems to work fine.

Environment

VS Code:
Version: 1.72.2 (Universal)
Commit: d045a5eda657f4d7b676dedbfa7aab8207f8a075
Date: 2022-10-12T22:16:30.254Z
Electron: 19.0.17
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Darwin arm64 21.6.0
Sandboxed: No

Additional context

I have had issues in devcontainer in the past when I had extensions enabled for my Docker desktop app, but I've since turned them off since they cause issues.

@ellismg
Copy link
Member

ellismg commented Oct 21, 2022

I assume this is related to the fact that my MBP is an M1, based on the error about aarch64.
I am able to install azd locally:

Good sleuthing! I believe you are correct here. We are not yet building any ARM versions of azd. We have logic in install-azd.sh such that when running on a Mac, we download the amd64 version of the binary:

elif [ "$architecture_raw" = "arm64" ] && [ "$platform" = 'darwin' ]; then
# In the case of Apple Silicon use the existing ARM64 environment
echo 'amd64';
return;

This relied on the fact that Rosetta exists and allows M1s to run amd64 binaries. That assumption falls apart on *nix, where there is no Rosetta.

I suspect that we should start building and publishing arm64 binaries for all the supported OSes. Go makes this pretty easy, we can run a go build with GOARCH=arm64 and GOOS=linux set (or darwin or windows) without having to set up a cross compiler environment. Once we did that, we could edit install-azd.sh to correctly handle these cases.

In the meantime, I wonder if there's a way for us to force passing --platform amd64 when building the devcontainer image?

@ellismg
Copy link
Member

ellismg commented Oct 21, 2022

/cc @danieljurek Since you've been looking at codespaces/devcointainer stuff recently.

@ellismg ellismg added bug Something isn't working devcontainer labels Oct 21, 2022
@rajeshkamal5050 rajeshkamal5050 added this to the On Deck milestone Oct 24, 2022
@ghost ghost added the needs-triage For new issues label Nov 1, 2022
@rajeshkamal5050 rajeshkamal5050 modified the milestones: On Deck, Release 0.5 Nov 4, 2022
@danieljurek
Copy link
Member

danieljurek commented Dec 6, 2022

In order to get this to work we'll need to build an ARM64 Go binary for Linux. We can cross-compile this but will need a way to verify that the software works and is testable in order to support such a release.

Started doing some research:

  • Set up an ARM64 pool of machines in Azure DevOps
  • Get pipelines building and running tools

ARM64 Linux/Windows images are NOT supported by default in Azure DevOps Pipelines. To run this we'll need to install prerequisite tools. Some of these can be installed successfully (like PowerShell) but I encountered an issue installing the correct version of Go.

This is starting to look like it'll require an iterative process to get working.

Additional steps not yet tested:

(all have been categorized at the moment)

Steps requiring fixes:

Steps not requiring fixes:

  • PublishTestResults@2
  • PublishCodeCoverageResults@1
  • PublishPipelineArtifact@1

cc @ellismg @rajeshkamal5050 @savannahostrowski

@savannahostrowski
Copy link

This is a good catch! We definitely want to get ARM build of azd lit up. Looks like this is already in the current milestone (which seems appropriate to me).

@danieljurek
Copy link
Member

danieljurek commented Dec 8, 2022

@pamelafox -- As a short term fix try changing the line in the devcontainer Dockerfile from

FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}

to include --platform=amd64:

FROM --platform=amd64 mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}

Does this unblock your work?

@pamelafox
Copy link
Member Author

That does seem to work, yes! I am not blocked since I can either use Codespaces or just choose to not open in devcontainer, but its neat that I can open the devcontainer locally now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working devcontainer engsys
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants