mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-04 22:13:47 +00:00
rust-analyzer now requires rustup to be installed ## Motivation The previous implementation bundled rust-analyzer binaries that quickly became outdated and required manual updates to Serena's codebase. This caused version mismatches between the bundled rust-analyzer and users' actual Rust toolchain versions. ## Changes - Remove RuntimeDependency-based binary bundling for rust-analyzer - Use rustup-managed rust-analyzer from the user's toolchain - Add automatic installation of rust-analyzer component if missing - Install rustup with minimal profile in Docker images ## Rationale Rust development universally relies on rustup for toolchain management. Unlike some other languages where system packages or bundled binaries make sense, Rust developers already have rustup installed and expect tools to use their toolchain's versions. This approach ensures: - rust-analyzer always matches the user's Rust version - No outdated binaries shipped with Serena - Automatic updates via `rustup update` - Consistency with Rust ecosystem expectations The LSP API of rust-analyzer is stable enough that version differences are not a concern. If users don't have rustup, they'll get a clear error message - this is acceptable since you cannot meaningfully develop Rust without rustup. ## Docker Support Added rustup installation to Docker images to ensure Rust support works in containerized environments. Uses minimal profile to reduce image size while still providing full rust-analyzer functionality.
86 lines
2.6 KiB
Docker
86 lines
2.6 KiB
Docker
# Base stage with common dependencies
|
|
FROM python:3.11-slim AS base
|
|
SHELL ["/bin/bash", "-c"]
|
|
|
|
# Set environment variables to make Python print directly to the terminal and avoid .pyc files.
|
|
ENV PYTHONUNBUFFERED=1
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
|
|
# Install system dependencies required for package manager and build tools.
|
|
# sudo, wget, zip needed for some assistants, like junie
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
curl \
|
|
build-essential \
|
|
git \
|
|
ssh \
|
|
sudo \
|
|
wget \
|
|
zip \
|
|
unzip \
|
|
git \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install pipx.
|
|
RUN python3 -m pip install --no-cache-dir pipx \
|
|
&& pipx ensurepath
|
|
|
|
# Install nodejs
|
|
ENV NVM_VERSION=0.40.3
|
|
ENV NODE_VERSION=22.18.0
|
|
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VERSION}/install.sh | bash
|
|
# standard location
|
|
ENV NVM_DIR=/root/.nvm
|
|
RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION}
|
|
RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION}
|
|
RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION}
|
|
ENV PATH="${NVM_DIR}/versions/node/v${NODE_VERSION}/bin/:${PATH}"
|
|
|
|
# Add local bin to the path
|
|
ENV PATH="${PATH}:/root/.local/bin"
|
|
|
|
# Install the latest version of uv
|
|
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
|
|
# Install Rust and rustup for rust-analyzer support (minimal profile)
|
|
ENV RUSTUP_HOME=/usr/local/rustup
|
|
ENV CARGO_HOME=/usr/local/cargo
|
|
ENV PATH="${CARGO_HOME}/bin:${PATH}"
|
|
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
|
|
--default-toolchain stable \
|
|
--profile minimal \
|
|
&& rustup component add rust-analyzer
|
|
|
|
# Set the working directory
|
|
WORKDIR /workspaces/serena
|
|
|
|
# Development target
|
|
FROM base AS development
|
|
# Copy all files for development
|
|
COPY . /workspaces/serena/
|
|
|
|
# Create virtual environment and install dependencies with dev extras
|
|
RUN uv venv
|
|
RUN . .venv/bin/activate
|
|
RUN uv pip install --all-extras -r pyproject.toml -e .
|
|
ENV PATH="/workspaces/serena/.venv/bin:${PATH}"
|
|
|
|
# Entrypoint to ensure environment is activated
|
|
ENTRYPOINT ["/bin/bash", "-c", "source .venv/bin/activate && $0 $@"]
|
|
|
|
# Production target
|
|
FROM base AS production
|
|
# Copy only necessary files for production
|
|
COPY pyproject.toml /workspaces/serena/
|
|
COPY README.md /workspaces/serena/
|
|
COPY src/ /workspaces/serena/src/
|
|
|
|
# Create virtual environment and install dependencies (production only)
|
|
RUN uv venv
|
|
RUN . .venv/bin/activate
|
|
RUN uv pip install -r pyproject.toml -e .
|
|
ENV PATH="/workspaces/serena/.venv/bin:${PATH}"
|
|
|
|
# Entrypoint to ensure environment is activated
|
|
ENTRYPOINT ["/bin/bash", "-c", "source .venv/bin/activate && $0 $@"]
|
|
|