Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Parser failure on "localEnv:" in devcontainer-feature.json

Đang mở
#1,704 0 bình luận 1 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 5 ngày

@v-Kaniska244 đang làm issue này rồi.

Từ ngày 5/8/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

When trying to inject a host environment variable into the container like this (in devcontainer-feature.json)

"containerEnv": {
    "MY_API_KEY": "${localEnv:MY_API_KEY}"
  }

the following error is returned:

UndefinedVar: Usage of undefined variable '$localEnv' (line 23)
Dockerfile.extended:23
--------------------
  21 |     echo "_REMOTE_USER_HOME=$( (command -v getent >/dev/null 2>&1 && getent passwd 'vscode' || grep -E '^vscode|^[^:]*:[^:]*:vscode:' /etc/passwd || true) | cut -d: -f6)" >> /tmp/dev-container-features/devcontainer-features.builtin.env
  22 |     
  23 | >>> ENV MY_API_KEY="${localEnv:MY_API_KEY}"
  24 |     RUN --mount=type=bind,from=dev_containers_feature_content_source,source=opencode-psi_0,target=/tmp/build-features-src/opencode-psi_0 \
  25 |         cp -ar /tmp/build-features-src/opencode-psi_0 /tmp/dev-container-features \
--------------------
[2026-08-04T06:11:06.442Z] 
ERROR: failed to build: failed to solve: failed to process "\"${localEnv:MY_API_
_KEY}\"": unsupported modifier (:M) in substitution

The issue seems to be that the "localEnv:" substring is not getting substituted before being passed to Docker, whose parser then trips on ":M" (or apparently any other colon-letter combination). Indeed, the error message goes away by inserting a hyphen after the colon:

"containerEnv": {
    "MY_API_KEY": "${localEnv:-MY_API_KEY}"
  }

But then the value passed into the container environment is the literal string "MY_API_KEY:":

env | grep MY_API_KEY
MY_API_KEY=MY_API_KEY:
Ngôn ngữ chính
Shell
Star
1.5k
Fork
624
Merge trung bình
4 ngày 8 giờ
Pull request đã merge (30 ngày)
7

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của devcontainers/features

Tất cả issue của devcontainers/features

Issue tương tự

Thêm issue về Shell/Bash

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.