Files
gitlab-foss/doc/user/project/troubleshooting.md
2025-07-01 15:11:54 +00:00

4.9 KiB

stage, group, info, title, description
stage group info title description
Tenant Scale Organizations To determine the technical writer assigned to the Stage/Group associated with this page, see https://handbook.gitlab.com/handbook/product/ux/technical-writing/#assignments Troubleshooting projects Problem solving, common issues, debugging, and error resolution.

When working with projects, you might encounter the following issues, or require alternate methods to complete specific tasks.

An error occurred while fetching commit data

When you visit a project, the message An error occurred while fetching commit data might be displayed if you use an ad blocker in your browser. The solution is to disable your ad blocker for the GitLab instance you are trying to access.

Find projects using an SQL query

While in a Rails console session, you can find and store an array of projects based on a SQL query:

# Finds projects that end with '%ject'
projects = Project.find_by_sql("SELECT * FROM projects WHERE name LIKE '%ject'")
=> [#<Project id:12 root/my-first-project>>, #<Project id:13 root/my-second-project>>]

Clear a project's or repository's cache

If a project or repository has been updated but the state is not reflected in the UI, you may need to clear the project's or repository's cache. You can do so through a Rails console session and one of the following:

{{< alert type="warning" >}}

Commands that change data can cause damage if not run correctly or under the right conditions. Always run commands in a test environment first and have a backup instance ready to restore.

{{< /alert >}}

## Clear project cache
ProjectCacheWorker.perform_async(project.id)

## Clear repository .exists? cache
project.repository.expire_exists_cache

Find projects that are pending deletion

If you need to find all projects marked for deletion but that have not yet been deleted, start a Rails console session and run the following:

projects = Project.where(pending_delete: true)
projects.each do |p|
  puts "Project ID: #{p.id}"
  puts "Project name: #{p.name}"
  puts "Repository path: #{p.repository.full_path}"
end

Transfer a project using console

If transferring a project through the UI or API is not working, you can attempt the transfer in a Rails console session.

p = Project.find_by_full_path('<project_path>')

# To set the owner of the project
current_user = p.creator

# Namespace where you want this to be moved
namespace = Namespace.find_by_full_path("<new_namespace>")

Projects::TransferService.new(p, current_user).execute(namespace)

Delete a project using console

If a project cannot be deleted, you can attempt to delete it through Rails console.

{{< alert type="warning" >}}

Commands that change data can cause damage if not run correctly or under the right conditions. Always run commands in a test environment first and have a backup instance ready to restore.

{{< /alert >}}

project = Project.find_by_full_path('<project_path>')
user = User.find_by_username('<username>')
Projects::DestroyService.new(project, user, {}).execute

If this fails, display why it doesn't work with:

project = Project.find_by_full_path('<project_path>')
project.delete_error

Toggle a feature for all projects within a group

While toggling a feature in a project can be done through the projects API, you may need to do this for a large number of projects.

To toggle a specific feature, you can start a Rails console session and run the following function:

{{< alert type="warning" >}}

Commands that change data can cause damage if not run correctly or under the right conditions. Always run commands in a test environment first and have a backup instance ready to restore.

{{< /alert >}}

projects = Group.find_by_name('_group_name').projects
projects.each do |p|
  ## replace <feature-name> with the appropriate feature name in all instances
  state = p.<feature-name>

  if state != 0
    puts "#{p.name} has <feature-name> already enabled. Skipping..."
  else
    puts "#{p.name} didn't have <feature-name> enabled. Enabling..."
    p.project_feature.update!(<feature-name>: ProjectFeature::PRIVATE)
  end
end

To find features that can be toggled, run pp p.project_feature. Available permission levels are listed in concerns/featurable.rb.