Gitlab Runner Error: sudo: no tty present and no askpass program specified
Category : How-to
After issuing the first build on a dynamically created Container I came across the following build error when running a command with sudo.
sudo: no tty present and no askpass program specified
The error is caused by trying to run a command with sudo, however the calling user has not been authorised to use sudo. The error isn’t helpful, and doesn’t really spell out where to go, but adding the calling user to the sudoers file will save the day.
Solution
Open up the sudoers file for editing in your favorite editor.
vi /etc/sudoers
And add your gitlab runner user to the bottom. If you installed your gitlab runner from the official apt repositories then your gitlab-runner process will run under the gitlab-runner user.
Add the following to the bottom of the file:
gitlab-runner ALL=(ALL) NOPASSWD: ALL
Retry your build and you should be back in business!