oraios/serena · error · SolidLSPException

Could not find language server files in package. Searched in

Error message

Could not find language server files in package. Searched in {package_path}

What it means

Raised by _extract_language_server when none of the well-known content directories (e.g. contentFiles/any/net9.0, etc.) exist inside the downloaded NuGet package, so there is no known source directory to copy the language server files from.

Source

Thrown at src/solidlsp/language_servers/csharp_language_server.py:448

        @staticmethod
        def _extract_language_server(lang_server_dep: RuntimeDependency, package_path: Path, server_dir: Path) -> None:
            """Extract language server files from downloaded package."""
            extract_path = lang_server_dep.extract_path or "lib/net9.0"
            source_dir = package_path / extract_path

            if not source_dir.exists():
                # Try alternative locations
                for possible_dir in [
                    package_path / "tools" / "net9.0" / "any",
                    package_path / "lib" / "net9.0",
                    package_path / "contentFiles" / "any" / "net9.0",
                ]:
                    if possible_dir.exists():
                        source_dir = possible_dir
                        break
                else:
                    raise SolidLSPException(f"Could not find language server files in package. Searched in {package_path}")

            # Copy files to cache directory
            server_dir.mkdir(parents=True, exist_ok=True)
            shutil.copytree(source_dir, server_dir, dirs_exist_ok=True)

        def _download_nuget_package(self, dependency: RuntimeDependency) -> Path:
            """
            Download a NuGet package from NuGet.org and extract it.
            Returns the path to the extracted package directory.
            """
            package_name = dependency.package_name
            package_version = dependency.package_version
            url = dependency.url

            if url is None:
                raise SolidLSPException(f"No URL specified for package {package_name} version {package_version}")

            package_extract_dir = Path(self._ls_resources_dir) / "temp_downloads" / f"{package_name}.{package_version}"

View on GitHub (pinned to 7fcbca7e62)

Solutions

  1. Verify the downloaded package is a genuine NuGet nupkg (it should extract to directories like 'lib', 'contentFiles') and re-download if corrupt
  2. Delete the temp download dir and retry to get a clean copy
  3. Pin to a package version whose layout matches the library's expectations (check the RuntimeDependency version)
  4. Upgrade the library so its known directory list covers the new package layout

Example fix

// before
$ unzip -l roslyn.nupkg # only 'tools/' dir, no contentFiles
// after: retry a known-good version, e.g. dependency.package_version = '4.x.x' with contentFiles/any/net9.0 layout
Defensive patterns

Strategy: validation

Validate before calling

import zipfile
from pathlib import Path

def nupkg_has_expected_layout(nupkg_path: str) -> bool:
    expected = ("contentFiles/", "lib/")
    with zipfile.ZipFile(nupkg_path) as z:
        names = z.namelist()
    return any(n.startswith(e) for n in names for e in expected)

Type guard

def package_has_content_dirs(package_path) -> bool:
    from pathlib import Path
    p = Path(package_path)
    candidates = [p / "contentFiles" / "any" / "net9.0", p / "lib" / "net9.0"]
    return any(c.is_dir() for c in candidates)

Try / catch

try:
    ls._ensure_server_installed()
except SolidLSPException as e:
    if "Could not find language server files in package" in str(e):
        shutil.rmtree(temp_download_dir, ignore_errors=True)
        ls._ensure_server_installed()  # re-download a clean package
    else:
        raise

Prevention

When it happens

Trigger: _ensure_language_server -> _extract_language_server when the extracted NuGet package at package_path contains none of the expected directories (like 'contentFiles', 'lib/net9.0', 'content/any/net9.0') — usually because the package layout differs from what the code expects.

Common situations: NuGet package structure changed between Roslyn language server versions, a wrong/corrupt file was downloaded (e.g. an HTML error page saved as .nupkg and extracted), or a proxy mirror served a different package.

Related errors


AI-assisted analysis of oraios/serena@7fcbca7e62 (2026-08-29). Data as JSON: /api/errors/111adbf54dd58a1f. Report an issue: GitHub.