Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/bundler/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ def cache
map aliases_for("cache")

desc "exec [OPTIONS]", "Run the command in context of the bundle"
method_option :keep_file_descriptors, type: :boolean, default: true, banner: "Passes all file descriptors to the new processes. Default is true, and setting it to false is deprecated"
method_option :keep_file_descriptors, type: :boolean, default: true, banner: "Passes all file descriptors to the new processes. Default is true, and setting it to false is not permitted (removed)."
method_option :gemfile, type: :string, required: false, banner: "Use the specified gemfile instead of Gemfile"
long_desc <<-D
Exec runs a command, providing it access to the gems in the bundle. While using
Expand Down
13 changes: 12 additions & 1 deletion lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,18 @@ def add_checksums

setup_domain!(add_checksums: true)

specs # force materialization to real specifications, so that checksums are fetched
# force materialization to real specifications, so that checksums are fetched
specs.each do |spec|
next unless spec.source.is_a?(Bundler::Source::Rubygems)
# Checksum was fetched from the compact index API.
next if !spec.source.checksum_store.missing?(spec) && !spec.source.checksum_store.empty?(spec)
# The gem isn't installed, can't compute the checksum.
next unless spec.loaded_from

package = Gem::Package.new(spec.source.cached_built_in_gem(spec))
checksum = Checksum.from_gem_package(package)
spec.source.checksum_store.register(spec, checksum)
end
end

private
Expand Down
23 changes: 0 additions & 23 deletions lib/bundler/feature_flag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,6 @@

module Bundler
class FeatureFlag
def self.settings_flag(flag, &default)
unless Bundler::Settings::BOOL_KEYS.include?(flag.to_s)
raise "Cannot use `#{flag}` as a settings feature flag since it isn't a bool key"
end

settings_method("#{flag}?", flag, &default)
end
private_class_method :settings_flag

def self.settings_option(key, &default)
settings_method(key, key, &default)
end
private_class_method :settings_option

def self.settings_method(name, key, &default)
define_method(name) do
value = Bundler.settings[key]
value = instance_eval(&default) if value.nil?
value
end
end
private_class_method :settings_method

(1..10).each {|v| define_method("bundler_#{v}_mode?") { @major_version >= v } }

def removed_major?(target_major_version)
Expand Down
5 changes: 1 addition & 4 deletions lib/bundler/man/bundle-exec.1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
.SH "NAME"
\fBbundle\-exec\fR \- Execute a command in the context of the bundle
.SH "SYNOPSIS"
\fBbundle exec\fR [\-\-keep\-file\-descriptors] [\-\-gemfile=GEMFILE] \fIcommand\fR
\fBbundle exec\fR [\-\-gemfile=GEMFILE] \fIcommand\fR
.SH "DESCRIPTION"
This command executes the command, making all gems specified in the [\fBGemfile(5)\fR][Gemfile(5)] available to \fBrequire\fR in Ruby programs\.
.P
Expand All @@ -13,9 +13,6 @@ Essentially, if you would normally have run something like \fBrspec spec/my_spec
Note that \fBbundle exec\fR does not require that an executable is available on your shell's \fB$PATH\fR\.
.SH "OPTIONS"
.TP
\fB\-\-keep\-file\-descriptors\fR
Passes all file descriptors to the new processes\. Default is true from bundler version 2\.2\.26\. Setting it to false is now deprecated\.
.TP
\fB\-\-gemfile=GEMFILE\fR
Use the specified gemfile instead of [\fBGemfile(5)\fR][Gemfile(5)]\.
.SH "BUNDLE INSTALL \-\-BINSTUBS"
Expand Down
6 changes: 1 addition & 5 deletions lib/bundler/man/bundle-exec.1.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ bundle-exec(1) -- Execute a command in the context of the bundle

## SYNOPSIS

`bundle exec` [--keep-file-descriptors] [--gemfile=GEMFILE] <command>
`bundle exec` [--gemfile=GEMFILE] <command>

## DESCRIPTION

Expand All @@ -20,10 +20,6 @@ available on your shell's `$PATH`.

## OPTIONS

* `--keep-file-descriptors`:
Passes all file descriptors to the new processes. Default is true from
bundler version 2.2.26. Setting it to false is now deprecated.

