From 48e522b7226c10c4b1ee4e4b72d736ede8238c27 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <209825114+claude[bot]@users.noreply.github.com> Date: Thu, 29 May 2025 04:00:01 +0000 Subject: [PATCH 1/2] fix: resolve devcontainer feature common installation issue - Remove invalid entrypoint, args, and init fields from devcontainer-feature.json - Add robust path detection in install.sh to find npm/global.json - Add debugging output and error handling for better troubleshooting - Ensure jq dependency is installed before JSON parsing Fixes #21 Co-authored-by: keito4 --- .../features/common/devcontainer-feature.json | 5 +- .devcontainer/features/common/install.sh | 55 ++++++++++++++++--- 2 files changed, 49 insertions(+), 11 deletions(-) mode change 100755 => 100644 .devcontainer/features/common/install.sh diff --git a/.devcontainer/features/common/devcontainer-feature.json b/.devcontainer/features/common/devcontainer-feature.json index 00222e45..2cb208bc 100644 --- a/.devcontainer/features/common/devcontainer-feature.json +++ b/.devcontainer/features/common/devcontainer-feature.json @@ -6,8 +6,5 @@ "installsAfter": [ "ghcr.io/meaningful-ooo/devcontainer-features/homebrew" ], - "options": {}, - "init": true, - "entrypoint": "/bin/sh", - "args": ["-c", "sh .devcontainer/features/common/install.sh"] + "options": {} } diff --git a/.devcontainer/features/common/install.sh b/.devcontainer/features/common/install.sh old mode 100755 new mode 100644 index fecefcc1..f051a0b4 --- a/.devcontainer/features/common/install.sh +++ b/.devcontainer/features/common/install.sh @@ -1,14 +1,55 @@ #!/bin/sh set -e -# npm/global.jsonからパッケージを読み込んでインストール -if [ -f "npm/global.json" ]; then - echo "Installing global npm packages from npm/global.json..." - jq -r '.dependencies | keys[]' npm/global.json | while read package; do - version=$(jq -r ".dependencies[\"$package\"].version" npm/global.json) - echo "Installing $package@$version..." - npm install -g "$package@$version" +echo "Starting common feature installation..." + +# デバッグ情報を出力 +echo "Current working directory: $(pwd)" +echo "User: $(whoami)" +echo "Home directory: $HOME" + +# npm/global.jsonを見つけるための複数のパスを試行 +GLOBAL_JSON_PATHS=( + "npm/global.json" + "/workspace/npm/global.json" + "/workspaces/*/npm/global.json" + "$HOME/npm/global.json" + "/tmp/build/npm/global.json" +) + +GLOBAL_JSON_FILE="" +for path in "${GLOBAL_JSON_PATHS[@]}"; do + # ワイルドカードを展開 + for file in $path; do + if [ -f "$file" ]; then + GLOBAL_JSON_FILE="$file" + echo "Found npm/global.json at: $GLOBAL_JSON_FILE" + break 2 + fi + done +done + +if [ -z "$GLOBAL_JSON_FILE" ]; then + echo "Warning: npm/global.json not found in any of the expected locations:" + for path in "${GLOBAL_JSON_PATHS[@]}"; do + echo " - $path" done + echo "Skipping npm package installation." + exit 0 +fi + +# jqが利用可能かチェック +if ! command -v jq >/dev/null 2>&1; then + echo "Installing jq for JSON parsing..." + apt-get update && apt-get install -y jq fi +# npm/global.jsonからパッケージを読み込んでインストール +echo "Installing global npm packages from $GLOBAL_JSON_FILE..." +jq -r '.dependencies | keys[]' "$GLOBAL_JSON_FILE" | while read package; do + version=$(jq -r ".dependencies[\"$package\"].version" "$GLOBAL_JSON_FILE") + echo "Installing $package@$version..." + npm install -g "$package@$version" +done + echo "Feature installation completed. Configuration will be applied by postCreateCommand." From caf47908783db65ec8a25b7c2d4abfb7e9fb48d5 Mon Sep 17 00:00:00 2001 From: keito4 Date: Thu, 29 May 2025 06:15:57 +0000 Subject: [PATCH 2/2] =?UTF-8?q?devcontainer=E3=81=AE=E8=A8=AD=E5=AE=9A?= =?UTF-8?q?=E3=82=92=E6=9B=B4=E6=96=B0=E3=81=97=E3=80=81common=E6=A9=9F?= =?UTF-8?q?=E8=83=BD=E3=81=ABjq=E3=81=A8zsh=E3=83=97=E3=83=A9=E3=82=B0?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=82=92=E8=BF=BD=E5=8A=A0=E3=80=82install.s?= =?UTF-8?q?h=E3=82=92bash=E3=81=AB=E5=A4=89=E6=9B=B4=E3=81=97=E3=80=81npm/?= =?UTF-8?q?global.json=E3=81=AE=E3=83=91=E3=82=B9=E6=A4=9C=E5=87=BA?= =?UTF-8?q?=E3=82=92=E6=94=B9=E5=96=84=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .devcontainer/devcontainer.json | 1 + .../features/common/devcontainer-feature.json | 4 +- .devcontainer/features/common/install.sh | 64 ++++++++----------- 3 files changed, 30 insertions(+), 39 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7f6da996..7ca61526 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -3,6 +3,7 @@ "image": "mcr.microsoft.com/devcontainers/base:ubuntu", "features": { "ghcr.io/devcontainers-extra/features/homebrew-package:1": {}, + "ghcr.io/eitsupi/devcontainer-features/jq-likes:2": {}, "./features/common": {}, "ghcr.io/itsmechlark/features/1password:1": {}, "ghcr.io/devcontainers/features/github-cli:1": {}, diff --git a/.devcontainer/features/common/devcontainer-feature.json b/.devcontainer/features/common/devcontainer-feature.json index 2cb208bc..7e56ee3a 100644 --- a/.devcontainer/features/common/devcontainer-feature.json +++ b/.devcontainer/features/common/devcontainer-feature.json @@ -4,7 +4,9 @@ "name": "Common Development Setup", "description": "Installs common development functions and configures development environment scripts", "installsAfter": [ - "ghcr.io/meaningful-ooo/devcontainer-features/homebrew" + "ghcr.io/meaningful-ooo/devcontainer-features/homebrew", + "ghcr.io/devcontainers-extra/features/zsh-plugins:0", + "ghcr.io/eitsupi/devcontainer-features/jq-likes:2" ], "options": {} } diff --git a/.devcontainer/features/common/install.sh b/.devcontainer/features/common/install.sh index f051a0b4..dd1b5689 100644 --- a/.devcontainer/features/common/install.sh +++ b/.devcontainer/features/common/install.sh @@ -1,55 +1,43 @@ -#!/bin/sh -set -e +#!/usr/bin/env bash +[ -n "${ZSH_VERSION-}" ] && emulate -L sh +set -eu +if (set -o 2>/dev/null | grep -q pipefail); then + set -o pipefail +fi echo "Starting common feature installation..." - -# デバッグ情報を出力 echo "Current working directory: $(pwd)" echo "User: $(whoami)" echo "Home directory: $HOME" -# npm/global.jsonを見つけるための複数のパスを試行 GLOBAL_JSON_PATHS=( - "npm/global.json" - "/workspace/npm/global.json" - "/workspaces/*/npm/global.json" - "$HOME/npm/global.json" - "/tmp/build/npm/global.json" + "npm/global.json" + "/workspace/npm/global.json" + "/workspaces/*/npm/global.json" + "$HOME/npm/global.json" + "/tmp/build/npm/global.json" ) GLOBAL_JSON_FILE="" -for path in "${GLOBAL_JSON_PATHS[@]}"; do - # ワイルドカードを展開 - for file in $path; do - if [ -f "$file" ]; then - GLOBAL_JSON_FILE="$file" - echo "Found npm/global.json at: $GLOBAL_JSON_FILE" - break 2 - fi - done +for path in ${GLOBAL_JSON_PATHS[@]}; do + for file in $path; do + if [ -f "$file" ]; then + GLOBAL_JSON_FILE="$file" + echo "Found npm/global.json at: $GLOBAL_JSON_FILE" + break 2 + fi + done done if [ -z "$GLOBAL_JSON_FILE" ]; then - echo "Warning: npm/global.json not found in any of the expected locations:" - for path in "${GLOBAL_JSON_PATHS[@]}"; do - echo " - $path" - done - echo "Skipping npm package installation." - exit 0 + echo "Warning: npm/global.json not found in any of the expected locations:" + for path in ${GLOBAL_JSON_PATHS[@]}; do + echo " - $path" + done + echo "Skipping npm package installation." + exit 0 fi -# jqが利用可能かチェック -if ! command -v jq >/dev/null 2>&1; then - echo "Installing jq for JSON parsing..." - apt-get update && apt-get install -y jq -fi - -# npm/global.jsonからパッケージを読み込んでインストール -echo "Installing global npm packages from $GLOBAL_JSON_FILE..." -jq -r '.dependencies | keys[]' "$GLOBAL_JSON_FILE" | while read package; do - version=$(jq -r ".dependencies[\"$package\"].version" "$GLOBAL_JSON_FILE") - echo "Installing $package@$version..." - npm install -g "$package@$version" -done +npm install -g $(jq -r '.dependencies | keys[]' "$GLOBAL_JSON_FILE") echo "Feature installation completed. Configuration will be applied by postCreateCommand."