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::FilePermissionError: You don't have write permissions for the /usr/local/bundle directory #355

Closed
alexbrebu opened this issue Jul 27, 2021 · 3 comments

Comments

@alexbrebu
Copy link

macOS Big Sur
Version 11.5.1


Docker version 20.10.7, build f0df35096d
docker-compose version 1.29.2, build unknown
docker-machine version 0.16.2, build bd45ab1
Dinghy 4.6.5


I have created this Dockerfile:

FROM ruby:2.7.4-alpine

RUN apk add build-base tzdata postgresql-dev postgresql-client

WORKDIR /usr/src/app
COPY Gemfile* ./
RUN bundle install

# Add a script to be executed every time the container starts.
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 3000

COPY . .

CMD ["rails", "server", "-b", "0.0.0.0"]

The error occurs when running the bundle install:

Building api
Sending build context to Docker daemon  438.8kB
Step 1/11 : FROM ruby:2.7.4-alpine
 ---> edd3dc5af692
Step 2/11 : RUN apk add build-base tzdata postgresql-dev postgresql-client
 ---> Using cache
 ---> 7370fb782090
Step 3/11 : WORKDIR /usr/src/app
 ---> Running in 4f66666b84ac
Removing intermediate container 4f66666b84ac
 ---> 20cc36d2f120
Step 4/11 : COPY Gemfile* ./
 ---> 63eee2b21da9
Step 5/11 : RUN bundle install
 ---> Running in e13ccb87957b
`/root` is not writable.
Bundler will use `/tmp/bundler20210727-1-1x1ft1f1' as your home directory temporarily.
Fetching gem metadata from https://rubygems.org/..........
Fetching rake 13.0.6
Installing rake 13.0.6
Gem::FilePermissionError: You don't have write permissions for the
/usr/local/bundle directory.
An error occurred while installing rake (13.0.6), and Bundler cannot continue.
Make sure that `gem install rake -v '13.0.6' --source 'https://rubygems.org/'`
succeeds before bundling.

In Gemfile:
  annotate was resolved to 3.1.1, which depends on
    rake
The command '/bin/sh -c bundle install' returned a non-zero code: 5
ERROR: Service 'api' failed to build : Build failed
@alexbrebu
Copy link
Author

The weird thing is that it does not return any error when run from a Linux setup

@frozenfoxx
Copy link

Did you solve this? I'm having this issue when using this container with Drone.io.

@alexbrebu
Copy link
Author

alexbrebu commented Aug 16, 2021

I closed the issue because I saw a discussion ongoing on this topic here and I left it as comment there

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