Skip to content

feat: add Rust toolchain to devcontainer - #109

Merged
keito4 merged 1 commit into
mainfrom
feat/add-rust-toolchain
Sep 3, 2025
Merged

feat: add Rust toolchain to devcontainer#109
keito4 merged 1 commit into
mainfrom
feat/add-rust-toolchain

Conversation

@keito4

@keito4 keito4 commented Sep 3, 2025

Copy link
Copy Markdown
Owner

Rustツールチェーンとsimilarity-tsパッケージを追加し、開発環境を拡張しました。

  • rustupとcargoのインストール
  • rustfmtとclippyコンポーネントの追加
  • similarity-tsパッケージのインストール
  • 必要な依存パッケージの追加(build-essential, pkg-config等)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated development container to include Rust toolchain (rustup, cargo) with rustfmt and clippy for improved developer tooling.
    • Added essential system libraries to broaden build capabilities during local development.
    • Streamlined PATH and environment setup; reduced reliance on global npm packages while retaining pnpm as needed.
    • Installed additional Rust-based utilities and integrated Cursor agent into the dev environment.
    • Removed obsolete AI tooling and hooks, simplifying bootstrap steps and reducing setup overhead for contributors.

Rustツールチェーンとsimilarity-tsパッケージを追加し、開発環境を拡張しました。

- rustupとcargoのインストール
- rustfmtとclippyコンポーネントの追加
- similarity-tsパッケージのインストール
- 必要な依存パッケージの追加(build-essential, pkg-config等)

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 3, 2025

Copy link
Copy Markdown

Walkthrough

Updates .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

Cohort / File(s) Summary
System packages and base tooling
.devcontainer/Dockerfile
Adds apt packages: build-essential, pkg-config, libssl-dev, libasound2-dev.
Rust toolchain setup
.devcontainer/Dockerfile
Introduces RUSTUP_HOME and CARGO_HOME, installs rustup stable, adds rustfmt and clippy, updates PATH to include CARGO_HOME/bin, installs a Cargo tool (similarity-ts).
Node/pnpm adjustments
.devcontainer/Dockerfile
Retains pnpm setup but removes global npm installs (typescript, eslint, @anthropic-ai/claude-code, @openai/codex, vercel). Removes PNPM_HOME ENV declaration; PATH now includes PNPM_HOME via combined setting.
Editor/agent integration
.devcontainer/Dockerfile
Adds installation of Cursor agent for the vscode user.
Cleanup of prior integrations
.devcontainer/Dockerfile
Removes Claude/Codex-related configs, commands, agents, Husky bootstrap, and default shell changes. Simplifies user/root switching steps and environment scaffolding.
Environment variables
.devcontainer/Dockerfile
Removes ENV PNPM_HOME declaration; adds ENV RUSTUP_HOME and ENV CARGO_HOME; modifies ENV PATH to: ${CARGO_HOME}/bin:${PNPM_HOME}:${PATH}.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

I hop through Docker’s gentle fields,
Trading npm trails for rusted shields.
Cargo’s bins now line the burrow,
Clippy chirps, “Your code’s not furrowed!”
Cursor hums, a friendly guide—
In this dev warren, I bounce with pride. 🐇🛠️

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/add-rust-toolchain

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@keito4 keito4 self-assigned this Sep 3, 2025
@keito4
keito4 merged commit 672f93c into main Sep 3, 2025
2 of 3 checks passed

@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 (3)
.devcontainer/Dockerfile (3)

3-3: Trim image size and harden apt step

Use --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 mutations

PATH 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 install

Good 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 63b55f5 and 9e636f2.

📒 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

Comment thread .devcontainer/Dockerfile
Comment on lines +12 to +14
ENV RUSTUP_HOME="/home/vscode/.rustup"
ENV CARGO_HOME="/home/vscode/.cargo"
ENV PATH="${CARGO_HOME}/bin:${PNPM_HOME}:${PATH}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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 || true

Length 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.

Comment thread .devcontainer/Dockerfile
Comment on lines +29 to +30
RUN cargo install similarity-ts

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

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.

@github-actions

github-actions Bot commented Sep 5, 2025

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.1.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released リリース済み

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant