feat: add Rust toolchain to devcontainer - #109
Conversation
Rustツールチェーンとsimilarity-tsパッケージを追加し、開発環境を拡張しました。 - rustupとcargoのインストール - rustfmtとclippyコンポーネントの追加 - similarity-tsパッケージのインストール - 必要な依存パッケージの追加(build-essential, pkg-config等) 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
WalkthroughUpdates .devcontainer/Dockerfile to pivot from Node/npm global tooling toward a Rust-centric environment: adds system build deps, sets up rustup with stable toolchain plus rustfmt/clippy, installs a Cargo package, adjusts PATH and env vars for Cargo, keeps pnpm but removes several global npm tools, and adds Cursor agent install. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
.devcontainer/Dockerfile (3)
3-3: Trim image size and harden apt stepUse --no-install-recommends and clean apt lists to reduce layer size and improve reproducibility.
If you publish this image via .github/workflows/docker-image.yml (per your past practice), ensure BuildKit cache is enabled to benefit from Rust/Cargo layers.
-RUN apt-get update && apt-get install -y curl git alsa-utils sox build-essential pkg-config libssl-dev libasound2-dev \ +RUN apt-get update && apt-get install -y --no-install-recommends curl git alsa-utils sox build-essential pkg-config libssl-dev libasound2-dev \ && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ - && apt-get install -y nodejs + && apt-get install -y --no-install-recommends nodejs \ + && rm -rf /var/lib/apt/lists/*
14-14: Avoid duplicating PATH mutationsPATH already includes CARGO_HOME/bin via ENV; echoing another PATH export into .bashrc is redundant and can cause PATH bloat.
- && echo "export PATH=\"\$CARGO_HOME/bin:\$PATH\"" >> /home/vscode/.bashrc \Also applies to: 20-20
21-22: Pin and slim rustup installGood call adding rustfmt and clippy. For reproducibility and faster installs, add --profile minimal and consider pinning toolchain via a rust-toolchain.toml or ARG.
- && curl -sSf https://sh.rustup.rs | bash -s -- -y --default-toolchain stable \ + && curl -sSf https://sh.rustup.rs | bash -s -- -y --profile minimal --default-toolchain stable \Optionally, add a rust-toolchain.toml to the repo so rustup auto-installs the exact version.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
.devcontainer/Dockerfile(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: keito4/config#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-29T14:37:56.575Z
Learning: Applies to .github/workflows/docker-image.yml : Maintain DevContainer image build workflow at .github/workflows/docker-image.yml with semantic versioning and multi-platform support
📚 Learning: 2025-08-29T14:37:56.575Z
Learnt from: CR
PR: keito4/config#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-29T14:37:56.575Z
Learning: Applies to .github/workflows/docker-image.yml : Maintain DevContainer image build workflow at .github/workflows/docker-image.yml with semantic versioning and multi-platform support
Applied to files:
.devcontainer/Dockerfile
| ENV RUSTUP_HOME="/home/vscode/.rustup" | ||
| ENV CARGO_HOME="/home/vscode/.cargo" | ||
| ENV PATH="${CARGO_HOME}/bin:${PNPM_HOME}:${PATH}" |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Global CARGO_HOME/RUSTUP_HOME point into /home/vscode
Setting these globally means subsequent root RUN steps may write root-owned files under /home/vscode. This interacts with the cargo install below.
Either (a) run all cargo/rustup operations as vscode, or (b) override/unset these ENV vars before running root-only steps. See fix on Lines 29-30.
🏁 Script executed:
#!/bin/bash
# Inspect the Dockerfile content around the env settings and user context
sed -n '1,60p' .devcontainer/Dockerfile
# Check for any USER directives (to see if subsequent steps switch to non-root)
grep -n '^USER ' .devcontainer/Dockerfile || true
# Locate any cargo install commands (to see if they're run as root)
grep -n 'cargo install' .devcontainer/Dockerfile || trueLength of output: 2778
Run the cargo install step under USER vscode or clear CARGO_HOME/RUSTUP_HOME before switching to root
Global CARGO_HOME/RUSTUP_HOME persist into the root context, so the RUN cargo install similarity-ts on .devcontainer/Dockerfile (around lines 25–30) will write root-owned files into /home/vscode/.cargo. Either move that RUN back under USER vscode or unset/override those ENV vars immediately before the root-level cargo install.
🤖 Prompt for AI Agents
In .devcontainer/Dockerfile around lines 12–14 and the subsequent cargo install
at ~25–30, CARGO_HOME/RUSTUP_HOME are set to /home/vscode and persist into the
root context, causing root-owned files when running RUN cargo install
similarity-ts; to fix, either move the RUN cargo install so it executes while
USER vscode is active (i.e., run it before switching to root or explicitly run
that layer under USER vscode), or immediately before the root-level cargo
install unset or override CARGO_HOME and RUSTUP_HOME (or point them to root's
paths) so the install writes to root-owned directories. Ensure the chosen change
prevents writing into /home/vscode as root.
| RUN cargo install similarity-ts | ||
|
|
There was a problem hiding this comment.
Fix root-owned Cargo install into /home/vscode
cargo install currently runs as root while CARGO_HOME=/home/vscode/.cargo, creating root-owned files the vscode user cannot manage.
-RUN cargo install similarity-ts
+USER vscode
+# Install as non-root to keep ~/.cargo owned by vscode and lock deps for reproducibility
+RUN bash -lc 'cargo install --locked similarity-ts'
+USER root🤖 Prompt for AI Agents
In .devcontainer/Dockerfile around lines 29-30, cargo install is being executed
as root while CARGO_HOME is /home/vscode/.cargo, producing root-owned files; run
the install as the vscode user (or set --root to /home/vscode/.cargo) so files
are owned by vscode. Modify the Dockerfile to either set ENV
CARGO_HOME=/home/vscode/.cargo && USER vscode before the RUN cargo install step
(then switch back to root if needed), or invoke cargo install with --root
/home/vscode/.cargo and ensure ownership is chowned to vscode afterward.
|
🎉 This PR is included in version 1.1.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Rustツールチェーンとsimilarity-tsパッケージを追加し、開発環境を拡張しました。
🤖 Generated with Claude Code
Summary by CodeRabbit