Skip to content

Point CPM_SOURCE_CACHE at the vendored dependency cache - #250

Merged
avsej merged 1 commit into
couchbase:mainfrom
avsej:fix-cpm-source-cache-path
Sep 9, 2026
Merged

avsej merged 1 commit into
couchbase:mainfrom
avsej:fix-cpm-source-cache-path

Conversation

@avsej

@avsej avsej commented Sep 8, 2026

Copy link
Copy Markdown
Member

Motivation

The generated ext/cache/extconf_include.rb derives both
CPM_SOURCE_CACHE and
COUCHBASE_CXX_CLIENT_EMBED_MOZILLA_CA_BUNDLE_ROOT from __dir__, but
ext/extconf.rb evaluates that file through eval with no file name,
so __FILE__ is "(eval)" and __dir__ is nil. Both flags then
resolve against the working directory. Under gem install that
directory happens to be ext/, so the paths come out right by
accident; rake compile runs extconf.rb from Dir.tmpdir, where
they resolve to a cache under the temporary directory and the
dependencies and CA bundle vendored in ext/cache go unused.

Modifications

ext/extconf.rb passes the include file's path to eval, so __dir__
inside the snippet names the directory the snippet lives in, and the
generator emits that directory instead of expanding a relative cache
against it. The path is still computed when extconf runs rather than
when the gem is packaged, so a gem unpacked under any prefix finds its
own cache.

Results

Both flags name ext/cache whatever working directory the build is
driven from, so a source-tree build consumes the vendored dependencies
and the pinned CA bundle rather than fetching its own. A gem packaged
from a source tree and installed under a different prefix resolves both
flags to its own unpacked cache, so the vendored copy travels with the
gem.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes consistently resolve vendored paths independently of the build working directory.

Pull request overview

Fixes vendored dependency cache resolution when extconf.rb runs outside ext/.

Changes:

  • Evaluates the generated include with its filename.
  • Uses the include file’s directory for both cache paths.
File summaries
File Description
Rakefile Generates cache flags targeting ext/cache.
ext/extconf.rb Supplies filename context to eval.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Motivation
----------
The generated ext/cache/extconf_include.rb derives both
CPM_SOURCE_CACHE and COUCHBASE_CXX_CLIENT_EMBED_MOZILLA_CA_BUNDLE_ROOT
from __dir__, but extconf.rb evaluates that file through eval with no
file name, so __FILE__ is "(eval)" and __dir__ is nil. Both flags then
resolve against the working directory. Under `gem install` that
directory happens to be ext/, so the paths come out right by accident;
`rake compile` runs extconf.rb from Dir.tmpdir, where they resolve to a
cache under the temporary directory and the dependencies and CA bundle
vendored in ext/cache go unused.

Modifications
-------------
extconf.rb passes the include file's path to eval, so __dir__ inside
the snippet names the directory the snippet lives in, and the generator
emits that directory instead of expanding a relative 'cache' against
it. The path is still computed when extconf runs rather than when the
gem is packaged, so a gem unpacked under any prefix finds its own
cache.

Results
-------
Both flags name ext/cache whatever working directory the build is
driven from, so a source-tree build consumes the vendored dependencies
and the pinned CA bundle rather than fetching its own. A gem packaged
from a source tree and installed under a different prefix resolves both
flags to its own unpacked cache, so the vendored copy travels with the
gem.
@avsej
avsej force-pushed the fix-cpm-source-cache-path branch from bcccc49 to 88a88b8 Compare September 8, 2026 22:03
@avsej
avsej requested a review from DemetrisChr September 8, 2026 22:37
@avsej avsej added the rubber stamp needed Reviewed & ready internal/infrastructure change. Needs light approval. No public API impact. label Sep 8, 2026
@avsej
avsej merged commit 3ab6124 into couchbase:main Sep 9, 2026
35 of 44 checks passed
@avsej
avsej deleted the fix-cpm-source-cache-path branch September 9, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rubber stamp needed Reviewed & ready internal/infrastructure change. Needs light approval. No public API impact.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants