Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B buck
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 201
    • Issues 201
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 22
    • Merge requests 22
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • buck
  • Issues
  • #2462
Closed
Open
Issue created May 10, 2020 by Administrator@rootContributor

Infinite loop when installing Buck if not in VCS repository root

Created by: elldritch

When buck is installed in a folder that's not either a Git or Mercurial repository root, the installer goes into an infinite loop.

To reproduce:

git clone --depth 1 https://github.com/facebook/buck.git
cd buck
mv .git .git-bak
ant

This will cause the build to hang at the gen-buck-info step.

Root cause

The root cause here is a bug in how programs/gen_buck_info.py attempts to detect the repository root. Here's the relevant excerpt: https://github.com/facebook/buck/blob/c5272997533a308face95d34e1e4a223691dd687/programs/gen_buck_info.py#L49-L63

If the current working directory is not a VCS repository root, the while loop on line 54 attempts to traverse upwards in the filesystem until it either finds a VCS repository root (vcs_module is not None) or reaches the filesystem root (os.path.dirname(path) == path).

However, when trying to find the VCS repository, an inner loop also attempts to find the Buck repository root by searching for a .buckconfig. This inner loop does NOT check that it stops at the filesystem root, and will loop infinitely if it does not find a .buckconfig.

When running ant in a directory that's not a VCS repository root, programs/gen_buck_info.py will:

  1. Search the current working directory for a .buckconfig, and find the .buckconfig (line 55).
  2. Search the current working directory for a VCS repository root, and fail to find one (lines 57-60).
  3. Mutate the search path to the current path's parent (lines 61-63).
  4. Search the parent for a .buckconfig, and fail to find one (line 55).
  5. Loop infinitely while searching parent folders for a .buckconfig (lines 55-56).

The fix

This code appears to be checking for a VCS in order to infer a Buck version from the VCS history. I'm not sure why it checks for a .buckconfig - perhaps to try and ensure that the VCS repository is also the Buck repository?

I'm happy to submit a PR to fix this, but would like some guidance in the correct behaviour here. I think the right answer is to remove the .buckconfig check in lines 55-56, because the existence of a .buckconfig doesn't really tell you anything about whether the repository is the "correct" one to be getting a version from.

Assignee
Assign to
Time tracking