Reputation: 45174
I have the following GitHub action:
name: Rubocop
on: push
jobs:
check:
runs-on: ubuntu-latest
steps:
- name: Install Rubocop
run: gem install rubocop
- name: Rubocop
run: rubocop
When this action runs, I get the following error:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /var/lib/gems/2.5.0 directory.
How can I fix this?
Upvotes: 3
Views: 2722
Reputation: 35102
Consider using docker. If your repo is to be containerized and your Action is a test it would be better to run the test in the same docker image environment rather than some GitHub's Ubuntu:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: docker run -v $(pwd):/checkout ruby:alpine sh -c "cd checkout && gem install bundler && bundle install && bundle exec ruby test.rb"
Upvotes: 0
Reputation: 12883
Use the following as per the official GitHub Actions docs:
name: Linting
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
- run: bundle install
- name: Rubocop
run: rubocop
or if you don't have a gemfile
:
name: Linting
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
- run: gem install rubocop
- name: Rubocop
run: rubocop
sudo gem install rubocop
is another option as described in You don't have write permissions for the /var/lib/gems/2.3.0 directory
Upvotes: 7