Point CPM_SOURCE_CACHE at the vendored dependency cache - #250
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 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
force-pushed
the
fix-cpm-source-cache-path
branch
from
September 8, 2026 22:03
bcccc49 to
88a88b8
Compare
DemetrisChr
approved these changes
Sep 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The generated
ext/cache/extconf_include.rbderives bothCPM_SOURCE_CACHEandCOUCHBASE_CXX_CLIENT_EMBED_MOZILLA_CA_BUNDLE_ROOTfrom__dir__, butext/extconf.rbevaluates that file throughevalwith no file name,so
__FILE__is"(eval)"and__dir__isnil. Both flags thenresolve against the working directory. Under
gem installthatdirectory happens to be
ext/, so the paths come out right byaccident;
rake compilerunsextconf.rbfromDir.tmpdir, wherethey resolve to a cache under the temporary directory and the
dependencies and CA bundle vendored in
ext/cachego unused.Modifications
ext/extconf.rbpasses the include file's path toeval, so__dir__inside the snippet names the directory the snippet lives in, and the
generator emits that directory instead of expanding a relative
cacheagainst 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/cachewhatever working directory the build isdriven 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.