Open endgame opened 4 years ago
Relevant commit at the old Bundler repo.
Looks like there's been a lot of churn w.r.t. the bundler {cache,package,pack}
--all
flag (try git log -G 'feature_flag.*cache_all' -p
in the old Bundler repo).
As I read the relevant docs, it looks like the local <app>/.bundle/config
overrides BUNDLE_*
settings in the environment, which means that restoring the --all
flag isn't as simple as setting BUNDLE_CACHE_ALL=false
in the controlling environment of bundle pack
. On the other handle, also setting BUNDLE_IGNORE_CONFIG=true
appears to work:
$ cd "$(mktemp -d)"
$ mkdir -p .bundle
$ printf > .bundle/config -- '---\nBUNDLE_CACHE_ALL: "true"\n'
$ bundle help pack' | grep -e --all
$ printf > .bundle/config -- '---\nBUNDLE_CACHE_ALL: "true"\n'
$ nix-shell --pure -p bundler --run 'BUNDLE_CACHE_ALL=false bundle help pack' | grep -e --all
[--all-platforms=Include gems for all platforms present in the lockfile, not only the current one], [--no-all-platforms]
$ rm -f .bundle/config
$ nix-shell --pure -p bundler --run 'BUNDLE_CACHE_ALL=false bundle help pack' | grep -e --all
[--all=Include all sources (including path and git).], [--no-all]
[--all-platforms=Include gems for all platforms present in the lockfile, not only the current one], [--no-all-platforms]
$ printf > .bundle/config -- '---\nBUNDLE_CACHE_ALL: "true"\n'
$ nix-shell --pure -p bundler --run 'BUNDLE_IGNORE_CONFIG=true BUNDLE_CACHE_ALL=false bundle help pack' | grep -e --all
[--all=Include all sources (including path and git).], [--no-all]
[--all-platforms=Include gems for all platforms present in the lockfile, not only the current one], [--no-all-platforms]
Not sure whether it is acceptable or desirable for bundix
to ignore the user's Bundler config, though.
--all
is a valid command line argument to bundle pack
if and only if cache_all
is false
. Passing --all
when it is valid has the side effect of setting cache_all
to true
, so the next invocation with --all
has an error. 👏👏
Since running bundix -m
already has the side-effect of setting cache_all
(because it executes bundler pack --all
), I propose changing the code around https://github.com/nix-community/bundix/blob/master/lib/bundix/commandline.rb#L110 along the lines of:
fail unless system(
Bundix::NIX_SHELL, '-p', options[:ruby],
"bundler.override { ruby = #{options[:ruby]}; }",
"--command", "bundle config --local cache_all true")
fail unless system(
Bundix::NIX_SHELL, '-p', options[:ruby],
"bundler.override { ruby = #{options[:ruby]}; }",
"--command", "bundle pack --path #{options[:bundle_pack_path]}")
This will not be needed in bundler 3 according to the documentation for cache_all
.
BTW, as a workaround for this bug, I've been running bundix like this:
bundle config --local cache_all false && $(nix-build '<nixpkgs>' -A bundix --no-out-link)/bin/bundix --magic
Running
bundix -m
with a modernbundler
fails thus:Bundix version: 2.5.0 from nixos-20.03 Bundler version 2.1.4 from nixos-20.03