I’ve experienced the same issue and solved by following.
- Located both environment.json and Dockerfile under .cursor/
- Installed sudo in Dockerfile
- Grant execution permission to bin/ scripts (bundle, rails, setup, etc.)
Dockerfile sample:
FROM ruby:3.2.2
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
ca-certificates \
curl \
git \
gnupg \
lsb-release \
openssh-client \
tzdata \
sudo \
&& rm -rf /var/lib/apt/lists/*
RUN install -d /etc/apt/keyrings \
&& curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc \
| gpg --dearmor -o /etc/apt/keyrings/postgresql.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/postgresql.gpg] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" \
> /etc/apt/sources.list.d/pgdg.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
postgresql-16 \
postgresql-client-16 \
postgresql-16-pgvector \
&& rm -rf /var/lib/apt/lists/*
RUN useradd -ms /bin/bash ubuntu
RUN echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER ubuntu
WORKDIR /home/ubuntu
ENV PATH="/home/ubuntu/.local/bin:${PATH}"