Skip to content
2 changes: 1 addition & 1 deletion lib/bundler/cli/pristine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def run
true
end.map(&:name)

jobs = installer.send(:installation_parallelization)
jobs = Bundler.settings.installation_parallelization
pristine_count = definition.specs.count - installed_specs.count
# allow a pristining a single gem to skip the parallel worker
jobs = [jobs, pristine_count].min
Expand Down
4 changes: 3 additions & 1 deletion lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,9 @@ def source_requirements
end

def preload_git_source_worker
@preload_git_source_worker ||= Bundler::Worker.new(5, "Git source preloading", ->(source, _) { source.specs })
workers = Bundler.settings.installation_parallelization

@preload_git_source_worker ||= Bundler::Worker.new(workers, "Git source preloading", ->(source, _) { source.specs })
end

def preload_git_sources
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/fetcher/gem_remote_fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class GemRemoteFetcher < Gem::RemoteFetcher
def initialize(*)
super

@pool_size = 5
@pool_size = Bundler.settings.installation_parallelization
end

def request(*args)
Expand Down
10 changes: 1 addition & 9 deletions lib/bundler/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,21 +189,13 @@ def install(options)
standalone = options[:standalone]
force = options[:force]
local = options[:local] || options[:"prefer-local"]
jobs = installation_parallelization
jobs = Bundler.settings.installation_parallelization
spec_installations = ParallelInstaller.call(self, @definition.specs, jobs, standalone, force, local: local)
spec_installations.each do |installation|
post_install_messages[installation.name] = installation.post_install_message if installation.has_post_install_message?
end
end

def installation_parallelization
if jobs = Bundler.settings[:jobs]
return jobs
end

Bundler.settings.processor_count
end

def load_plugins
Gem.load_plugins

Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/man/bundle-config.1
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ When set, no post install messages will be printed\. To silence a single gem, us
Generate a \fBgems\.rb\fR instead of a \fBGemfile\fR when running \fBbundle init\fR\.
.TP
\fBjobs\fR (\fBBUNDLE_JOBS\fR)
The number of gems Bundler can install in parallel\. Defaults to the number of available processors\.
The number of gems Bundler can download and install in parallel\. Defaults to the number of available processors\.
.TP
\fBlockfile\fR (\fBBUNDLE_LOCKFILE\fR)
The path to the lockfile that bundler should use\. By default, Bundler adds \fB\.lock\fR to the end of the \fBgemfile\fR entry\. Can be set to \fBfalse\fR in the Gemfile to disable lockfile creation entirely (see gemfile(5))\.
Expand Down
4 changes: 2 additions & 2 deletions lib/bundler/man/bundle-config.1.ronn
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html).
* `init_gems_rb` (`BUNDLE_INIT_GEMS_RB`):
Generate a `gems.rb` instead of a `Gemfile` when running `bundle init`.
* `jobs` (`BUNDLE_JOBS`):
The number of gems Bundler can install in parallel. Defaults to the number of
available processors.
The number of gems Bundler can download and install in parallel.
Defaults to the number of available processors.
* `lockfile` (`BUNDLE_LOCKFILE`):
The path to the lockfile that bundler should use. By default, Bundler adds
`.lock` to the end of the `gemfile` entry. Can be set to `false` in the
Expand Down
4 changes: 4 additions & 0 deletions lib/bundler/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ def app_cache_path
@app_cache_path ||= self[:cache_path] || "vendor/cache"
end

def installation_parallelization
self[:jobs] || processor_count
end

def validate!
all.each do |raw_key|
[@local_config, @env_config, @global_config].each do |settings|
Expand Down
27 changes: 25 additions & 2 deletions lib/bundler/source/git/git_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,29 @@ class GitProxy
attr_accessor :path, :uri, :branch, :tag, :ref, :explicit_ref
attr_writer :revision

def self.version
@version ||= full_version[/((\.?\d+)+).*/, 1]
end

def self.full_version
@full_version ||= begin
raise GitNotInstalledError.new unless Bundler.git_present?

