Skip to content

Methods from Solargraph plugin gems don't reliably appear - #1407

Draft
apiology wants to merge 63 commits into
castwide:masterfrom
apiology:load-plugins-when-caching-gems
Draft

apiology wants to merge 63 commits into
castwide:masterfrom
apiology:load-plugins-when-caching-gems

Conversation

@apiology

@apiology apiology commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Claude: This PR was written by Claude Code on behalf of @apiology.

Problem:

  • Method pins from Solargraph plugin gems (the plugins: list in .solargraph.yml) sometimes don't show up, in the editor or in solargraph typecheck.
  • After a Solargraph plugin gem is added or upgraded, Solargraph keeps serving the old cached pins.

Causes:

  • The language server caches gems in a subprocess that ignores the workspace's plugins, while solargraph typecheck loads them; both write one cache, so whichever caches a gem first wins.
  • The gem's cache key doesn't include Solargraph plugin gems or their versions, so after one is added, removed or upgraded, Solargraph keeps reading pins built under the old set, and nothing rebuilds them until the cache is cleared.

Neither was a problem prior to #1378 (released in 0.62.0), which started using the local Solargraph plugin hook on gems as well as workspace files.

Solution:

The caching subprocess now loads the workspace's Solargraph plugin gems, and a gem's cache key includes those gems and their versions, so each workspace caches gems under its own set.

castwide and others added 24 commits September 28, 2026 23:57
…de#1379)

* RbsCollection

* Gem caching in External spec

* RbsCollection specs

* Stale code

* Linting
The no-YARD gem mapper lost pins that YARD used to produce:

* Mixins called on an explicit receiver. Only receiverless include/extend/prepend
  were mapped, so ActiveSupport's `Object.prepend(self)` (which is how
  `require_dependency` reaches every class) and
  `Integer.prepend ActiveSupport::NumericWithFormat` made all the methods those
  modules add to core classes invisible.

* ActiveSupport's `class_attribute`, whose accessors are created at run time.
  Rails documents them with `## :singleton-method:` comment directives that YARD
  turned into methods. `process_class_attribute` generates the same accessors and
  honors instance_accessor/instance_reader/instance_writer/instance_predicate.

