phacility/phabricator · warning · PhutilArgumentUsageException

Path "%s" contains no libphutil libraries.

Error message

Path "%s" contains no libphutil libraries.

What it means

A PhutilArgumentUsageException from 'bin/i18n extract'. After confirming each path is a directory, the command searches it with FileFinder for files named '__phutil_library_init__.php' — the marker of a phutil library root. If none exist anywhere under the path, there is nothing to extract from, so the command aborts.

Source

Thrown at src/infrastructure/internationalization/management/PhabricatorInternationalizationManagementExtractWorkflow.php:50

      $paths = array(getcwd());
    }

    $targets = array();
    foreach ($paths as $path) {
      $root = Filesystem::resolvePath($path);

      if (!Filesystem::pathExists($root) || !is_dir($root)) {
        throw new PhutilArgumentUsageException(
          pht(
            'Path "%s" does not exist, or is not a directory.',
            $path));
      }

      $libraries = id(new FileFinder($path))
        ->withPath('*/__phutil_library_init__.php')
        ->find();
      if (!$libraries) {
        throw new PhutilArgumentUsageException(
          pht(
            'Path "%s" contains no libphutil libraries.',
            $path));
      }

      foreach ($libraries as $library) {
        $targets[] = Filesystem::resolvePath(dirname($path.'/'.$library)).'/';
      }
    }

    $targets = array_unique($targets);

    foreach ($targets as $library) {
      echo tsprintf(
        "**<bg:blue> %s </bg>** %s\n",
        pht('EXTRACT'),
        pht(
          'Extracting "%s"...',

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Run the command against a directory that contains (at any depth) a __phutil_library_init__.php, typically the phabricator checkout root
  2. If extracting your own library, initialize it first with libphutil's library initialization so the marker file exists
  3. Check sparse-checkout/rsync filters are not excluding the marker file

Example fix

# before: directory has no phutil library
$ bin/i18n extract /tmp/notalibrary

# after: point at a real library root
$ bin/i18n extract /srv/phabricator
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the target actually contains a phutil library before extracting.
$found = id(new FileFinder($path))
  ->withPath('*/__phutil_library_init__.php')
  ->find();
if (!$found) {
  fwrite(STDERR, "No __phutil_library_init__.php under {$path}\n");
  exit(1);
}

Type guard

function containsPhutilLibrary($path) {
  return (bool)id(new FileFinder($path))
    ->withPath('*/__phutil_library_init__.php')
    ->find();
}

Try / catch

try { $workflow->execute($args); } catch (PhutilArgumentUsageException $ex) { fwrite(STDERR, $ex->getMessage()."\n"); exit(1); }

Prevention

When it happens

Trigger: Pointing the extractor at a plain directory tree that is not a phutil/arcanist library (no __phutil_library_init__.php); extracting against a bare git checkout of a non-library project.

Common situations: Running i18n extract over a random project directory instead of the phabricator (or arcanist/libphutil) source tree; extracting against a directory where the library marker file was excluded by a sparse checkout or .gitignore.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/97ddc07a9a8b345d. Report an issue: GitHub.