Skip to content

Add livekit/server/sdk entrypoint so Bundler.require loads the gem - #102

Open
corsonknowles wants to merge 1 commit into
livekit:mainfrom
corsonknowles:conventional-bundler-entrypoint
Open

corsonknowles wants to merge 1 commit into
livekit:mainfrom
corsonknowles:conventional-bundler-entrypoint

Conversation

@corsonknowles

Copy link
Copy Markdown

Problem

With a plain gem "livekit-server-sdk" line in a Gemfile, Bundler.require does not load this gem, and it does so silently.

Bundler's autorequire first tries require "livekit-server-sdk". When that raises a LoadError for exactly that path and the name contains dashes, it retries with every - replaced by /, i.e. require "livekit/server/sdk". If that also fails, Bundler skips the gem without a warning.

The entrypoint here is livekit, so neither path matches, and consumers have to write gem "livekit-server-sdk", require: "livekit" or add a manual require "livekit" somewhere. In a Rails app that relies on Bundler.require this shows up as uninitialized constant LiveKit::... errors that depend on load order. #75 may be one instance of this: if app code defines something under LiveKit:: before the gem is loaded, the autoloader can end up owning the LiveKit namespace and remove it on reload.

Change

  • Adds lib/livekit/server/sdk.rb, which only does require_relative "../../livekit". It defines no constants, so there is nothing new under LiveKit::Server, and nothing collides with the existing lib/livekit/ files or the generated protos.
  • Adds a line under [Unreleased] in CHANGELOG.md. I left the version alone.

It's fully backward compatible: require "livekit" and existing require: options keep working unchanged, and requiring both paths loads the code once. spec.files comes from git ls-files, so the file ships in the gem.

Verification

$ ruby -Ilib -e 'require "livekit/server/sdk"; p defined?(LiveKit::AccessToken); p defined?(LiveKit::LiveKitAPI)'
"constant"
"constant"

With a scratch Gemfile containing only gem "livekit-server-sdk", path: "<checkout>" (no require:), running Bundler.require; p defined?(LiveKit::AccessToken):

  • before this change: nil
  • after this change: "constant"

🤖 Generated with Claude Code

Bundler.require tries require 'livekit-server-sdk', then
'livekit/server/sdk'. Neither path existed, so the gem was skipped
silently unless the Gemfile set require: 'livekit'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@corsonknowles
corsonknowles requested a review from a team as a code owner October 27, 2026 23:10
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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