Fixes several solargraph-rails definitions (require_dependency on ActiveJob,
Rails::Application, ActionDispatch::Routing::Mapper and ActiveRecord; ActionController
callbacks; ActiveRecord::Base.enumerate_columns_in_select_statements;
ActiveRecord::Base#signed_id_verifier_secret; Integer#to_formatted_s).
External now selects collection entries for the gems it loads, but the lookup
expected a collection directory whose version matches the installed gem. Two
kinds of signature sets were silently dropped:

* Gems whose signatures are published under a different version than the gem.
  gem_rbs_collection ships `actionpack/6.0` for every Rails 6 and 7 release and
  `devise/4.9` for Devise 4 and 5, so actionpack 7.0.10 and devise 5.0.4 got no
  signatures at all (this is what hid the ActionController callback DSL).
  RbsCollection#best_key now falls back to the closest version the collection
  provides for that gem, preferring the highest one that does not exceed it.

* Stdlib entries in the lockfile (`date/0`, `json/0`, ...). They are not
  associated with a gem in the bundle, and `rbs collection install` resolves
  them to the signatures that ship with the rbs gem instead of copying them into
  the collection directory, so they can never be matched by a gem lookup.
  RbsCollection#stdlib_names exposes them and External loads them with
  Collection::Stdlib, which restores e.g. `Date#xmlschema -> String`.

Also guards External#rbs_collection_lockfile against a nil directory, which
previously short-circuited before the collection was touched.
Gem pins are mapped from gem source and serialized, so a plugin's
conventions shape what lands in the gem cache. The language server
caches gems by running `solargraph cache` in a subprocess, which never
loaded the workspace's plugins, so the cache it wrote could differ from
the one an in-process typecheck builds.

`cache` and `uncache` now require the plugins configured for the
directory, through a Workspace::Config#require_plugins that Workspace
also delegates to. Each loaded plugin and its gem version are recorded
in CacheDir, and gem_dir includes them, so loading or upgrading a
plugin rebuilds the gem cache instead of reusing pins made without it.

The @sg-ignore in CacheDir.add_plugin records a typecheck defect:
Hash#each_value.find types the block parameter as the value type
unioned with the hash itself.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhUSLUimEYJyCZv8NdQGKb
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SEntZKsZwQHhzqcwG7MTqn
@apiology
apiology marked this pull request as draft October 29, 2026 15:00
@apiology apiology changed the title [regression fix] Give gem caches the workspace's plugins [regression fix] Load Solargraph plugin gems when caching gems Oct 29, 2026
apiology and others added 2 commits October 29, 2026 12:30
Config#require_plugins and the private Shell helper have the side
effect of requiring plugins and recording them in the gem cache key;
the bang marks that.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LTpguHqALFufF4QdNagq1C
@apiology
apiology marked this pull request as ready for review November 5, 2026 18:45
@apiology apiology changed the title [regression fix] Load Solargraph plugin gems when caching gems Show plugin-added gem methods in the editor Nov 11, 2026
@apiology apiology changed the title Show plugin-added gem methods in the editor Include Solargraph plugin gems' pins in every gem cache Nov 11, 2026
@apiology apiology changed the title Include Solargraph plugin gems' pins in every gem cache Methods from Solargraph plugin gems don't reliably appear Nov 11, 2026
@apiology
apiology marked this pull request as draft November 11, 2026 20:33
apiology and others added 11 commits November 11, 2026 16:04
Master's library spec now has its own #cache_next_gemspec group,
cache_next_gemspec no longer checks Yardoc.processing?, and
unloaded_gems is a Set. Give the plugin example its own group name,
drop the unused stub and return a Set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LTpguHxFEQL9KJ7MGedKby
The language server passes the plugins its workspace loaded with
--plugins. A plugin the subprocess could not load was only warned
about and left out of the gem cache key, so the subprocess cached
the gem where the server never reads it. Exit with an error instead.
Plugins read from .solargraph.yml still only warn, as the workspace
does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LTpguHxFEQL9KJ7MGedKby
When the cache subprocess succeeds but its gem cache key differs
from the workspace's, the gem stays uncached and the server ran the
same command again without end. Record it as a cache error, naming
the directory it expected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LTpguHxFEQL9KJ7MGedKby
$/solargraph/documentGems ran the gems command with no --directory or
--plugins, so it keyed the gem cache on the server's working directory
instead of each workspace. Run it once per workspace with the plugins
that workspace loaded, as the background gem caching does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LTpguHxFEQL9KJ7MGedKby
Cache a gem with a fixture plugin whose convention adds a pin to every
mapped file, then read the cache for that plugin set: the pin is
there, and absent from the cache built without the plugin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LTpguHxFEQL9KJ7MGedKby
castwide#1400, merged in from master, stops flagging
argument forwarding, so the castwide#1108 sg-ignores on
the Collection::Gem.load and uncache calls report as unneeded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LTpguHxFEQL9KJ7MGedKby
The merge of load-plugins-when-caching-gems took the plain names,
undoing its rename. Requiring plugins is still a side effect, so use
require_plugins! again for Workspace, Workspace::Config (instance and
class method) and the Shell helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LTpguHxFEQL9KJ7MGedKby
What .solargraph.yml lists under plugins was called paths and
plugin_paths. Call it plugins: the require_plugins! parameter and
Workspace#plugins, and document that each entry is a require path,
usually the plugin gem's name. The hash of loaded plugin gem names
and versions that keys the gem cache, formerly Workspace#plugins,
becomes plugin_versions in Workspace, External, Collection::Gem,
CacheDir.gem_dir and Shell.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LTpguHxFEQL9KJ7MGedKby
The plugin_versions YARD defined the term by itself. Say what the
hash holds: Solargraph plugin gem name to version, nil when the
plugin was not loaded from a gem, with the full definition on
Workspace#plugin_versions. Rename DocumentGems#commands to
commands_by_workspace and document that it returns one argv per
workspace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LTpguHxFEQL9KJ7MGedKby
@apiology
apiology marked this pull request as ready for review November 12, 2026 18:59
A Workspace with no directory has no workspace config of its own to
name plugins (where an empty directory loads no .solargraph.yml, its
plugin_versions are empty), so its ApiMap read the plain gems cache
directory even when the process had loaded a plugin by require. The
solargraph gems command, run where .solargraph.yml lists that plugin,
writes to the plugin-keyed directory, so solargraph-rspec specs found
no cached gems and lost RSpec completions.

Such a workspace now also keys on the gems that define the registered
conventions (Convention.plugin_versions), which matches the key
Config.require_plugins! gives the same plugin gem. Workspaces with a
directory still key only on their configured plugins.
@apiology
apiology marked this pull request as draft November 18, 2026 16:20
apiology and others added 7 commits November 18, 2026 11:40
CI runs the suite with solargraph-rspec loaded, so a configless
workspace also keys on it. Check only that the probe plugin is in the
key.
castwide master added solargraph bundle, which caches every bundled gem
but read and wrote the plain gems directory. A workspace whose
.solargraph.yml lists plugins reads the plugin-keyed directory, so
gems cached by solargraph bundle looked missing there, as in the
solargraph-rspec plugin specs. Pass the plugins it requires to
Collection::Gem.cached? and .load, as the cache command does.
Check that solargraph bundle prints and caches a bundled gem that is
not cached yet, in the plugin-keyed gem cache directory.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LTpguFV8m5C72EvjeEFx96
Master removed External#rbs_collection_paths and
#rbs_collection_config_path (unused), so the specs this branch added
for the config path call a method that no longer exists.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants