Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gem subdirectory not writable on ruby:3.2-bookworm #1090

Closed
luizkowalski opened this issue Jun 9, 2024 · 2 comments
Closed

Gem subdirectory not writable on ruby:3.2-bookworm #1090

luizkowalski opened this issue Jun 9, 2024 · 2 comments

Comments

@luizkowalski
Copy link

hey 👋🏻

I'm trying to use the image ruby:3.2-bookworm but I can update RubyGems using gem update --system -N, it throws this error:

ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied @ dir_s_mkdir - /usr/local/lib/ruby/site_ruby/3.2.0/rubygems
        /usr/local/lib/ruby/3.2.0/fileutils.rb:403:in `mkdir'
        /usr/local/lib/ruby/3.2.0/fileutils.rb:403:in `fu_mkdir'
        /usr/local/lib/ruby/3.2.0/fileutils.rb:384:in `block (2 levels) in mkdir_p'
        /usr/local/lib/ruby/3.2.0/fileutils.rb:382:in `reverse_each'
        /usr/local/lib/ruby/3.2.0/fileutils.rb:382:in `block in mkdir_p'
        /usr/local/lib/ruby/3.2.0/fileutils.rb:374:in `each'
        /usr/local/lib/ruby/3.2.0/fileutils.rb:374:in `mkdir_p'
        /usr/local/rvm/gems/default/gems/rubygems-update-3.5.11/lib/rubygems/commands/setup_command.rb:143:in `mkdir_p'
        /usr/local/rvm/gems/default/gems/rubygems-update-3.5.11/lib/rubygems/commands/setup_command.rb:641:in `install_file'
        /usr/local/rvm/gems/default/gems/rubygems-update-3.5.11/lib/rubygems/commands/setup_command.rb:633:in `block in install_file_list'
        /usr/local/rvm/gems/default/gems/rubygems-update-3.5.11/lib/rubygems/commands/setup_command.rb:632:in `each'

it works when I manually run sudo chown -R $(whoami):vscode /usr/local/lib/ruby/* but I don't think this is expected

Here is my Dockerfile and configurations:

FROM mcr.microsoft.com/vscode/devcontainers/ruby:3.2-bookworm

ENV RAILS_DEVELOPMENT_HOSTS=".githubpreview.dev,.app.github.dev"

RUN apt install curl ca-certificates

RUN install -d /usr/share/postgresql-common/pgdg
RUN curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
RUN sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

RUN apt update

RUN apt install postgresql-client-16 -y --no-install-recommends \
  && apt-get clean \
  && rm -rf /var/lib/apt/lists/*
{
  "name": "Project",
  "dockerComposeFile": "docker-compose.yml",
  "service": "app",
  "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
  "features": {
    "ghcr.io/devcontainers/features/common-utils:2": {
      "username": "vscode",
      "userUid": 1001,
      "userGid": 1001,
      "installZsh": true,
      "installOhMyZsh": true,
      "configureZshAsDefaultShell": true,
      "upgradePackages": true
    },
    "ghcr.io/rocker-org/devcontainer-features/apt-packages:1": {
      "packages": "libpq-dev, libvips, postgresql-client-16"
    },
    "ghcr.io/devcontainers/features/git:1": {
      "version": "latest"
    },
    "ghcr.io/devcontainers/features/node:1": {
      "version": 20
    },
    "ghcr.io/devcontainers-contrib/features/zsh-plugins:0": {
      "username": "vscode",
      "plugins": "bundler rails ruby yarn git"
    },
    "ghcr.io/devcontainers/features/sshd:1": {
      "version": "latest"
    }
  }
}
@samruddhikhandale
Copy link
Member

Hi 👋

Unfortunately, this is a known bug which is expected to be fixed by devcontainers/features#757

We also recommend using 👇 in the Templates, see here

RUN su vscode -c "gem install rails webdrivers"
RUN su vscode -c "/usr/local/rvm/bin/rvm fix-permissions"

@luizkowalski
Copy link
Author

thanks @samruddhikhandale, I'm following the issue now!

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

No branches or pull requests

2 participants