require "open3"
out, err, status = Open3.capture3("git", "--version")

raise GitCommandError.new("--version", SharedHelpers.pwd, err) unless status.success?
Bundler.ui.warn err unless err.empty?

out.sub(/git version\s*/, "").strip
end
end

def self.reset
@version = nil
@full_version = nil
end

def initialize(path, uri, options = {}, revision = nil, git = nil)
@path = path
@uri = uri
Expand Down Expand Up @@ -92,11 +115,11 @@ def contains?(commit)
end

def version
@version ||= full_version.match(/((\.?\d+)+).*/)[1]
self.class.version
end

def full_version
@full_version ||= git_local("--version").sub(/git version\s*/, "").strip
self.class.full_version
end

def checkout
Expand Down
4 changes: 2 additions & 2 deletions prism/extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ build_options_i(VALUE key, VALUE value, VALUE argument) {
if (!pm_options_version_set(options, ruby_version, 3)) {
// Prism doesn't know this specific version. Is it lower?
if (ruby_version[0] < '3' || (ruby_version[0] == '3' && ruby_version[2] < '3')) {
options->version == PM_OPTIONS_VERSION_CRUBY_3_3;
options->version = PM_OPTIONS_VERSION_CRUBY_3_3;
} else {
// Must be higher.
options->version == PM_OPTIONS_VERSION_LATEST;
options->version = PM_OPTIONS_VERSION_LATEST;
}
}
} else if (!pm_options_version_set(options, version, RSTRING_LEN(value))) {
Expand Down
14 changes: 7 additions & 7 deletions prism/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,20 @@ typedef struct {
pm_heredoc_indent_t indent;
} pm_heredoc_lex_mode_t;

/**
* When lexing Ruby source, the lexer has a small amount of state to tell which
* kind of token it is currently lexing. For example, when we find the start of
* a string, the first token that we return is a TOKEN_STRING_BEGIN token. After
* that the lexer is now in the PM_LEX_STRING mode, and will return tokens that
* are found as part of a string.
*/
/**
* The size of the breakpoints and strpbrk cache charset buffers. All
* breakpoint arrays and the strpbrk cache charset must share this size so
* that memcmp can safely compare the full buffer without overreading.
*/
#define PM_STRPBRK_CACHE_SIZE 16

/**
* When lexing Ruby source, the lexer has a small amount of state to tell which
* kind of token it is currently lexing. For example, when we find the start of
* a string, the first token that we return is a TOKEN_STRING_BEGIN token. After
* that the lexer is now in the PM_LEX_STRING mode, and will return tokens that
* are found as part of a string.
*/
typedef struct pm_lex_mode {
/** The type of this lex mode. */
enum {
Expand Down
5 changes: 3 additions & 2 deletions spec/bundler/bundler/env_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,9 @@ def with_clear_paths(env_var, env_value)

context "when the git version is OS specific" do
it "includes OS specific information with the version number" do
expect(git_proxy_stub).to receive(:git_local).with("--version").
and_return("git version 1.2.3 (Apple Git-BS)")
status = double("success?" => true)
expect(Open3).to receive(:capture3).with("git", "--version").
and_return(["git version 1.2.3 (Apple Git-BS)", "", status])
expect(Bundler::Source::Git::GitProxy).to receive(:new).and_return(git_proxy_stub)

expect(described_class.report).to include("Git 1.2.3 (Apple Git-BS)")
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/bundler/gem_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def sha512_hexdigest(path)
mock_confirm_message "#{app_name} (#{app_version}) installed."
subject.install_gem(nil, :local)
expect(app_gem_path).to exist
gem_command :list
installed_gems_list
expect(out).to include("#{app_name} (#{app_version})")
end
end
Expand Down
21 changes: 12 additions & 9 deletions spec/bundler/bundler/source/git/git_proxy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
describe "#version" do
context "with a normal version number" do
before do
expect(git_proxy).to receive(:git_local).with("--version").
expect(described_class).to receive(:full_version).
and_return("git version 1.2.3")
end

Expand All @@ -116,7 +116,7 @@

context "with a OSX version number" do
before do
expect(git_proxy).to receive(:git_local).with("--version").
expect(described_class).to receive(:full_version).
and_return("git version 1.2.3 (Apple Git-BS)")
end

Expand All @@ -131,7 +131,7 @@

context "with a msysgit version number" do
before do
expect(git_proxy).to receive(:git_local).with("--version").
expect(described_class).to receive(:full_version).
and_return("git version 1.2.3.msysgit.0")
end

Expand All @@ -148,8 +148,9 @@
describe "#full_version" do
context "with a normal version number" do
before do
expect(git_proxy).to receive(:git_local).with("--version").
and_return("git version 1.2.3")
status = double("success?" => true)
expect(Open3).to receive(:capture3).with("git", "--version").
and_return(["git version 1.2.3", "", status])
end

it "returns the git version number" do
Expand All @@ -159,8 +160,9 @@

context "with a OSX version number" do
before do
expect(git_proxy).to receive(:git_local).with("--version").
and_return("git version 1.2.3 (Apple Git-BS)")
status = double("success?" => true)
expect(Open3).to receive(:capture3).with("git", "--version").
and_return(["git version 1.2.3 (Apple Git-BS)", "", status])
end

it "does not strip out OSX specific additions in the version string" do
Expand All @@ -170,8 +172,9 @@

context "with a msysgit version number" do
before do
expect(git_proxy).to receive(:git_local).with("--version").
and_return("git version 1.2.3.msysgit.0")
status = double("success?" => true)
expect(Open3).to receive(:capture3).with("git", "--version").
and_return(["git version 1.2.3.msysgit.0", "", status])
end

it "does not strip out msysgit specific additions in the version string" do
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/commands/check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
bundle "config set --local path vendor/bundle"
bundle :cache

gem_command "uninstall myrack", env: { "GEM_HOME" => vendored_gems.to_s }
uninstall_gem("myrack", env: { "GEM_HOME" => vendored_gems.to_s })

bundle "check", raise_on_error: false
expect(err).to include("* myrack (1.0.0)")
Expand Down
8 changes: 4 additions & 4 deletions spec/bundler/commands/clean_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def should_not_have_gems(*gems)
gem "myrack"
G

gem_command :list
installed_gems_list
expect(out).to include("myrack (1.0.0)").and include("thin (1.0)")
end

Expand Down Expand Up @@ -498,7 +498,7 @@ def should_not_have_gems(*gems)
end
bundle :update, all: true

gem_command :list
installed_gems_list
expect(out).to include("foo (1.0.1, 1.0)")
end

Expand All @@ -522,7 +522,7 @@ def should_not_have_gems(*gems)
bundle "clean --force"

expect(out).to include("Removing foo (1.0)")
gem_command :list
installed_gems_list
expect(out).not_to include("foo (1.0)")
expect(out).to include("myrack (1.0.0)")
end
Expand Down Expand Up @@ -556,7 +556,7 @@ def should_not_have_gems(*gems)
expect(err).to include(system_gem_path.to_s)
expect(err).to include("grant write permissions")

gem_command :list
installed_gems_list
expect(out).to include("foo (1.0)")
expect(out).to include("myrack (1.0.0)")
end
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/install/gems/compact_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ def start
gem "activemerchant"
end
G
gem_command "uninstall activemerchant"
uninstall_gem("activemerchant")
bundle "update rails", artifice: "compact_index"
count = lockfile.match?("CHECKSUMS") ? 2 : 1 # Once in the specs, and once in CHECKSUMS
expect(lockfile.scan(/activemerchant \(/).size).to eq(count)
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/support/builders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ def _build(opts)
Bundler.rubygems.build(@spec, opts[:skip_validation])
end
elsif opts[:skip_validation]
@context.gem_command "build --force #{@spec.name}", dir: lib_path
Dir.chdir(lib_path) { Gem::Package.build(@spec, true) }
else
Dir.chdir(lib_path) { Gem::Package.build(@spec) }
end
Expand Down
Loading