Troubleshooting the GitLab Workflow extension for VS Code

If you encounter any issues with the GitLab Workflow extension for VS Code, or have feature requests for it:

  1. Check the extension documentation for known issues and solutions.
  2. Report bugs or request features in the gitlab-vscode-extension issue queue.

For troubleshooting VS Code for GitLab Duo Code Suggestions, see Troubleshooting Code Suggestions for VS Code.

Enable debug logs

Both the VS Code Extension and the GitLab Language Server provide logs that can help you troubleshoot. To enable debug logging:

  1. In VS Code, on the top bar, go to Code > Settings > Settings.
  2. On the top right corner, select Open Settings (JSON) to edit your settings.json file.
  3. Add this line, or edit it if it already exists:

    "gitlab.debug": true,
    
  4. Save your changes.

View log files

To view debug logs from either the VS Code Extension or the GitLab Language Server:

  1. Use the command GitLab: Show Extension Logs to view the output panel.
  2. In the upper right corner of the output panel, select either GitLab Workflow or GitLab Language Server from the dropdown list.

Error: 407 Access Denied failure with a proxy

If you use an authenticated proxy, you might encounter an error like 407 Access Denied (authentication_failed):

Request failed: Can't add GitLab account for https://gitlab.com. Check your instance URL and network connection.
Fetching resource from https://gitlab.com/api/v4/personal_access_tokens/self failed

You must enable proxy authentication for the GitLab Language Server.

Configure self-signed certificates

To use self-signed certificates to connect to your GitLab instance, configure them using these settings. These settings are community contributions, because the GitLab team uses a public CA. None of the fields are required.

Prerequisites:

Setting name Default Information
gitlab.ca null Deprecated. See the SSL setup guide for more information on how to set up your self-signed CA.
gitlab.cert null Unsupported. See epic 6244. If your self-managed GitLab instance requires a custom certificate or key pair, set this option to point to your certificate file. See gitlab.certKey.
gitlab.certKey null Unsupported. See epic 6244. If your self-managed GitLab instance requires a custom certificate or key pair, set this option to point to your certificate key file. See gitlab.cert.
gitlab.ignoreCertificateErrors false Unsupported. See epic 6244. If you use a self-managed GitLab instance with no SSL certificate, or have certificate issues that prevent you from using the extension, set this option to true to ignore certificate errors.

HTTPS project cloning works but SSH cloning fails

This problem happens in VS Code when your SSH URL host or path is different from your HTTPS path. The GitLab Workflow extension uses:

  • The host to match the account that you set up.
  • The path to get the namespace and project name.

For example, the VS Code extension’s URLs are:

  • SSH: git@gitlab.com:gitlab-org/gitlab-vscode-extension.git
  • HTTPS: https://gitlab.com/gitlab-org/gitlab-vscode-extension.git

Both have the gitlab.com and gitlab-org/gitlab-vscode-extension path.

To fix this problem, check if your SSH URL is on a different host, or if it has extra segments in a path. If either is true, you can manually assign a Git repository to a GitLab project:

  1. In VS Code, on the left sidebar, select GitLab Workflow ().
  2. Select the project marked (no GitLab project), then select Manually assign GitLab project: Assign GitLab project manually
  3. Select the correct project from the list.

For more information about simplifying this process, see issue 577 in the gitlab-vscode-extension project.

Error: can't access the OS Keychain

Error messages like these can occur on both MacOS and Ubuntu:

GitLab Workflow can't access the OS Keychain.
If you use Ubuntu, see this existing issue.
Error: Cannot get password
at I.$getPassword (vscode-file://vscode-app/snap/code/97/usr/share/code/resources/app/out/vs/workbench/workbench.desktop.main.js:1712:49592)

For more information about these errors, see:

MacOS workaround

A workaround exists for MacOS:

  1. On your machine, open Keychain Access and search for vscodegitlab.gitlab-workflow.
  2. Delete vscodegitlab.gitlab-workflow from your keychain.
  3. Remove the corrupted account from VS Code using the GitLab: Remove Account from VS Code command.
  4. To add the account again, run either Gitlab: Add Account to VS Code or GitLab: Authenticate to GitLab.com.

Ubuntu workaround

When VS Code is installed with snap in Ubuntu 20.04 and 22.04, it can’t read passwords from the OS keychain that extension versions 3.44.0 and later use for secure token storage.

A workaround exists for Ubuntu users who use versions of VS Code earlier than 1.68.0:

  • You can downgrade the GitLab Workflow extension to version 3.43.1.
  • You can install VS Code from the .deb package, rather than snap:
    1. Uninstall the snap VS Code.
    2. Install VS Code from the .deb package.
    3. Go to Ubuntu’s Password & Keys, find the vscodegitlab.workflow/gitlab-tokens entry, and remove it.
    4. In VS Code, run Gitlab: Remove Your Account to remove the account with missing credentials.
    5. To add the account again, run either Gitlab: Add Account to VS Code or GitLab: Authenticate to GitLab.com.

If you use VS Code version 1.68.0 or later, re-installation might not be possible. However, you can still run the last three steps to re-authenticate.

Set token with environment variables

If you often delete your VS Code storage, such as in Gitpod containers, you can create environment variables before starting VS Code. If you set the token in a VS Code environment variable, you don’t have to set a personal access token each time you delete your VS Code storage. Set these variables:

  • GITLAB_WORKFLOW_INSTANCE_URL: Your GitLab instance URL, like https://gitlab.com.
  • GITLAB_WORKFLOW_TOKEN: Your personal access token, which you created when authenticating with GitLab.

The token configured in an environment variable is overridden if you configure a token for the same GitLab instance in the extension.