2

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?

Jason Swett
  • 41,074
  • 64
  • 208
  • 335

1 Answers1

6

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

riQQ
  • 6,571
  • 4
  • 32
  • 48