* `--gemfile=GEMFILE`:
Use the specified gemfile instead of [`Gemfile(5)`][Gemfile(5)].

Expand Down
11 changes: 11 additions & 0 deletions spec/bundler/commands/cache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,17 @@
expect(bundled_app("vendor/cache/myrack-1.0.0.gem")).to exist
end

it "prints an error when using legacy windows rubies" do
gemfile <<-D
source "https://gem.repo1"
gem 'myrack', :platforms => [:ruby_20, :x64_mingw_20]
D

bundle "cache --all-platforms", raise_on_error: false
expect(err).to include("removed")
expect(bundled_app("vendor/cache/myrack-1.0.0.gem")).not_to exist
end

it "does not attempt to install gems in without groups" do
build_repo4 do
build_gem "uninstallable", "2.0" do |s|
Expand Down
43 changes: 39 additions & 4 deletions spec/bundler/commands/clean_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def should_not_have_gems(*gems)
expect(bundled_app("symlink-path/#{Bundler.ruby_scope}/bundler/gems/foo-#{revision[0..11]}")).to exist
end

it "removes old git gems" do
it "removes old git gems on bundle update" do
build_git "foo-bar", path: lib_path("foo-bar")
revision = revision_for(lib_path("foo-bar"))

Expand Down Expand Up @@ -383,7 +383,7 @@ def should_not_have_gems(*gems)
expect(out).to include("myrack (1.0.0)").and include("thin (1.0)")
end

it "automatically cleans when path has not been set", bundler: "5" do
it "does not clean on bundle update when path has not been set" do
build_repo2

install_gemfile <<-G
Expand All @@ -398,8 +398,43 @@ def should_not_have_gems(*gems)

bundle "update", all: true

files = Pathname.glob(bundled_app(".bundle", Bundler.ruby_scope, "*", "*"))
files.map! {|f| f.to_s.sub(bundled_app(".bundle", Bundler.ruby_scope).to_s, "") }
files = Pathname.glob(default_bundle_path("*", "*"))
files.map! {|f| f.to_s.sub(default_bundle_path.to_s, "") }
expected_files = %W[
/bin/bundle
/bin/bundler
/cache/bundler-#{Bundler::VERSION}.gem
/cache/foo-1.0.1.gem
/cache/foo-1.0.gem
/gems/bundler-#{Bundler::VERSION}
/gems/foo-1.0
/gems/foo-1.0.1
/specifications/bundler-#{Bundler::VERSION}.gemspec
/specifications/foo-1.0.1.gemspec
/specifications/foo-1.0.gemspec
]
expected_files += ["/bin/bundle.bat", "/bin/bundler.bat"] if Gem.win_platform?

expect(files.sort).to eq(expected_files.sort)
end

it "will automatically clean on bundle update when path has not been set", bundler: "5" do
build_repo2

install_gemfile <<-G
source "https://gem.repo2"

gem "foo"
G

update_repo2 do
build_gem "foo", "1.0.1"
end

bundle "update", all: true

