DEV Community

abbazs
abbazs

Posted on

How to install glab CLI for GitLab on Ubuntu using apt?

How to install glab CLI for GitLab on Ubuntu using apt?

Step 1: Add the GitLab package repository GPG key

The first step is to add the GitLab package repository GPG key to your system's trusted keys. This can be done using the following command:

curl -L https://packages.gitlab.com/glab/glab/gpgkey | sudo apt-key add -
Enter fullscreen mode Exit fullscreen mode

Step 2: Add the GitLab package repository to your system's package sources list

The next step is to add the GitLab package repository to your system's package sources list. You can do this by running the following command:

sudo curl -o /etc/apt/sources.list.d/glab.list https://packages.gitlab.com/glab/glab/ubuntu/$(lsb_release -cs)/glab.list
Enter fullscreen mode Exit fullscreen mode

Step 3: Update your package list

Once you've added the GitLab package repository to your system's package sources list, you'll need to update your package list to include the newly added repository. You can do this using the following command:

sudo apt update
Enter fullscreen mode Exit fullscreen mode

Step 4: Install the glab CLI package

With the package repository added and the package list updated, you can now install the glab CLI package using apt. To do this, run the following command:

sudo apt install glab
Enter fullscreen mode Exit fullscreen mode

Step 5: Verify the installation

Finally, you can verify that the glab CLI was installed successfully by running the following command:

glab version
Enter fullscreen mode Exit fullscreen mode

This should display the version number of the glab CLI that you just installed.

Single code block:

curl -L https://packages.gitlab.com/glab/glab/gpgkey | sudo apt-key add -
sudo curl -o /etc/apt/sources.list.d/glab.list https://packages.gitlab.com/glab/glab/ubuntu/$(lsb_release -cs)/glab.list
sudo apt update
sudo apt install -y glab
glab version
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
dancingquanta profile image
Andrew Tolmie

hi I have issue with step 1 and step 2:

Please see the commands and their results below

12:07:08 [Andrew:~/test/] [base] main* 100 ±
-> curl -L https://packages.gitlab.com/glab/glab/gpgkey | sudo apt-key add -
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    31  100    31    0     0    128      0 --:--:-- --:--:-- --:--:--   128
gpg: no valid OpenPGP data found.
12:08:09 [Andrew:~/test/] [base] main* 2 ±
-> sudo curl -o /etc/apt/sources.list.d/glab.list https://packages.gitlab.com/glab/glab/ubuntu/$(lsb_release -cs)/glab.list
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1351  100  1351    0     0   6558      0 --:--:-- --:--:-- --:--:--  6558
12:09:43 [Andrew:~/test/] [base] main* ±
-> sudo apt update
E: Type '<!DOCTYPE' is not known on line 1 in source list /etc/apt/sources.list.d/glab.list
E: The list of sources could not be read.
Enter fullscreen mode Exit fullscreen mode

Can you advise please?

Collapse
 
perlun profile image
Per Lundberg

I'm also seeing the same problem. Just running curl -L https://packages.gitlab.com/glab/glab/gpgkey gives me Incorrect username or API token, so it doesn't seem the package source can be used this way.