oraios/serena · error · RuntimeError

This appears to be a Bundler project, but solargraph is not

Error message

This appears to be a Bundler project, but solargraph is not available. Please add 'gem "solargraph"' to your Gemfile and run 'bundle install'.

What it means

Raised by Solargraph's _setup_runtime_dependencies when the repository looks like a Bundler project (a Gemfile exists) but the solargraph gem is not available via bundle. The library refuses to fall back to a global gem install because a Bundler project must resolve the server through its own Gemfile for version consistency.

Source

Thrown at src/solidlsp/language_servers/solargraph.py:196

            ]

            dependency = runtime_dependencies[0]
            try:
                result = subprocess_run(
                    ["gem", "list", "^solargraph$", "-i"], check=False, capture_output=True, text=True, cwd=repository_root_path
                )
                if result.stdout.strip() == "false":
                    log.info("Installing Solargraph...")
                    subprocess_run(dependency["installCommand"].split(), check=True, capture_output=True, cwd=repository_root_path)

                return "gem exec solargraph"
            except subprocess.CalledProcessError as e:
                error_msg = e.stderr.decode() if e.stderr else str(e)
                raise RuntimeError(
                    f"Failed to check or install Solargraph: {error_msg}\nPlease try installing manually: gem install solargraph"
                ) from e
        else:
            raise RuntimeError(
                "This appears to be a Bundler project, but solargraph is not available. "
                "Please add 'gem \"solargraph\"' to your Gemfile and run 'bundle install'."
            )

    @staticmethod
    def _detect_rails_project(repository_root_path: str) -> bool:
        """
        Detect if this is a Rails project by checking for Rails-specific files.
        """
        rails_indicators = [
            "config/application.rb",
            "config/environment.rb",
            "app/controllers/application_controller.rb",
            "Rakefile",
        ]

        for indicator in rails_indicators:
            if os.path.exists(os.path.join(repository_root_path, indicator)):

View on GitHub (pinned to 7fcbca7e62)

Solutions

  1. Add `gem "solargraph"` to the Gemfile and run `bundle install`.
  2. Verify availability with `bundle exec solargraph --version` from the repo root.
  3. If solargraph is in a group, run `bundle install` with that group enabled (e.g. `bundle config set --local with development`).
  4. If the Gemfile is unrelated to this workspace, run the server from the correct project root or remove the stray Gemfile.

Example fix

// before
# Gemfile
# (no solargraph)
// after
# Gemfile
gem "solargraph", group: :development
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
import subprocess
gemfile = Path(repo_root) / "Gemfile"
if gemfile.exists():
    r = subprocess.run(["bundle", "exec", "solargraph", "--version"], cwd=repo_root, capture_output=True, text=True)
    if r.returncode != 0:
        subprocess.run(["bundle", "install"], cwd=repo_root, check=True)

Type guard

def bundler_solargraph_ready(repo_root: str) -> bool:
    import subprocess
    from pathlib import Path
    if not (Path(repo_root) / "Gemfile").exists():
        return True
    return subprocess.run(
        ["bundle", "exec", "solargraph", "--version"],
        cwd=repo_root, capture_output=True
    ).returncode == 0

Try / catch

try:
    server = SolargraphLanguageServer(config, repo_root, settings)
except RuntimeError as e:
    if "Bundler project" in str(e):
        subprocess.run(["bundle", "add", "solargraph"], cwd=repo_root, check=True)
        subprocess.run(["bundle", "install"], cwd=repo_root, check=True)
        server = SolargraphLanguageServer(config, repo_root, settings)
    else:
        raise

Prevention

When it happens

Trigger: Starting the Solargraph server on a repo containing a Gemfile where solargraph was never added, or was added but `bundle install` was never run, or it's in a non-default gem group/section that bundle exec doesn't load.

Common situations: Cloning a Ruby project without following its README setup, solargraph listed only in a dev group on a machine bundling without that group, or a stale Gemfile.lock.

Related errors


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