files = Pathname.glob(local_gem_path("*", "*"))
files.map! {|f| f.to_s.sub(local_gem_path.to_s, "") }
expect(files.sort).to eq %w[
/cache/foo-1.0.1.gem
/gems/foo-1.0.1
Expand Down
15 changes: 0 additions & 15 deletions spec/bundler/commands/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -327,21 +327,6 @@
end
end

describe "doing bundle install foo" do
before do
gemfile <<-G
source "https://gem.repo1"
gem "myrack"
G
end

it "works" do
bundle "config set --local path vendor"
bundle "install"
expect(the_bundle).to include_gems "myrack 1.0"
end
end

it "gives useful errors if no global sources are set, and gems not installed locally, with and without a lockfile" do
install_gemfile <<-G, raise_on_error: false
gem "myrack"
Expand Down
91 changes: 91 additions & 0 deletions spec/bundler/commands/lock_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2174,6 +2174,97 @@
L
end

it "add checksums for gems installed on disk" do
build_repo4 do
build_gem "warning", "18.0.0"
end

bundle "config lockfile_checksums false"

simulate_platform "x86_64-linux" do
install_gemfile(<<-G, artifice: "endpoint")
source "https://gem.repo4"

gem "warning"
G

bundle "config --delete lockfile_checksums"
bundle("lock --add-checksums", artifice: "endpoint")
end

checksums = checksums_section do |c|
c.checksum gem_repo4, "warning", "18.0.0"
end

expect(lockfile).to eq <<~L
GEM
remote: https://gem.repo4/
specs:
warning (18.0.0)

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
warning
#{checksums}
BUNDLED WITH
#{Bundler::VERSION}
L
end

it "doesn't add checksum for gems not installed on disk" do
lockfile(<<~L)
GEM
remote: https://gem.repo4/
specs:
warning (18.0.0)

PLATFORMS
#{local_platform}

DEPENDENCIES
warning

BUNDLED WITH
#{Bundler::VERSION}
L

gemfile(<<~G)
source "https://gem.repo4"

gem "warning"
G

build_repo4 do
build_gem "warning", "18.0.0"
end

FileUtils.rm_rf("#{gem_repo4}/gems")

bundle("lock --add-checksums", artifice: "endpoint")

expect(lockfile).to eq <<~L
GEM
remote: https://gem.repo4/
specs:
warning (18.0.0)

PLATFORMS
#{local_platform}

DEPENDENCIES
warning

CHECKSUMS
warning (18.0.0)

BUNDLED WITH
#{Bundler::VERSION}
L
end

context "when re-resolving to include prereleases" do
before do
build_repo4 do
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/install/gemfile/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@

it "caches the git repo" do
install_base_gemfile
expect(Dir["#{default_bundle_path}/cache/bundler/git/foo-1.0-*"]).to have_attributes size: 1
expect(Dir["#{default_cache_path}/git/foo-1.0-*"]).to have_attributes size: 1
end

it "does not write to cache on bundler/setup" do
Expand Down
15 changes: 15 additions & 0 deletions spec/bundler/other/major_deprecation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,21 @@
end
end

context "with a global path source" do
before do
build_lib "foo"

install_gemfile <<-G, raise_on_error: false
path "#{lib_path("foo-1.0")}"
gem 'foo'
G
end

it "shows an error" do
expect(err).to include("You can no longer specify a path source by itself")
end
end

context "when Bundler.setup is run in a ruby script" do
before do
create_file "gems.rb", "source 'https://gem.repo1'"
Expand Down
22 changes: 18 additions & 4 deletions zjit/src/backend/lir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ use std::mem::take;
use crate::codegen::local_size_and_idx_to_ep_offset;
use crate::cruby::{Qundef, RUBY_OFFSET_CFP_PC, RUBY_OFFSET_CFP_SP, SIZEOF_VALUE_I32, vm_stack_canary};
use crate::hir::SideExitReason;
use crate::options::{debug, get_option};
use crate::options::{debug, get_option, TraceExits};
use crate::cruby::VALUE;
use crate::stats::{exit_counter_ptr, exit_counter_ptr_for_opcode, CompileError};
use crate::stats::{exit_counter_ptr, exit_counter_ptr_for_opcode, side_exit_counter, CompileError};
use crate::virtualmem::CodePtr;
use crate::asm::{CodeBlock, Label};
use crate::state::rb_zjit_record_exit_stack;
Expand Down Expand Up @@ -1644,8 +1644,22 @@ impl Assembler
}
}

if get_option!(trace_side_exits) {
asm_ccall!(self, rb_zjit_record_exit_stack, Opnd::const_ptr(pc as *const u8));
if get_option!(trace_side_exits).is_some() {
// Get the corresponding `Counter` for the current `SideExitReason`.
let side_exit_counter = side_exit_counter(reason);

// Only record the exit if `trace_side_exits` is defined and the counter is either the one specified
let should_record_exit = get_option!(trace_side_exits)
.map(|trace| match trace {
TraceExits::All => true,
TraceExits::Counter(counter) if counter == side_exit_counter => true,
_ => false,
})
.unwrap_or(false);

if should_record_exit {
asm_ccall!(self, rb_zjit_record_exit_stack, Opnd::const_ptr(pc as *const u8));
}
}

asm_comment!(self, "exit to the interpreter");
Expand Down
Loading