Runner as shell unable to use sudo

Right now I am using tags to identify whether a specific runner has all the software installed required for a build. However, I already see this becoming hard to manage and thus I wanted to simply install the required software if necessary using before_script.

As the use of apt-get or other privileged commands is important for my plans, I will need to use sudo, which according to #248 (closed) should not be a problem, however I experienced the following:

gitlab-ci-multi-runner 1.1.0~beta.267.g45c32b1 (45c32b1)
Using Shell executor...
...
...
...
$ sudo apt-get update && sudo apt-get upgrade -y
sudo: no tty present and no askpass program specified
$ whoami
gitlab-runner
$ sudo apt-get install htop
sudo: no tty present and no askpass program specified

ERROR: Build failed: exit status 1

Now, I googled a little bit (as I have no experience with sudo etc. usually it just works for me) and if I got it right, I might just need to set some permissions and this issue is resolved.

However, what I don't get is why this is at all required, as it appears something like this was not necessary in the above stated issue.

If desired, my demo .gitlab-ci.yml looks like this:

before_script:
 - sudo apt-get update && sudo apt-get upgrade -y
 
stages:
 - first_stage
 
job:
 stage: first_stage
 script:
  - whoami
  - sudo apt-get install htop

And the runners configuration looks like this:

[[runners]]
  name = "RUNNER"
  url = "URL"
  token = "SECRET"
  executor = "shell"
  [runners.ssh]
  [runners.docker]
    tls_verify = false
    image = ""
    privileged = false
    disable_cache = false
  [runners.parallels]
    base_name = ""
    disable_snapshots = false
  [runners.virtualbox]
    base_name = ""
    disable_snapshots = false
  [runners.cache]
    Insecure = false

Hope you can help me out here! (: /cc @ayufan