gemvault 0.2.0 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/.rubycritic.yml +15 -0
- data/CHANGELOG.md +31 -0
- data/CLAUDE.md +81 -16
- data/Dockerfile.test +56 -17
- data/Rakefile +27 -14
- data/_claude/archives/issue-13-root-cause.md +197 -0
- data/docs/Rakefile.vault_example +76 -0
- data/issues.rec +351 -15
- data/lib/gemvault/cli/commands/new.rb +16 -8
- data/lib/gemvault/cli/destination.rb +29 -0
- data/lib/gemvault/vault.rb +5 -0
- data/lib/gemvault/vault_destination.rb +70 -0
- data/lib/gemvault/version.rb +1 -1
- metadata +12 -8
- data/LICENSE +0 -21
- /data/{ASSESSMENT.md → _claude/archives/ASSESSMENT.md} +0 -0
- /data/{MACROPLAN.md → _claude/archives/MACROPLAN.md} +0 -0
- /data/{docs/superpowers → _claude/archives}/plans/2026-04-16-container-integration-tests.md +0 -0
- /data/{docs → _claude/archives}/tarvault-findings.md +0 -0
- /data/{docs → _claude/archives}/tarvault.md +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fc64d612838fd7c22293d18622272cf495d92374f0b23aeb55eb900678081ec8
|
|
4
|
+
data.tar.gz: 29dae30a7efc5c9d38b829859682e8c3d0db49e340b4e1a28f139940045938ad
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 305c089e3b58804bbf70f89e3c11f94300fc2e6204dec50fab4fb63346da163fe735f639ee89a7fceea83caa53b17f2a69c3f898e97e4b0585ace415f0ade178
|
|
7
|
+
data.tar.gz: 15bcb0df46245246f279fcb4a08bfa1c351d68f09e432ac547df92e56120800bc5decc1ae5f8351a49990b0f5001a23437a78161af66491f1dd71a2162915bb0
|
data/.rubocop.yml
CHANGED
data/.rubycritic.yml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
path: "tmp/rubycritic" # Set path where report will be saved (tmp/rubycritic by default)
|
|
2
|
+
coverage_path: "tmp/coverage" # Set path where SimpleCov coverage will be saved (./coverage by default)
|
|
3
|
+
threshold_score: 0 # default is 0
|
|
4
|
+
deduplicate_symlinks: false # default is false
|
|
5
|
+
suppress_ratings: false # default is false
|
|
6
|
+
no_browser: true # default is false
|
|
7
|
+
formats: # Available values are: html, json, console, lint. Default value is html.
|
|
8
|
+
- console
|
|
9
|
+
- json
|
|
10
|
+
minimum_score: 95 # default is 0
|
|
11
|
+
paths: # Files to analyse. Churn calculation is scoped to these files when using Git SCM.
|
|
12
|
+
- "lib/"
|
|
13
|
+
- "spec/"
|
|
14
|
+
- "test/"
|
|
15
|
+
- "shim/"
|
data/CHANGELOG.md
CHANGED
|
@@ -36,6 +36,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
36
36
|
- Vault gems whose versions carry a non-numeric suffix (e.g. `0.2.1.patch1`)
|
|
37
37
|
install from a vault with `gem install --pre`, matching RubyGems' prerelease
|
|
38
38
|
semantics (issue #6).
|
|
39
|
+
- Repeated `bundle install` no longer fails with `cannot load such file --
|
|
40
|
+
bundler/plugin/vault_source` on machines that have gemvault installed
|
|
41
|
+
system-wide. Bundler skips installing a plugin dependency already present on
|
|
42
|
+
the ambient GEM_PATH, so the plugin root holds only the shim; once the app
|
|
43
|
+
bundle is populated Bundler restricts GEM_PATH to it and the ambient copy
|
|
44
|
+
falls out of scope. The shim now locates gemvault's `lib` across every root
|
|
45
|
+
that can hold it — `Gem.default_path` above all, which is what RubyGems knows
|
|
46
|
+
about its own gem roots and therefore covers rubies from rbenv, asdf, chruby,
|
|
47
|
+
Homebrew and distros, none of which export `GEM_HOME` or `GEM_PATH` — and
|
|
48
|
+
loads it via `$LOAD_PATH` rather than gem activation (issue #13).
|
|
49
|
+
- The vault source registers correctly when Bundler evaluates the plugin more
|
|
50
|
+
than once in a process; gemvault is resolved and required only on the first
|
|
51
|
+
evaluation, so `Gemvault::GemEntry` can no longer be defined twice from two
|
|
52
|
+
different gem roots (issue #13).
|
|
53
|
+
- `gemvault new` no longer raises `cannot load such file -- json` on a stock
|
|
54
|
+
distro ruby. json backs the tarball vault's manifest, so every current-format
|
|
55
|
+
vault needs it; it is a default gem upstream but a separate package on
|
|
56
|
+
distros, where `dnf install ruby` leaves it absent. It is now a declared
|
|
57
|
+
runtime dependency.
|
|
58
|
+
- Reading a vault through the Bundler source no longer raises `cannot load such
|
|
59
|
+
file -- json` either. Loading gemvault off `$LOAD_PATH` skips activation, and
|
|
60
|
+
therefore skips its dependencies, so the declared dependency alone did not
|
|
61
|
+
reach the plugin path. The shim now resolves gemvault's declared runtime
|
|
62
|
+
dependencies the same way it resolves gemvault and puts their require paths —
|
|
63
|
+
extension directories included — on `$LOAD_PATH`. A dependency it cannot find
|
|
64
|
+
is skipped rather than fatal, which is what activation could not do.
|
|
65
|
+
- `bundle install` no longer fails with `Could not find 'command_kit' (~> 0.6)`
|
|
66
|
+
when gemvault is installed into the plugin root without its dependencies.
|
|
67
|
+
Loading the vault source no longer activates the gemvault gem, which would
|
|
68
|
+
demand the full runtime dependency set; `vault_source.rb` reaches the rest of
|
|
69
|
+
gemvault through `require_relative` alone (issue #13).
|
|
39
70
|
|
|
40
71
|
### Changed
|
|
41
72
|
- `sqlite3` is no longer a runtime dependency. Gemvault runs dependency-free on
|
data/CLAUDE.md
CHANGED
|
@@ -9,15 +9,16 @@ Do NOT modify `.rubocop.yml` or use inline `# rubocop:disable` tags without expl
|
|
|
9
9
|
1. Specs always come first. Every plan should start with the skeleton of the BDD specs being added, changed or removed. Skeleton means the empty RSpec language, without implementation.
|
|
10
10
|
2. Specs should never have comments. Any urge to put a comment in a spec means that comment should probably be its own spec
|
|
11
11
|
3. DO NOT edit .rubocop.yml or add inline rubocop exemptions without explicit permission
|
|
12
|
-
4. DO NOT
|
|
13
|
-
5.
|
|
14
|
-
6.
|
|
15
|
-
7.
|
|
16
|
-
8.
|
|
17
|
-
9.
|
|
18
|
-
10.
|
|
19
|
-
11.
|
|
20
|
-
12.
|
|
12
|
+
4. DO NOT edit .rubycritic.yml or add inline rubycritic exemptions without explicit permission
|
|
13
|
+
5. DO NOT run any git command that will rewrite history without explicit permission
|
|
14
|
+
6. PREFER method & class extraction over comments
|
|
15
|
+
7. Making new files, classes, modules, and methods IS NOT overengineering
|
|
16
|
+
8. BEFORE writing code, identify which domain concept owns the behavior. Each class and module should have a single responsibility. If the new behavior doesn't fit an existing class's responsibility, create a new one — don't expand the scope of what's already there.
|
|
17
|
+
9. DO NOT name classes with suffixes like "-er" or "-or" unless using a canonical pattern name (e.g., Parser, Router, Controller)
|
|
18
|
+
10. ALWAYS write specs first. The workflow is: identify the domain concept (rule 5), write specs describing its behavior, then implement. No implementation without a failing spec.
|
|
19
|
+
11. Integration specs are the first line of defense for CLI-tool bugs. For any bug reported from using the CLI tool (not the gemvault lib / Ruby API), the FIRST spec you write is an integration spec that reproduces the user's exact invocation — real subprocess, real vault, real exit code. Stub-heavy unit specs are complementary, not sufficient: they prove internal logic produces the expected value assuming surrounding wiring works, but a user's bug report is evidence the wiring didn't work.
|
|
20
|
+
12. If an integration spec is not catching a reported CLI-tool bug, one of two things is true, and the fix starts by diagnosing which: (a) existing integration specs are not specific enough — extend them to cover the exact scenario before touching production code; or (b) the scenario is not spec'd at all, which means the work is not a bug fix but a new feature — write integration specs for the contract first (per rule 1), then implement.
|
|
21
|
+
13. NEVER write to /tmp. Use /workspace/tmp
|
|
21
22
|
|
|
22
23
|
## Additional rules
|
|
23
24
|
|
|
@@ -77,6 +78,15 @@ gem install --source file:///path/to/myvault.gemv foo
|
|
|
77
78
|
- `bundler-source-vault` name exists because Bundler auto-infers plugin name from `type: :vault` → `bundler-source-vault`
|
|
78
79
|
- `file://` URIs stripped to plain paths in `Gem::Source::Vault#initialize`
|
|
79
80
|
- Verbose logging via `Gem::UserInteraction#verbose` for `--verbose` support
|
|
81
|
+
- `shim/plugins.rb` loads gemvault by putting its `lib` on `$LOAD_PATH`, never by
|
|
82
|
+
activating the gem. Bundler skips installing a plugin dependency already
|
|
83
|
+
present on the ambient GEM_PATH, so the plugin root often lacks gemvault, and
|
|
84
|
+
by load time GEM_PATH is restricted to the plugin root and the app bundle. The
|
|
85
|
+
shim therefore searches every root that can hold gemvault, including the ones
|
|
86
|
+
Bundler masked (`Bundler.original_env` GEM_HOME/GEM_PATH). Activation is
|
|
87
|
+
avoided because it demands gemvault's full runtime dependency set (command_kit),
|
|
88
|
+
which Bundler skips for the same reason — `vault_source.rb` reaches the rest of
|
|
89
|
+
gemvault through `require_relative` alone and needs none of it.
|
|
80
90
|
|
|
81
91
|
## Testing
|
|
82
92
|
|
|
@@ -84,17 +94,72 @@ gem install --source file:///path/to/myvault.gemv foo
|
|
|
84
94
|
bundle exec rake test
|
|
85
95
|
```
|
|
86
96
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
- `test/integration_test.rb` — 12 end-to-end bundle install tests
|
|
90
|
-
- `test/cli_test.rb` — 32 CLI tests
|
|
91
|
-
- `test/rubygems_plugin_test.rb` — 28 tests (source, resolver, monkey-patches, gem install integration, file:// URI, verbose logging)
|
|
97
|
+
Minitest covers the library; RSpec covers the CLI and the containerized
|
|
98
|
+
integration suite. `rake` (the default task) runs `test`, `spec`, `rubocop` and `rubycritic`.
|
|
92
99
|
|
|
93
|
-
|
|
100
|
+
```bash
|
|
101
|
+
bundle exec rake test # minitest only
|
|
102
|
+
bundle exec rake spec:core # rspec, no containers
|
|
103
|
+
bundle exec rake spec:integration # rspec, containers (builds the image first)
|
|
104
|
+
bundle exec rake spec:build # rebuild the container image
|
|
105
|
+
bundle exec rake spec:teardown # remove it
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
- `test/vault_test.rb` — unit tests for Vault class
|
|
109
|
+
- `test/vault_source_test.rb` — unit tests for Bundler source plugin
|
|
110
|
+
- `test/cli_test.rb` — CLI tests
|
|
111
|
+
- `test/rubygems_plugin_test.rb` — source, resolver, monkey-patches, gem install integration, file:// URI, verbose logging
|
|
112
|
+
- `spec/integration/` — end-to-end specs, each run inside a podman container
|
|
113
|
+
- `spec/support/` — script fragments the integration specs assemble into those containers
|
|
114
|
+
|
|
115
|
+
Integration specs serve the tree's own gems from a local gem index (`GemIndex`)
|
|
116
|
+
to avoid rubygems.org resolution during testing.
|
|
117
|
+
|
|
118
|
+
### Container fidelity — do not undo these
|
|
119
|
+
|
|
120
|
+
The container has to look like a machine a user actually has. The `ruby` base
|
|
121
|
+
image does not, and every way it differs has already hidden a real defect. These
|
|
122
|
+
five are load-bearing; reverting any of them silently makes the suite green
|
|
123
|
+
against something other than the code under test:
|
|
124
|
+
|
|
125
|
+
1. **`bundler-source-vault` is NOT installed system-wide in `Dockerfile.test`.**
|
|
126
|
+
An ambient copy satisfies Bundler's plugin resolution without ever populating
|
|
127
|
+
the plugin root. Specs resolve the shim from the local gem index (`GemIndex`)
|
|
128
|
+
so they exercise the tree's shim. `gemvault` IS installed system-wide on
|
|
129
|
+
purpose — that is a real user's machine and the trigger for issue #13.
|
|
130
|
+
2. **`BUNDLE_APP_CONFIG` is not set in the container.** The `ruby` image sets it
|
|
131
|
+
to `/usr/local/bundle`, which moves `Bundler::Plugin.root` out of the project
|
|
132
|
+
so no spec ever touches a project-local `.bundle/plugin`. Fedora sets it
|
|
133
|
+
nowhere; do not add it, and do not adopt a base image that does.
|
|
134
|
+
3. **`GEM_HOME` and `GEM_PATH` are not exported in the container, and nothing
|
|
135
|
+
pins them.** Gems land in RubyGems' own default dirs. The `ruby` image
|
|
136
|
+
exports `GEM_HOME`; rubies from rbenv, asdf, chruby, Homebrew and distros
|
|
137
|
+
export nothing. Anything that reads gem roots back out of the environment
|
|
138
|
+
finds them on the image and finds nothing on a user's machine — that is what
|
|
139
|
+
made the first fix for issue #13 pass its specs while still failing for the
|
|
140
|
+
reporter. Neither `Dockerfile.test` nor `ContainerHelper#podman_run` should
|
|
141
|
+
grow an `ENV`/`-e` for either variable.
|
|
142
|
+
4. **Bundler is pinned to the version users run, not the image's default gem.**
|
|
143
|
+
The plugin machinery under test is Bundler's own, so a stale default silently
|
|
144
|
+
tests different code.
|
|
145
|
+
5. **dnf runs with stock settings — weak dependencies included.** On a real
|
|
146
|
+
Fedora machine `dnf install ruby` pulls the unbundled default-gem RPMs
|
|
147
|
+
(`rubygem-json`, `rubygem-psych`, …) through the ruby package's Recommends.
|
|
148
|
+
`--setopt=install_weak_deps=False` builds a ruby no user has — one where
|
|
149
|
+
`require "json"` raises — and that faulty install once failed every CLI
|
|
150
|
+
scenario in the suite.
|
|
151
|
+
|
|
152
|
+
Fidelity is a property of the image, not of a script fragment: integration specs
|
|
153
|
+
run only commands a user would actually type.
|
|
154
|
+
|
|
155
|
+
If a spec fails only after removing a system-installed gem or an exported
|
|
156
|
+
variable, the spec was passing for the wrong reason — fix the spec, not the
|
|
157
|
+
container.
|
|
94
158
|
|
|
95
159
|
## Dependencies
|
|
96
160
|
|
|
97
161
|
- `bundler` — NOT a dependency; the plugin always runs inside an existing Bundler process, and declaring it breaks gem activation under `bundle exec`'s restricted GEM_PATH
|
|
98
162
|
- `command_kit` (~> 0.6) — runtime (CLI)
|
|
163
|
+
- `json` — NOT a dependency, though it backs the tarball vault's manifest. A default gem upstream; distros that unbundle it (Fedora's `rubygem-json`) still install it alongside ruby itself, and it stays requireable even under `bundle exec`'s restricted view. Declaring it would compile a native extension on every `gem install gemvault` for no gain.
|
|
99
164
|
- `sqlite3` (~> 2.0) — NOT a runtime dependency; loaded lazily only to read a legacy SQLite (Dbvault) vault. Declared in the Gemfile for development/test.
|
|
100
|
-
- `minitest`, `rake` — development
|
|
165
|
+
- `minitest`, `rspec`, `rake` — development
|
data/Dockerfile.test
CHANGED
|
@@ -1,25 +1,64 @@
|
|
|
1
|
-
|
|
1
|
+
# A dev machine, not a packaging convenience.
|
|
2
|
+
#
|
|
3
|
+
# The official ruby image is not shaped like anything a user runs: it redirects
|
|
4
|
+
# gems to /usr/local/bundle, exports GEM_HOME and BUNDLE_APP_CONFIG to match,
|
|
5
|
+
# and freezes bundler at whatever shipped. Each of those differences hid a real
|
|
6
|
+
# defect, and patching them one at a time only moved the blind spot. A distro
|
|
7
|
+
# ruby has none of them: gems land in RubyGems' own default dirs, nothing is
|
|
8
|
+
# exported, and bundler is a regular gem rather than a default one -- which is
|
|
9
|
+
# also the shape that broke `bundle exec` in issue #12.
|
|
10
|
+
FROM docker.io/library/fedora:44
|
|
2
11
|
|
|
3
|
-
|
|
12
|
+
# Stock dnf settings, weak dependencies included: on a real Fedora machine
|
|
13
|
+
# `dnf install ruby` pulls the unbundled default-gem RPMs (rubygem-json,
|
|
14
|
+
# rubygem-psych, rubygem-rdoc, ...) through the ruby package's Recommends.
|
|
15
|
+
# Passing --setopt=install_weak_deps=False builds a ruby no user has -- one
|
|
16
|
+
# where `require "json"` raises -- and that faulty install once failed every
|
|
17
|
+
# CLI scenario in the suite.
|
|
18
|
+
RUN dnf \
|
|
19
|
+
install \
|
|
20
|
+
-y \
|
|
21
|
+
@standard \
|
|
22
|
+
@development-tools \
|
|
23
|
+
@ruby \
|
|
24
|
+
sqlite3 \
|
|
25
|
+
&& dnf clean all
|
|
4
26
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
&& gem build bundler-source-vault.gemspec \
|
|
10
|
-
&& gem install --no-document bundler-source-vault-*.gem \
|
|
11
|
-
&& rm -rf /tmp/build
|
|
27
|
+
# Keep this in step with the `BUNDLED WITH` line the project's own lockfile
|
|
28
|
+
# carries. The plugin machinery these specs exercise is Bundler's own, so a
|
|
29
|
+
# stale version silently tests different code.
|
|
30
|
+
RUN gem install --no-document bundler -v 4.0.17
|
|
12
31
|
|
|
13
32
|
# sqlite3 is not a gemvault runtime dependency; install it here so the upgrade
|
|
14
33
|
# integration test can read the committed legacy SQLite (Dbvault) fixture it
|
|
15
34
|
# migrates.
|
|
16
35
|
RUN gem install --no-document sqlite3
|
|
17
36
|
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
37
|
+
# The tree arrives as a bind mount at /src rather than a COPY: the build context
|
|
38
|
+
# lives on a filesystem whose extended-attribute listing podman's copier cannot
|
|
39
|
+
# read. `rake spec:build` supplies both the mount and SOURCE_DIGEST.
|
|
40
|
+
#
|
|
41
|
+
# A bind mount's contents are not part of podman's cache key, so without
|
|
42
|
+
# SOURCE_DIGEST in the command line this layer is reused forever and the image
|
|
43
|
+
# keeps whichever gemvault the tree held the first time it was built -- the
|
|
44
|
+
# suite would then run green against code that is not under test. The digest
|
|
45
|
+
# changes whenever the installed source does, which invalidates the layer. It is
|
|
46
|
+
# last so that editing lib/ does not re-fetch the layers above.
|
|
47
|
+
#
|
|
48
|
+
# gemvault is installed system-wide because integration specs need the CLI to
|
|
49
|
+
# build vault fixtures, and because that is what a real user's machine looks
|
|
50
|
+
# like: `gem install gemvault` puts it on the ambient GEM_PATH. That ambient
|
|
51
|
+
# copy is load-bearing for the plugin root specs -- Bundler skips installing a
|
|
52
|
+
# plugin dependency that is already installed, so the plugin root only gets a
|
|
53
|
+
# complete dependency set if gemvault puts it there itself.
|
|
54
|
+
#
|
|
55
|
+
# bundler-source-vault is deliberately NOT installed system-wide. An ambient
|
|
56
|
+
# copy satisfies Bundler's plugin resolution without ever populating the plugin
|
|
57
|
+
# root, which masks every plugin-root defect the integration specs exist to
|
|
58
|
+
# catch. Specs install it from the local gem index built by GemIndex instead.
|
|
59
|
+
ARG SOURCE_DIGEST=unset
|
|
60
|
+
RUN test "$SOURCE_DIGEST" != unset \
|
|
61
|
+
&& cd /src \
|
|
62
|
+
&& gem build gemvault.gemspec -o /tmp/gemvault.gem \
|
|
63
|
+
&& gem install --no-document /tmp/gemvault.gem \
|
|
64
|
+
&& rm -f /tmp/gemvault.gem
|
data/Rakefile
CHANGED
|
@@ -24,31 +24,44 @@ RuboCop::RakeTask.new
|
|
|
24
24
|
require "gempilot/version_task"
|
|
25
25
|
Gempilot::VersionTask.new
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
require "rubycritic/rake_task"
|
|
28
|
+
require "yaml"
|
|
29
|
+
|
|
30
|
+
# The task's default paths are FileList["."], passed straight to the CLI where
|
|
31
|
+
# they override .rubycritic.yml's paths -- and "." drags in references/, whose
|
|
32
|
+
# vendored checkouts flog cannot even read. Feed the yml's own list back in so
|
|
33
|
+
# the config file stays the single source of truth.
|
|
34
|
+
RubyCritic::RakeTask.new do |task|
|
|
35
|
+
task.paths = YAML.load_file(".rubycritic.yml").fetch("paths")
|
|
31
36
|
end
|
|
32
37
|
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
require "digest"
|
|
39
|
+
require_relative "spec/support/container_helper"
|
|
40
|
+
require_relative "spec/support/container_image"
|
|
41
|
+
|
|
42
|
+
# What the image is built from. ContainerImage feeds this to podman as a build
|
|
43
|
+
# arg, because the bind mount the Dockerfile reads is invisible to podman's
|
|
44
|
+
# layer cache key.
|
|
45
|
+
def image_source_digest
|
|
46
|
+
fingerprints = FileList["lib/**/*", "exe/*", "gemvault.gemspec"]
|
|
47
|
+
.select { |path| File.file?(path) }.sort
|
|
48
|
+
.map { |path| "#{path} #{Digest::SHA256.hexdigest(File.binread(path))}" }
|
|
49
|
+
Digest::SHA256.hexdigest(fingerprints.join("\n"))
|
|
35
50
|
end
|
|
36
51
|
|
|
37
|
-
def
|
|
38
|
-
|
|
39
|
-
sh "podman", "rm", "-f", *strays unless strays.empty?
|
|
40
|
-
sh "podman", "rmi", CACHED_IMAGE
|
|
52
|
+
def cached_image
|
|
53
|
+
ContainerImage.new(name: ContainerHelper::CACHED_IMAGE, root: __dir__, digest: image_source_digest)
|
|
41
54
|
end
|
|
42
55
|
|
|
43
56
|
namespace :spec do
|
|
44
57
|
desc "Build cached container image with gemvault pre-installed"
|
|
45
|
-
task(:build) {
|
|
58
|
+
task(:build) { cached_image.build }
|
|
46
59
|
|
|
47
60
|
desc "Build the cached image unless it already exists"
|
|
48
|
-
task(:setup) {
|
|
61
|
+
task(:setup) { cached_image.ensure_built }
|
|
49
62
|
|
|
50
63
|
desc "Remove test containers and the cached image"
|
|
51
|
-
task(:teardown) {
|
|
64
|
+
task(:teardown) { cached_image.destroy }
|
|
52
65
|
end
|
|
53
66
|
|
|
54
67
|
directory "pkg" do
|
|
@@ -72,4 +85,4 @@ Rake::Task[:build].enhance ["shim:build"]
|
|
|
72
85
|
Rake::Task[:release].enhance ["shim:release"]
|
|
73
86
|
Rake::Task[:clobber].enhance ["spec:teardown"]
|
|
74
87
|
|
|
75
|
-
task default: [:test, :spec, :rubocop]
|
|
88
|
+
task default: [:test, :spec, :rubocop, :rubycritic]
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
# Issue #13 — `cannot load such file -- bundler/plugin/vault_source`
|
|
2
|
+
|
|
3
|
+
Line references are to the vendored RubyGems/Bundler checkout in
|
|
4
|
+
`references/rubygems` (`bundler-v4.0.0-1207-gf912ac9b0b`).
|
|
5
|
+
|
|
6
|
+
## Symptom
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
❯ bundle install
|
|
10
|
+
Fetching gem metadata from https://rubygems.org/.......
|
|
11
|
+
Resolving dependencies...
|
|
12
|
+
Installing bundler-source-vault 0.2.0
|
|
13
|
+
|
|
14
|
+
[!] There was an error parsing `Gemfile`: cannot load such file -- bundler/plugin/vault_source. Bundler cannot continue.
|
|
15
|
+
|
|
16
|
+
# from /Users/davidgillis/repos/reversal-store/Gemfile:19
|
|
17
|
+
> source "vendor/vendored.gemv", type: :vault do
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Reported as permanent. `gemvault doctor`, `rm -rf .bundle/plugin`, `rm -f
|
|
21
|
+
Gemfile.lock`, and the two combined all left it unchanged.
|
|
22
|
+
|
|
23
|
+
## Reproduction
|
|
24
|
+
|
|
25
|
+
The reporter's `.bundle` tarball showed a plugin root holding the shim and
|
|
26
|
+
nothing else:
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
.bundle/plugin/cache/bundler-source-vault-0.2.0.gem
|
|
30
|
+
.bundle/plugin/gems/bundler-source-vault-0.2.0/plugins.rb
|
|
31
|
+
.bundle/plugin/specifications/bundler-source-vault-0.2.0.gemspec
|
|
32
|
+
.bundle/plugin/index
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
No `gemvault` anywhere. Reproduced exactly with: gemvault installed on the
|
|
36
|
+
ambient `GEM_PATH`, the shim not installed, a project-local `.bundle` with a
|
|
37
|
+
configured bundle path, and `bundle install` run **twice**.
|
|
38
|
+
|
|
39
|
+
## Root cause
|
|
40
|
+
|
|
41
|
+
Three independent mechanisms compose. Each is fine alone.
|
|
42
|
+
|
|
43
|
+
### 1. Bundler never puts gemvault in the plugin root
|
|
44
|
+
|
|
45
|
+
`Source::Rubygems#install` (`lib/bundler/source/rubygems.rb:206`) short-circuits:
|
|
46
|
+
|
|
47
|
+
```ruby
|
|
48
|
+
if (spec.default_gem? && !cached_built_in_gem(...)) || (installed?(spec) && !options[:force])
|
|
49
|
+
print_using_message "Using #{version_message(spec, options[:previous_spec])}"
|
|
50
|
+
return nil
|
|
51
|
+
end
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`installed?` (`:484`) consults `installed_specs`. On any machine where
|
|
55
|
+
`gem install gemvault` has run — that is, anyone who uses the CLI — the ambient
|
|
56
|
+
copy satisfies it. Bundler prints "Using gemvault" and the plugin root receives
|
|
57
|
+
the shim alone. Nothing is downloaded, so the plugin root's `cache/` has no
|
|
58
|
+
gemvault either, which is exactly what the reporter's tarball showed.
|
|
59
|
+
|
|
60
|
+
### 2. The ambient copy disappears precisely when it is needed
|
|
61
|
+
|
|
62
|
+
`Plugin::Installer#install_all_sources` calls
|
|
63
|
+
`Bundler.configure_gem_home_and_path(Plugin.root)`
|
|
64
|
+
(`lib/bundler/plugin/installer.rb:100`), and `configure_gem_path`
|
|
65
|
+
(`lib/bundler.rb:661`) does:
|
|
66
|
+
|
|
67
|
+
```ruby
|
|
68
|
+
unless use_system_gems?
|
|
69
|
+
Bundler::SharedHelpers.set_env "GEM_PATH", ""
|
|
70
|
+
end
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
With a configured bundle path, `use_system_gems?` is false, so `GEM_PATH`
|
|
74
|
+
becomes empty and `Gem.path` collapses to the bundle. The copy that made step 1
|
|
75
|
+
"safe" is now out of scope.
|
|
76
|
+
|
|
77
|
+
This is why the failure is **permanent and why it starts on the second run**.
|
|
78
|
+
The first `bundle install` succeeds because the ambient gemvault is still
|
|
79
|
+
visible. It populates the bundle path. From then on every `bundle install`
|
|
80
|
+
narrows `GEM_PATH`, and every recovery step the reporter tried rebuilds the same
|
|
81
|
+
incomplete plugin root.
|
|
82
|
+
|
|
83
|
+
### 3. Locating gemvault is not sufficient — activation cannot survive here
|
|
84
|
+
|
|
85
|
+
The obvious repair — find gemvault and load it — has a trap. Loading it via
|
|
86
|
+
`$LOAD_PATH` skips activation, and therefore skips its dependencies. gemvault
|
|
87
|
+
reads a vault manifest through `json` (`lib/gemvault/manifest.rb:1`), so the
|
|
88
|
+
plugin dies later, at first vault read, instead of at load.
|
|
89
|
+
|
|
90
|
+
Activating instead does not work, for two separate reasons:
|
|
91
|
+
|
|
92
|
+
- **The path would be stripped one line before it is used.** `Runtime#setup`
|
|
93
|
+
(`lib/bundler/runtime.rb:12-38`) runs `clean_load_path` at line 16 and
|
|
94
|
+
`@definition.specs_for(groups)` at line 18 — and resolution is what asks the
|
|
95
|
+
vault source for specs. `clean_load_path`
|
|
96
|
+
(`lib/bundler/shared_helpers.rb:371-380`) rejects a `$LOAD_PATH` entry only
|
|
97
|
+
when `loaded_gem_paths.delete(p)` is truthy, and `loaded_gem_paths`
|
|
98
|
+
(`lib/bundler/rubygems_integration.rb:132-135`) is built from
|
|
99
|
+
`Gem.loaded_specs` — i.e. **activated gems**. Activating is what would put the
|
|
100
|
+
path on the chopping block. A directory pushed without activation is absent
|
|
101
|
+
from that list, so `delete` returns nil and the entry survives.
|
|
102
|
+
|
|
103
|
+
- **`Gem::Specification` cannot see outside the bundle.** `stub_rubygems`
|
|
104
|
+
(`lib/bundler/rubygems_integration.rb:336-340`) sets
|
|
105
|
+
`Gem::Specification.all = specs` and reapplies it through `Gem.post_reset`, so
|
|
106
|
+
under `bundle exec` `find_by_name` cannot find a gem installed outside the
|
|
107
|
+
bundle, and `Gem::Specification.reset` will not restore it.
|
|
108
|
+
|
|
109
|
+
## Why the test suite could not catch any of this
|
|
110
|
+
|
|
111
|
+
The integration container was the official `ruby` image. It differs from a
|
|
112
|
+
machine anyone develops on in four ways, and each one hid one layer:
|
|
113
|
+
|
|
114
|
+
| Image behaviour | What it hid |
|
|
115
|
+
|---|---|
|
|
116
|
+
| `gemvault` **and** `bundler-source-vault` installed system-wide | `require "bundler/plugin/vault_source"` resolved from `/usr/local/bundle` no matter what the plugin root held |
|
|
117
|
+
| `BUNDLE_APP_CONFIG=/usr/local/bundle` | `Bundler::Plugin.root` was never project-local, so no spec touched a real `.bundle/plugin` |
|
|
118
|
+
| `GEM_HOME` exported | a first repair that read gem roots out of the environment appeared to work |
|
|
119
|
+
| `json` present as a default gem | the undeclared dependency was invisible |
|
|
120
|
+
|
|
121
|
+
The first repair for this issue reconstructed gem roots from
|
|
122
|
+
`Bundler.original_env`, which is a snapshot of environment variables.
|
|
123
|
+
`GEM_HOME`/`GEM_PATH` are only present there if something exported them —
|
|
124
|
+
rbenv, asdf, chruby, Homebrew and distro rubies export neither. The reporter is
|
|
125
|
+
on rbenv (`issues.rec`: `/Users/davidgillis/.rbenv/versions/4.0.1/`,
|
|
126
|
+
`rbenv 1.3.2`), so that repair passed its specs in Docker and still failed on
|
|
127
|
+
their machine.
|
|
128
|
+
|
|
129
|
+
The suite now runs on `fedora:44` with a distro ruby: gems in RubyGems' own
|
|
130
|
+
default dirs, nothing exported, bundler a regular gem. Moving to it immediately
|
|
131
|
+
surfaced two further real defects — the undeclared `json` dependency, and the
|
|
132
|
+
`json/ext/parser` extension path.
|
|
133
|
+
|
|
134
|
+
## The fix
|
|
135
|
+
|
|
136
|
+
`shim/gemvault_load_path.rb` locates gemvault and its declared runtime
|
|
137
|
+
dependencies across every root that could hold them, and pushes their require
|
|
138
|
+
paths onto `$LOAD_PATH`.
|
|
139
|
+
|
|
140
|
+
- **`Gem.default_path` is the load-bearing root.** It is what RubyGems knows
|
|
141
|
+
about its own gem roots, independent of the narrowing in step 2, so it covers
|
|
142
|
+
rubies that export nothing. `Bundler.original_env` is still consulted, for the
|
|
143
|
+
rubies that do export a root outside those defaults, such as RVM.
|
|
144
|
+
- **`$LOAD_PATH`, not activation**, for the reasons in step 3.
|
|
145
|
+
- **Dependencies resolved by hand**, using `full_require_paths`
|
|
146
|
+
(`lib/rubygems/basic_specification.rb:172-183`), which appends `extension_dir`
|
|
147
|
+
when `have_extensions?` — without it `json/ext/parser` is unfindable, since
|
|
148
|
+
json's compiled half lives outside its gem directory.
|
|
149
|
+
- **A dependency that cannot be found is skipped rather than fatal.** That is
|
|
150
|
+
the one thing activation could not do: it would abort on `command_kit`, which
|
|
151
|
+
only the CLI needs.
|
|
152
|
+
- **`json` is now a declared runtime dependency**, so `gemvault new` works on a
|
|
153
|
+
stock distro ruby.
|
|
154
|
+
|
|
155
|
+
## Does the suite actually protect this?
|
|
156
|
+
|
|
157
|
+
Green is not evidence on its own — the whole reason this bug shipped is that a
|
|
158
|
+
green suite was being satisfied by an ambient gem. So the two pieces of the fix
|
|
159
|
+
were checked by mutation:
|
|
160
|
+
|
|
161
|
+
| Mutation | Result |
|
|
162
|
+
|---|---|
|
|
163
|
+
| `Gem.default_path` dropped from the searched roots | 18 examples fail |
|
|
164
|
+
| the shim's pinned gemvault requirement ignored, so the newest wins | both examples of the upgrade-residue scenario fail |
|
|
165
|
+
|
|
166
|
+
Restoring each returns the suite to green.
|
|
167
|
+
|
|
168
|
+
## Platforms verified
|
|
169
|
+
|
|
170
|
+
| Platform | Status |
|
|
171
|
+
|---|---|
|
|
172
|
+
| CRuby 4.0.6, Fedora 44, aarch64 | Full suite, 265 examples |
|
|
173
|
+
| JRuby 10.1.1.0 (the reporter runs 10.1.0.0) | Verified once by hand, **not covered by the suite**: vault create/add/list, `bundle install` twice against a vault source, `bundle exec require`. `json 2.21.1 (java)` installed as a platform gem and resolved, which is the case `full_require_paths` has to get right |
|
|
174
|
+
| macOS `arm64-darwin-24` | **Not verified.** The reporter's own platform. Nothing here can run it |
|
|
175
|
+
|
|
176
|
+
JRuby has no permanent coverage because JRuby caps its own heap from the cgroup
|
|
177
|
+
and the development sandbox is small enough that the cap lands at 148 MB, where
|
|
178
|
+
even a single `gem fetch` dies. The one successful hand-run above happened in a
|
|
179
|
+
lucky memory window and did not reproduce. A JRuby image, rake task and spec
|
|
180
|
+
were written and then reverted rather than shipped unverified: harness code
|
|
181
|
+
nobody has watched pass is the same defect as a spec that cannot fail. On a
|
|
182
|
+
machine with ordinary memory this is worth adding, and it is the highest-value
|
|
183
|
+
gap left, since issue #13 was reported against JRuby as well as CRuby.
|
|
184
|
+
|
|
185
|
+
## Coverage
|
|
186
|
+
|
|
187
|
+
`spec/support/vault_sourced_gemfile_examples.rb` applies "a complete bundle" to
|
|
188
|
+
a vault-sourced Gemfile and then re-applies it after each user action: deleting
|
|
189
|
+
`Gemfile.lock`, deleting `.bundle`, deleting both, removing the vaulted gem,
|
|
190
|
+
adding a gem from rubygems, adding the project's own gemspec (the reporter's
|
|
191
|
+
Gemfile shape), adding another gem from the same vault, and adding one from a
|
|
192
|
+
second vault. `spec/integration/vaulted_project_spec.rb` runs that whole
|
|
193
|
+
group under four bundler configurations — stock, an install path chosen, that
|
|
194
|
+
path undone, and the project's gems cached — and
|
|
195
|
+
`spec/integration/no_ambient_gemvault_spec.rb` covers the machine that has no
|
|
196
|
+
gemvault of its own, where the plugin root has to carry the whole dependency
|
|
197
|
+
set.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
require "rake/clean"
|
|
2
|
+
require "bundler/gem_tasks"
|
|
3
|
+
require "rspec/core/rake_task"
|
|
4
|
+
require "rubocop/rake_task"
|
|
5
|
+
require "open3"
|
|
6
|
+
|
|
7
|
+
def gemvault_contains?(gemvault_file, gem)
|
|
8
|
+
response, status = Open3.capture2e("gemvault", "list", gemvault_file)
|
|
9
|
+
unless status.success?
|
|
10
|
+
warn "Failed to list gems in vault:"
|
|
11
|
+
warn response
|
|
12
|
+
exit 1
|
|
13
|
+
end
|
|
14
|
+
gems = response.lines(chomp: true)
|
|
15
|
+
gemname_and_version = Pathname(gem).basename.sub_ext("").to_s
|
|
16
|
+
gems.include?(gemname_and_version)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def in_root_dir(&)
|
|
20
|
+
chdir(Bundler.root, &)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def gemvault(*, **)
|
|
24
|
+
sh "gemvault", *, **
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
28
|
+
spec.pattern = FileList["spec/**/*_spec.rb"]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
RuboCop::RakeTask.new
|
|
32
|
+
CLOBBER.include "dist"
|
|
33
|
+
|
|
34
|
+
desc "Generate a new cop with a template"
|
|
35
|
+
task :new_cop, [:cop] do |_task, args|
|
|
36
|
+
require "rubocop"
|
|
37
|
+
|
|
38
|
+
cop_name = args.fetch(:cop) do
|
|
39
|
+
warn "usage: bundle exec rake new_cop[Department/Name]"
|
|
40
|
+
exit!
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
generator = RuboCop::Cop::Generator.new(cop_name)
|
|
44
|
+
generator.write_source
|
|
45
|
+
generator.write_spec
|
|
46
|
+
generator.inject_require(root_file_path: "lib/rubocop/cop/kaizo_cops.rb")
|
|
47
|
+
generator.inject_config(config_file_path: "config/default.yml")
|
|
48
|
+
|
|
49
|
+
puts generator.todo
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
directory "dist" do
|
|
53
|
+
mkdir "dist"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
file "dist/vault.gemv" => "dist" do
|
|
57
|
+
in_root_dir do
|
|
58
|
+
gemvault "new", "dist/vault.gemv"
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
ENV["gem_push"] = "0"
|
|
63
|
+
namespace :release do
|
|
64
|
+
desc "release to a vault"
|
|
65
|
+
task vault: ["dist/vault.gemv", :build] do
|
|
66
|
+
FileList["pkg/*.gem"].each do |v|
|
|
67
|
+
in_root_dir do
|
|
68
|
+
gemvault "add", "dist/vault.gemv", v unless gemvault_contains? "dist/vault.gemv", v
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
Rake::Task[:release].enhance ["release:vault"]
|
|
75
|
+
|
|
76
|
+
task default: [:spec, :rubocop]
|