Fixing GitLab Runner Shell Executor Permission Issues on Ubuntu 20-25

The Issue:

The error typically occurs when the GitLab Runner shell executor doesn’t have the necessary permissions to access or execute files in the /home/gitlab-runner directory. This can happen if:

  • Configuration files or hidden files (dotfiles like .bashrc or .gitlab-ci.yml) are misconfigured.
  • Improper file or directory permissions are preventing the runner from accessing required files.

The Solution:

A straightforward fix is to remove all dotfiles (.*) in the /home/gitlab-runner directory. These files might be causing the permission errors, especially if they were created or misconfigured by previous installations or processes.

Steps to Fix:

  1. SSH into your AWS Ubuntu 20.04 instance where GitLab Runner is installed.
  2. Run the following command to remove all dotfiles from the gitlab-runner home directory: sudo rm -rf /home/gitlab-runner/.* Caution: This will remove all hidden configuration files. Ensure you’re comfortable removing any files that might not be necessary.
  3. After this, the GitLab Runner should be able to run without encountering the permission error.

Why This Works:

  • The gitlab-runner service runs under its own user (gitlab-runner), and misconfigured hidden files in the home directory can prevent it from running properly.
  • Removing these files eliminates the possibility of conflicting settings or permissions, allowing the runner to work seamlessly.