Skip to content

fix: resolve devcontainer feature common installation issue - #22

Merged
keito4 merged 2 commits into
mainfrom
claude/issue-21-20250529_035805
May 29, 2025
Merged

fix: resolve devcontainer feature common installation issue#22
keito4 merged 2 commits into
mainfrom
claude/issue-21-20250529_035805

Conversation

@keito4

@keito4 keito4 commented May 29, 2025

Copy link
Copy Markdown
Owner

Fixes #21

This PR resolves the issue where ./features/common was not being installed during build time.

Changes

  • Fixed devcontainer-feature.json to follow proper specification
  • Enhanced install.sh with robust path detection and debugging
  • Removed incorrect entrypoint and args configuration

Testing

The feature will now properly install global npm packages from npm/global.json during devcontainer build.

Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability of global npm package installation by searching multiple configuration file locations and providing clearer diagnostics if none are found.
  • Chores
    • Updated development container features to include additional tools for enhanced shell and JSON processing support.
    • Enhanced installation script with safer shell options and simplified package installation commands.

- 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 <keito4@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented May 29, 2025

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

Walkthrough

The changes update the .devcontainer/features/common setup by removing the explicit initialization, entrypoint, and argument properties from the feature's JSON configuration. The install.sh script is enhanced for robustness, supporting flexible global.json discovery, improved diagnostics, and streamlined npm global package installation. The devcontainer configuration adds a new feature for jq-likes.

Changes

Files/Paths Change Summary
.devcontainer/features/common/devcontainer-feature.json Removed "init", "entrypoint", and "args" properties; expanded "installsAfter" array to include two features.
.devcontainer/features/common/install.sh Rewritten for robustness: supports multiple global.json locations, adds diagnostics, simplifies npm install command.
.devcontainer/devcontainer.json Added "ghcr.io/eitsupi/devcontainer-features/jq-likes:2" feature alongside existing features.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Container
    participant InstallScript
    participant System

    User->>Container: Start devcontainer
    Container->>InstallScript: Run install.sh
    InstallScript->>System: Print diagnostics (cwd, user, home)
    InstallScript->>System: Search for global.json in multiple locations
    alt global.json found
        InstallScript->>System: Parse global.json keys for npm packages
        InstallScript->>System: Run npm install -g with package names
    else global.json not found
        InstallScript->>System: Output warning and exit gracefully
    end
    InstallScript->>System: Print completion message
Loading

Assessment against linked issues

Objective Addressed Explanation
Ensure ./features/common is installed at build time (#21) The PR removes init, entrypoint, and args which may affect auto-run; unclear if installation is triggered by other means.

Suggested labels

codex

Poem

A rabbit hopped in the devcontainer’s den,
Tweaked the scripts and JSON again.
Now searching for files with a keen little nose,
And fixing with care wherever it goes.
With logs and checks, it hops along—
The build grows robust, the scripts grow strong! 🐇


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 48e522b and caf4790.

📒 Files selected for processing (3)
  • .devcontainer/devcontainer.json (1 hunks)
  • .devcontainer/features/common/devcontainer-feature.json (1 hunks)
  • .devcontainer/features/common/install.sh (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (4)
.devcontainer/features/common/install.sh (4)

4-9: Consider gating verbose debug output
Unconditional log lines (cwd, user, home) can clutter build logs. You could wrap them in a if [ "${DEBUG:-}" = "true" ] guard or introduce a --verbose flag so diagnostics only print when needed.


11-18: Use workspace environment variables for path discovery
Hardcoded locations like /workspace and /workspaces/* may differ across setups. Leverage built-in DevContainer env vars to locate the repo root more reliably, for example:

-    "/workspace/npm/global.json"
-    "/workspaces/*/npm/global.json"
+    "${DEV_CONTAINER_WORKSPACE_FOLDER}/npm/global.json"
+    "${GITHUB_WORKSPACE}/npm/global.json"
🧰 Tools
🪛 Shellcheck (0.10.0)

[warning] 12-18: In POSIX sh, arrays are undefined.

(SC3030)


41-45: Clean up apt caches after installing jq
To keep the container lean, install without recommends and remove the package lists afterward:

-   apt-get update && apt-get install -y jq
+   apt-get update \
+     && apt-get install -y --no-install-recommends jq \
+     && rm -rf /var/lib/apt/lists/*

47-53: Verify npm is available before proceeding
If Node.js isn’t installed, the npm install -g steps will fail in an opaque way. Add an early check:

if ! command -v npm >/dev/null 2>&1; then
  echo "Error: npm is not installed. Please include a Node.js feature before common."
  exit 1
fi
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d15c71 and 48e522b.

📒 Files selected for processing (2)
  • .devcontainer/features/common/devcontainer-feature.json (1 hunks)
  • .devcontainer/features/common/install.sh (1 hunks)
🧰 Additional context used
🪛 Shellcheck (0.10.0)
.devcontainer/features/common/install.sh

[warning] 12-18: In POSIX sh, arrays are undefined.

(SC3030)


[warning] 21-21: In POSIX sh, array references are undefined.

(SC3054)


[warning] 34-34: In POSIX sh, array references are undefined.

(SC3054)

🔇 Additional comments (1)
.devcontainer/features/common/devcontainer-feature.json (1)

9-9: Ensure installation script execution is still wired up
The explicit "init", "entrypoint", and "args" properties have been removed and an empty options block was added. Verify that your devcontainer’s root devcontainer.json or the feature’s own runs/postCreateCommand is invoking .devcontainer/features/common/install.sh, otherwise the install script will no longer execute automatically.

Comment thread .devcontainer/features/common/install.sh Outdated
Comment thread .devcontainer/features/common/install.sh Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

./features/commonがビルド時にinstallされない

1 participant