diff --git a/Cargo.lock b/Cargo.lock index 2858c0556ddba6..d749b2e071e253 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,18 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "capstone" version = "0.14.0" @@ -38,21 +50,39 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "console" -version = "0.15.8" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" +checksum = "d64e8af5551369d19cf50138de61f1c42074ab970f74e99be916646777f8fc87" dependencies = [ "encode_unicode", - "lazy_static", "libc", - "windows-sys", + "windows-sys 0.61.2", ] [[package]] name = "encode_unicode" -version = "0.3.6" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "fastrand" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +dependencies = [ + "instant", +] [[package]] name = "getrandom" @@ -66,26 +96,47 @@ dependencies = [ "wasip2", ] +[[package]] +name = "hermit-abi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" + [[package]] name = "insta" -version = "1.43.1" +version = "1.47.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "154934ea70c58054b556dd430b99a98c2a7ff5309ac9891597e339b5c28f4371" +checksum = "6f40e41efb5f592d3a0764f818e2f08e5e21c4f368126f74f37c81bd4af7a0c6" dependencies = [ "console", "once_cell", "similar", + "tempfile", ] [[package]] -name = "jit" -version = "0.1.0" +name = "instant" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" +dependencies = [ + "cfg-if", +] [[package]] -name = "lazy_static" -version = "1.5.0" +name = "io-lifetimes" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" +dependencies = [ + "hermit-abi", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "jit" +version = "0.1.0" [[package]] name = "libc" @@ -93,6 +144,12 @@ version = "0.2.171" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" +[[package]] +name = "linux-raw-sys" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" + [[package]] name = "once_cell" version = "1.21.3" @@ -140,6 +197,15 @@ dependencies = [ "getrandom", ] +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags", +] + [[package]] name = "ruby" version = "0.0.0" @@ -148,6 +214,20 @@ dependencies = [ "zjit", ] +[[package]] +name = "rustix" +version = "0.37.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "519165d378b97752ca44bbe15047d5d3409e875f39327546b42ac81d7e18c1b6" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.48.0", +] + [[package]] name = "shlex" version = "1.3.0" @@ -166,6 +246,20 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "tempfile" +version = "3.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" +dependencies = [ + "autocfg", + "cfg-if", + "fastrand", + "redox_syscall", + "rustix", + "windows-sys 0.48.0", +] + [[package]] name = "wasip2" version = "1.0.1+wasi-0.2.4" @@ -175,13 +269,52 @@ dependencies = [ "wit-bindgen", ] +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -190,28 +323,46 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -224,24 +375,48 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" diff --git a/configure.ac b/configure.ac index 2a732c1d30eb21..1d348435faf392 100644 --- a/configure.ac +++ b/configure.ac @@ -2501,9 +2501,7 @@ AC_CACHE_CHECK(for negative time_t for gmtime(3), rb_cv_negative_time_t, #include void -check(tm, y, m, d, h, s) - struct tm *tm; - int y, m, d, h, s; +check(struct tm *tm, int y, int m, int d, int h, int s) { if (!tm || tm->tm_year != y || @@ -2587,8 +2585,7 @@ AS_IF([test "$ac_cv_func_sigprocmask" = yes && test "$ac_cv_func_sigaction" = ye #include void -sig_handler(dummy) - int dummy; +sig_handler(int dummy) { } diff --git a/cont.c b/cont.c index 1382b22fce5077..36ee34fe670f8b 100644 --- a/cont.c +++ b/cont.c @@ -42,7 +42,11 @@ extern int madvise(caddr_t, size_t, int); #include "id_table.h" #include "ractor_core.h" -static const int DEBUG = 0; +enum { + DEBUG = 0, + DEBUG_EXPAND = 0, + DEBUG_ACQUIRE = 0, +}; #define RB_PAGE_SIZE (pagesize) #define RB_PAGE_MASK (~(RB_PAGE_SIZE - 1)) @@ -62,11 +66,11 @@ static VALUE rb_cFiberPool; // Defined in `coroutine/$arch/Context.h`: #ifdef COROUTINE_LIMITED_ADDRESS_SPACE #define FIBER_POOL_ALLOCATION_FREE -#define FIBER_POOL_INITIAL_SIZE 8 -#define FIBER_POOL_ALLOCATION_MAXIMUM_SIZE 32 +#define FIBER_POOL_MINIMUM_COUNT 8 +#define FIBER_POOL_MAXIMUM_ALLOCATIONS 32 #else -#define FIBER_POOL_INITIAL_SIZE 32 -#define FIBER_POOL_ALLOCATION_MAXIMUM_SIZE 1024 +#define FIBER_POOL_MINIMUM_COUNT 32 +#define FIBER_POOL_MAXIMUM_ALLOCATIONS 1024 #endif #ifdef RB_EXPERIMENTAL_FIBER_POOL #define FIBER_POOL_ALLOCATION_FREE @@ -189,7 +193,11 @@ struct fiber_pool { size_t count; // The initial number of stacks to allocate. - size_t initial_count; + size_t minimum_count; + + // If positive, total stacks in this pool cannot exceed this (shared pool only: + // set via RUBY_SHARED_FIBER_POOL_MAXIMUM_COUNT). Expansion fails with errno EAGAIN. + size_t maximum_count; // Whether to madvise(free) the stack or not. // If this value is set to 1, the stack will be madvise(free)ed @@ -470,7 +478,7 @@ fiber_pool_allocate_memory(size_t * count, size_t stride) // the system would allow (e.g. overcommit * physical memory + swap), we // divide count by two and try again. This condition should only be // encountered in edge cases, but we handle it here gracefully. - while (*count > 1) { + while (*count) { #if defined(_WIN32) void * base = VirtualAlloc(0, (*count)*stride, MEM_COMMIT, PAGE_READWRITE); @@ -518,11 +526,28 @@ fiber_pool_allocate_memory(size_t * count, size_t stride) static struct fiber_pool_allocation * fiber_pool_expand(struct fiber_pool * fiber_pool, size_t count) { + if (count == 0) { + errno = EAGAIN; + return NULL; + } + STACK_GROW_DIR_DETECTION; size_t size = fiber_pool->size; size_t stride = size + RB_PAGE_SIZE; + // If the maximum number of stacks is set, and we have reached it, return NULL. + if (fiber_pool->maximum_count > 0) { + if (fiber_pool->count >= fiber_pool->maximum_count) { + errno = EAGAIN; + return NULL; + } + size_t remaining = fiber_pool->maximum_count - fiber_pool->count; + if (count > remaining) { + count = remaining; + } + } + // Allocate metadata before mmap: ruby_xmalloc (RB_ALLOC) raises on failure and // must not run after base is mapped, or the region would leak. struct fiber_pool_allocation * allocation = RB_ALLOC(struct fiber_pool_allocation); @@ -548,7 +573,7 @@ fiber_pool_expand(struct fiber_pool * fiber_pool, size_t count) #endif allocation->pool = fiber_pool; - if (DEBUG) { + if (DEBUG_EXPAND) { fprintf(stderr, "fiber_pool_expand(%"PRIuSIZE"): %p, %"PRIuSIZE"/%"PRIuSIZE" x [%"PRIuSIZE":%"PRIuSIZE"]\n", count, (void*)fiber_pool, fiber_pool->used, fiber_pool->count, size, fiber_pool->vm_stack_size); } @@ -613,7 +638,7 @@ fiber_pool_expand(struct fiber_pool * fiber_pool, size_t count) // Initialize the specified fiber pool with the given number of stacks. // @param vm_stack_size The size of the vm stack to allocate. static void -fiber_pool_initialize(struct fiber_pool * fiber_pool, size_t size, size_t count, size_t vm_stack_size) +fiber_pool_initialize(struct fiber_pool * fiber_pool, size_t size, size_t minimum_count, size_t maximum_count, size_t vm_stack_size) { VM_ASSERT(vm_stack_size < size); @@ -621,14 +646,16 @@ fiber_pool_initialize(struct fiber_pool * fiber_pool, size_t size, size_t count, fiber_pool->vacancies = NULL; fiber_pool->size = ((size / RB_PAGE_SIZE) + 1) * RB_PAGE_SIZE; fiber_pool->count = 0; - fiber_pool->initial_count = count; + fiber_pool->minimum_count = minimum_count; + fiber_pool->maximum_count = maximum_count; fiber_pool->free_stacks = 1; fiber_pool->used = 0; - fiber_pool->vm_stack_size = vm_stack_size; - if (RB_UNLIKELY(!fiber_pool_expand(fiber_pool, count))) { - rb_raise(rb_eFiberError, "can't allocate initial fiber stacks (%"PRIuSIZE" x %"PRIuSIZE" bytes): %s", count, fiber_pool->size, strerror(errno)); + if (fiber_pool->minimum_count > 0) { + if (RB_UNLIKELY(!fiber_pool_expand(fiber_pool, fiber_pool->minimum_count))) { + rb_raise(rb_eFiberError, "can't allocate initial fiber stacks (%"PRIuSIZE" x %"PRIuSIZE" bytes): %s", fiber_pool->minimum_count, fiber_pool->size, strerror(errno)); + } } } @@ -678,15 +705,30 @@ fiber_pool_allocation_free(struct fiber_pool_allocation * allocation) #endif // Number of stacks to request when expanding the pool (clamped to min/max). -static inline size_t +static size_t fiber_pool_stack_expand_count(const struct fiber_pool *pool) { - const size_t maximum = FIBER_POOL_ALLOCATION_MAXIMUM_SIZE; - const size_t minimum = pool->initial_count; + const size_t maximum_allocations = FIBER_POOL_MAXIMUM_ALLOCATIONS; + const size_t minimum_count = FIBER_POOL_MINIMUM_COUNT; + // We are going try and double the number of stacks in the pool: size_t count = pool->count; - if (count > maximum) count = maximum; - if (count < minimum) count = minimum; + if (count > maximum_allocations) count = maximum_allocations; + if (count < minimum_count) count = minimum_count; + + // If we have a maximum count, we need to clamp the number of stacks to the maximum: + if (pool->maximum_count > 0) { + if (pool->count >= pool->maximum_count) { + // No expansion is possible: + return 0; + } + + // Otherwise, compute the number of stacks we can allocate to bring us to the maximum: + size_t remaining = pool->maximum_count - pool->count; + if (count > remaining) { + count = remaining; + } + } return count; } @@ -698,7 +740,7 @@ fiber_pool_stack_acquire_expand(struct fiber_pool *fiber_pool) { size_t count = fiber_pool_stack_expand_count(fiber_pool); - if (DEBUG) fprintf(stderr, "fiber_pool_stack_acquire: expanding fiber pool by %"PRIuSIZE" stacks\n", count); + if (DEBUG_ACQUIRE) fprintf(stderr, "fiber_pool_stack_acquire: expanding fiber pool by %"PRIuSIZE" stacks\n", count); struct fiber_pool_vacancy *vacancy = NULL; @@ -706,7 +748,7 @@ fiber_pool_stack_acquire_expand(struct fiber_pool *fiber_pool) return fiber_pool_vacancy_pop(fiber_pool); } else { - if (DEBUG) fprintf(stderr, "fiber_pool_stack_acquire: expand failed (%s), collecting garbage\n", strerror(errno)); + if (DEBUG_ACQUIRE) fprintf(stderr, "fiber_pool_stack_acquire: expand failed (%s), collecting garbage\n", strerror(errno)); rb_gc(); @@ -716,6 +758,9 @@ fiber_pool_stack_acquire_expand(struct fiber_pool *fiber_pool) return vacancy; } + // Recompute count as gc may have freed up some allocations: + count = fiber_pool_stack_expand_count(fiber_pool); + // Try to expand the fiber pool again: if (RB_LIKELY(fiber_pool_expand(fiber_pool, count))) { return fiber_pool_vacancy_pop(fiber_pool); @@ -3526,7 +3571,7 @@ rb_fiber_pool_initialize(int argc, VALUE* argv, VALUE self) TypedData_Get_Struct(self, struct fiber_pool, &FiberPoolDataType, fiber_pool); - fiber_pool_initialize(fiber_pool, NUM2SIZET(size), NUM2SIZET(count), NUM2SIZET(vm_stack_size)); + fiber_pool_initialize(fiber_pool, NUM2SIZET(size), NUM2SIZET(count), 0, NUM2SIZET(vm_stack_size)); return self; } @@ -3545,6 +3590,46 @@ rb_fiber_pool_initialize(int argc, VALUE* argv, VALUE self) * fiber.resume #=> FiberError: dead fiber called */ +static size_t +shared_fiber_pool_minimum_count(void) +{ + size_t minimum_count = FIBER_POOL_MINIMUM_COUNT; + + const char *minimum_count_env = getenv("RUBY_SHARED_FIBER_POOL_MINIMUM_COUNT"); + if (minimum_count_env && minimum_count_env[0]) { + char *end; + unsigned long value = strtoul(minimum_count_env, &end, 10); + if (end != minimum_count_env && *end == '\0') { + minimum_count = (size_t)value; + } + else { + rb_warn("invalid RUBY_SHARED_FIBER_POOL_MINIMUM_COUNT=%s (expected a non-negative integer)", minimum_count_env); + } + } + + return minimum_count; +} + +static size_t +shared_fiber_pool_maximum_count(void) +{ + size_t maximum_count = 0; + + const char *maximum_count_env = getenv("RUBY_SHARED_FIBER_POOL_MAXIMUM_COUNT"); + if (maximum_count_env && maximum_count_env[0]) { + char *end; + unsigned long value = strtoul(maximum_count_env, &end, 10); + if (end != maximum_count_env && *end == '\0') { + maximum_count = (size_t)value; + } + else { + rb_warn("invalid RUBY_SHARED_FIBER_POOL_MAXIMUM_COUNT=%s (expected a non-negative integer)", maximum_count_env); + } + } + + return maximum_count; +} + void Init_Cont(void) { @@ -3562,7 +3647,9 @@ Init_Cont(void) #endif SET_MACHINE_STACK_END(&th->ec->machine.stack_end); - fiber_pool_initialize(&shared_fiber_pool, stack_size, FIBER_POOL_INITIAL_SIZE, vm_stack_size); + size_t minimum_count = shared_fiber_pool_minimum_count(); + size_t maximum_count = shared_fiber_pool_maximum_count(); + fiber_pool_initialize(&shared_fiber_pool, stack_size, minimum_count, maximum_count, vm_stack_size); fiber_initialize_keywords[0] = rb_intern_const("blocking"); fiber_initialize_keywords[1] = rb_intern_const("pool"); diff --git a/lib/rubygems/version.rb b/lib/rubygems/version.rb index 6e286bd628f0da..c864af0b91d00b 100644 --- a/lib/rubygems/version.rb +++ b/lib/rubygems/version.rb @@ -158,6 +158,7 @@ class Gem::Version VERSION_PATTERN = '[0-9]+(?>\.[0-9a-zA-Z]+)*(-[0-9A-Za-z-]+(\.[0-9A-Za-z-]+)*)?' # :nodoc: ANCHORED_VERSION_PATTERN = /\A\s*(#{VERSION_PATTERN})?\s*\z/ # :nodoc: + RADIX_OPT = [9_500, 3_500, 260_000, 22_227, 24].freeze # :nodoc: ## # A string representation of this Version. @@ -423,16 +424,19 @@ def freeze attr_reader :sort_key # :nodoc: def compute_sort_key - segments = canonical_segments - return if segments.size > 4 || prerelease? || segments.any? {|segment| segment > 65_000 } + return if prerelease? - base = 1_000_000_000_000 + segments = canonical_segments + return if segments.size > 5 - segments.sum do |segment| - result = segment * base - base /= 10_000 - result + key = 0 + RADIX_OPT.each_with_index do |radix, i| + seg = segments.fetch(i, 0) + return nil if seg >= radix + key = key * radix + seg end + + key end def _segments diff --git a/man/erb.1 b/man/erb.1 index 7f606ae5faa1d3..38a4c14ea46f75 100644 --- a/man/erb.1 +++ b/man/erb.1 @@ -1,5 +1,5 @@ .\"Ruby is copyrighted by Yukihiro Matsumoto . -.Dd February 24, 2026 +.Dd March 27, 2026 .Dt ERB 1 "Ruby Programmer's Reference Guide" .Os UNIX .Sh NAME diff --git a/man/goruby.1 b/man/goruby.1 index 1d6a32663a050c..732ecaa66378c4 100644 --- a/man/goruby.1 +++ b/man/goruby.1 @@ -1,5 +1,5 @@ .\"Ruby is copyrighted by Yukihiro Matsumoto . -.Dd February 24, 2026 +.Dd March 27, 2026 .Dt GORUBY 1 "Ruby Programmer's Reference Guide" .Os UNIX .Sh NAME diff --git a/man/ruby.1 b/man/ruby.1 index 177e8ac5ddf8c1..bc776b89465aa1 100644 --- a/man/ruby.1 +++ b/man/ruby.1 @@ -1,5 +1,5 @@ .\"Ruby is copyrighted by Yukihiro Matsumoto . -.Dd February 24, 2026 +.Dd March 27, 2026 .Dt RUBY 1 "Ruby Programmer's Reference Guide" .Os UNIX .Sh NAME @@ -700,6 +700,16 @@ Frees stacks of pooled fibers, if set to 1. Do not free the stacks if set to 0. Introduced in Ruby 2.7, default: 1 (no growth) .Pp +.It Ev RUBY_SHARED_FIBER_POOL_MAXIMUM_COUNT +If set to a non-negative integer, the shared fiber pool cannot allocate more +than that many stacks; further fiber creation may fail with +.Va FiberError . +Unset or 0 means no explicit cap (subject to process limits). +.Pp +.It Ev RUBY_SHARED_FIBER_POOL_MINIMUM_COUNT +Initial and minimum growth chunk size for the shared fiber pool (stacks). +Unset uses the implementation default. +.Pp .El .Sh STACK SIZE ENVIRONMENT Stack size environment variables are implementation-dependent and diff --git a/prism/templates/ext/prism/api_node.c.erb b/prism/templates/ext/prism/api_node.c.erb index 71f7fe273e2ab2..41d7165930d38a 100644 --- a/prism/templates/ext/prism/api_node.c.erb +++ b/prism/templates/ext/prism/api_node.c.erb @@ -82,11 +82,18 @@ pm_source_new(const pm_parser_t *parser, rb_encoding *encoding, bool freeze) { VALUE source_string = rb_enc_str_new((const char *) start, pm_parser_end(parser) - start, encoding); const pm_line_offset_list_t *line_offsets = pm_parser_line_offsets(parser); - VALUE offsets = rb_str_new((const char *) line_offsets->offsets, line_offsets->size * sizeof(uint32_t)); + VALUE offsets; if (freeze) { + offsets = rb_ary_new_capa(line_offsets->size); + for (size_t index = 0; index < line_offsets->size; index++) { + rb_ary_push(offsets, ULONG2NUM(line_offsets->offsets[index])); + } + rb_obj_freeze(source_string); rb_obj_freeze(offsets); + } else { + offsets = rb_str_new((const char *) line_offsets->offsets, line_offsets->size * sizeof(uint32_t)); } VALUE source = rb_funcall(rb_cPrismSource, rb_intern("for"), 3, source_string, LONG2NUM(pm_parser_start_line(parser)), offsets); diff --git a/spec/bundler/bundler/cli_spec.rb b/spec/bundler/bundler/cli_spec.rb index e2c64b93940157..d1e6d7d411d77d 100644 --- a/spec/bundler/bundler/cli_spec.rb +++ b/spec/bundler/bundler/cli_spec.rb @@ -100,7 +100,7 @@ def out_with_macos_man_workaround end it "runs bundle install when default_cli_command set to install" do - bundle "config set default_cli_command install" + bundle_config "default_cli_command install" bundle "", raise_on_error: false expect(out).to_not include("In a future version of Bundler") expect(err).to include("Could not locate Gemfile") @@ -135,7 +135,7 @@ def out_with_macos_man_workaround end it "prints the simulated version too when setting is enabled" do - bundle "config simulate_version 4", verbose: true + bundle "config set simulate_version 4", verbose: true bundle "info bundler", verbose: true expect(out).to start_with("Running `bundle info bundler --verbose` with bundler #{Bundler::VERSION} (simulating Bundler 4)") end @@ -143,7 +143,7 @@ def out_with_macos_man_workaround context "with verbose configuration" do before do - bundle "config verbose true" + bundle_config "verbose true" end it "prints the running command" do @@ -210,7 +210,7 @@ def out_with_macos_man_workaround let(:bundler_version) { "2.0" } let(:latest_version) { nil } before do - bundle "config set --global disable_version_check false" + bundle_config_global "disable_version_check false" pristine_system_gems "bundler-#{bundler_version}" if latest_version @@ -278,7 +278,7 @@ def out_with_macos_man_workaround bundler "--version" expect(out).to eq(Bundler::VERSION.to_s) - bundle "config simulate_version 5" + bundle_config "simulate_version 5" bundler "--version" expect(out).to eq("#{Bundler::VERSION} (simulating Bundler 5)") end diff --git a/spec/bundler/bundler/gem_helper_spec.rb b/spec/bundler/bundler/gem_helper_spec.rb index acf783908d6fb5..b4ae2abdc50e34 100644 --- a/spec/bundler/bundler/gem_helper_spec.rb +++ b/spec/bundler/bundler/gem_helper_spec.rb @@ -9,8 +9,12 @@ let(:app_gemspec_path) { app_path.join("#{app_name}.gemspec") } before(:each) do - global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false", "BUNDLE_GEM__LINTER" => "false", - "BUNDLE_GEM__CI" => "false", "BUNDLE_GEM__CHANGELOG" => "false" + bundle_config_global "gem.mit false" + bundle_config_global "gem.test false" + bundle_config_global "gem.coc false" + bundle_config_global "gem.linter false" + bundle_config_global "gem.ci false" + bundle_config_global "gem.changelog false" git("config --global init.defaultBranch main") bundle "gem #{app_name}" prepare_gemspec(app_gemspec_path) diff --git a/spec/bundler/bundler/settings_spec.rb b/spec/bundler/bundler/settings_spec.rb index 39a8b36b3d658f..e91e1641b3da20 100644 --- a/spec/bundler/bundler/settings_spec.rb +++ b/spec/bundler/bundler/settings_spec.rb @@ -318,12 +318,12 @@ let(:settings) { described_class.new(bundled_app(".bundle")) } it "converts older keys without double underscore" do - config("BUNDLE_MY__PERSONAL.MYRACK" => "~/Work/git/myrack") + bundle_config("BUNDLE_MY__PERSONAL.MYRACK" => "~/Work/git/myrack") expect(settings["my.personal.myrack"]).to eq("~/Work/git/myrack") end it "converts older keys without trailing slashes and double underscore" do - config("BUNDLE_MIRROR__HTTPS://RUBYGEMS.ORG" => "http://example-mirror.rubygems.org") + bundle_config("BUNDLE_MIRROR__HTTPS://RUBYGEMS.ORG" => "http://example-mirror.rubygems.org") expect(settings["mirror.https://rubygems.org/"]).to eq("http://example-mirror.rubygems.org") end @@ -337,7 +337,7 @@ end it "converts older keys with dashes" do - config("BUNDLE_MY-PERSONAL-SERVER__ORG" => "my-personal-server.org") + bundle_config("BUNDLE_MY-PERSONAL-SERVER__ORG" => "my-personal-server.org") expect(Bundler.ui).to receive(:warn).with( "Your #{bundled_app(".bundle/config")} config includes `BUNDLE_MY-PERSONAL-SERVER__ORG`, which contains the dash character (`-`).\n" \ "This is deprecated, because configuration through `ENV` should be possible, but `ENV` keys cannot include dashes.\n" \ @@ -347,7 +347,7 @@ end it "reads newer keys format properly" do - config("BUNDLE_MIRROR__HTTPS://RUBYGEMS__ORG/" => "http://example-mirror.rubygems.org") + bundle_config("BUNDLE_MIRROR__HTTPS://RUBYGEMS__ORG/" => "http://example-mirror.rubygems.org") expect(settings["mirror.https://rubygems.org/"]).to eq("http://example-mirror.rubygems.org") end end diff --git a/spec/bundler/cache/cache_path_spec.rb b/spec/bundler/cache/cache_path_spec.rb index d5bd14965b58cf..2a280ea8588eb2 100644 --- a/spec/bundler/cache/cache_path_spec.rb +++ b/spec/bundler/cache/cache_path_spec.rb @@ -17,7 +17,7 @@ context "with config cache_path" do it "caches gems at given path" do - bundle "config set cache_path vendor/cache-foo" + bundle_config "cache_path vendor/cache-foo" bundle :cache expect(bundled_app("vendor/cache-foo/myrack-1.0.0.gem")).to exist end diff --git a/spec/bundler/cache/gems_spec.rb b/spec/bundler/cache/gems_spec.rb index c9b85556e1ef1d..198279d84cdfb1 100644 --- a/spec/bundler/cache/gems_spec.rb +++ b/spec/bundler/cache/gems_spec.rb @@ -78,13 +78,13 @@ end context "using system gems" do - before { bundle "config set path.system true" } + before { bundle_config "path.system true" } let(:path) { system_gem_path } it_behaves_like "when there are only gemsources" end context "installing into a local path" do - before { bundle "config set path ./.bundle" } + before { bundle_config "path ./.bundle" } let(:path) { local_gem_path } it_behaves_like "when there are only gemsources" end @@ -136,7 +136,7 @@ gem "json" G - bundle "config set cache_all_platforms true" + bundle_config "cache_all_platforms true" bundle :cache expect(bundled_app("vendor/cache/json-#{default_json_version}.gem")).to exist @@ -157,14 +157,14 @@ context "when a remote gem is not available for caching" do it "warns, but uses builtin gems when installing to system gems" do - bundle "config set path.system true" + bundle_config "path.system true" install_gemfile %(source "https://gem.repo1"; gem 'json', '#{default_json_version}'), verbose: true expect(err).to include("json-#{default_json_version} is built in to Ruby, and can't be cached") expect(out).to include("Using json #{default_json_version}") end it "errors when explicitly caching" do - bundle "config set path.system true" + bundle_config "path.system true" install_gemfile <<-G source "https://gem.repo1" diff --git a/spec/bundler/cache/git_spec.rb b/spec/bundler/cache/git_spec.rb index 860f97d434219c..f0976ecac7c93e 100644 --- a/spec/bundler/cache/git_spec.rb +++ b/spec/bundler/cache/git_spec.rb @@ -22,7 +22,7 @@ gem "foo", :git => '#{lib_path("foo-1.0")}' G - bundle "config cache_all false" + bundle_config "cache_all false" bundle :cache expect(bundled_app("vendor/cache/foo-1.0-#{ref}")).not_to exist @@ -56,7 +56,7 @@ gem "foo", :git => '#{lib_path("foo-1.0")}' G - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" bundle "install" bundle :cache @@ -171,12 +171,12 @@ source "https://gem.repo1" gem "foo", :git => '#{lib_path("foo-1.0")}' G - bundle "config set path vendor/bundle" + bundle_config "path vendor/bundle" bundle :install pristine_system_gems with_path_as "" do - bundle "config set deployment true" + bundle_config "deployment true" bundle "install --local" expect(the_bundle).to include_gem "foo 1.0" end @@ -192,7 +192,7 @@ bundle :cache, "all-platforms" => true pristine_system_gems - bundle "config set frozen true" + bundle_config "frozen true" bundle "install --local --verbose" expect(out).to_not include("Fetching") expect(the_bundle).to include_gem "foo 1.0" @@ -208,7 +208,7 @@ bundle :cache, "all-platforms" => true pristine_system_gems - bundle "config set frozen true" + bundle_config "frozen true" bundle "install --local --verbose" expect(out).to_not include("Fetching") expect(the_bundle).to include_gem "foo 1.0" @@ -224,7 +224,7 @@ bundle :cache, "all-platforms" => true pristine_system_gems - bundle "config set frozen true" + bundle_config "frozen true" # Remove untracked files (including the empty refs dir in the cache) Dir.chdir(bundled_app) do @@ -248,8 +248,8 @@ source "https://gem.repo1" gem "foo", :git => '#{lib_path("foo-1.0")}' G - bundle "config set global_gem_cache false" - bundle "config path vendor/bundle" + bundle_config "global_gem_cache false" + bundle_config "path vendor/bundle" bundle :install # Simulate old cache by copying the real cache folder to vendor/cache @@ -279,8 +279,8 @@ source "https://gem.repo1" gem "foo", :git => '#{lib_path("foo-1.0")}' G - bundle "config set global_gem_cache false" - bundle "config path vendor/bundle" + bundle_config "global_gem_cache false" + bundle_config "path vendor/bundle" bundle :install # Simulate old cache by copying the real cache folder to vendor/cache @@ -308,8 +308,8 @@ source "https://gem.repo1" gem "foo", :git => '#{lib_path("foo-1.0")}' G - bundle "config set global_gem_cache false" - bundle "config path vendor/bundle" + bundle_config "global_gem_cache false" + bundle_config "path vendor/bundle" bundle :install # Simulate old cache by copying the real cache folder to vendor/cache @@ -383,7 +383,7 @@ pristine_system_gems with_path_as "" do - bundle "config set deployment true" + bundle_config "deployment true" bundle :install, local: true expect(the_bundle).to include_gem "foo 1.0" end diff --git a/spec/bundler/cache/path_spec.rb b/spec/bundler/cache/path_spec.rb index 6865e54b321fa9..42648aea1fc5a4 100644 --- a/spec/bundler/cache/path_spec.rb +++ b/spec/bundler/cache/path_spec.rb @@ -99,7 +99,7 @@ source "https://gem.repo1" gem "foo", :path => '#{lib_path("foo-1.0")}' G - bundle "config cache_all false" + bundle_config "cache_all false" bundle :cache expect(err).to be_empty diff --git a/spec/bundler/commands/add_spec.rb b/spec/bundler/commands/add_spec.rb index ed98a914f326c4..a7eacfbd7f180a 100644 --- a/spec/bundler/commands/add_spec.rb +++ b/spec/bundler/commands/add_spec.rb @@ -291,7 +291,7 @@ end it "shows error message when gem cannot be found" do - bundle "config set force_ruby_platform true" + bundle_config "force_ruby_platform true" bundle "add 'werk_it'", raise_on_error: false expect(err).to match("Could not find gem 'werk_it' in") diff --git a/spec/bundler/commands/binstubs_spec.rb b/spec/bundler/commands/binstubs_spec.rb index 306cbbc412d57e..af4d24a9e8e338 100644 --- a/spec/bundler/commands/binstubs_spec.rb +++ b/spec/bundler/commands/binstubs_spec.rb @@ -158,7 +158,7 @@ context "with the binstubs dir configured" do before do - bundle "config bin exec" + bundle_config "bin exec" end it "creates the binstubs in the configured dir" do @@ -193,7 +193,7 @@ end it "generates a standalone binstub at the given path when configured" do - bundle "config bin foo" + bundle_config "bin foo" bundle "binstubs myrack --standalone" expect(bundled_app("foo/myrackup")).to exist end @@ -313,7 +313,7 @@ gem "myrack" G - bundle "config set auto_install 1" + bundle_config "auto_install 1" bundle "binstubs myrack" expect(out).to include("Installing myrack 1.0.0") expect(the_bundle).to include_gems "myrack 1.0.0" @@ -325,7 +325,7 @@ gem "myrack" G - bundle "config set auto_install 1" + bundle_config "auto_install 1" bundle "binstubs myrack", env: { "BUNDLE_INSTALL" => "1" } expect(out).not_to include("Installing myrack 1.0.0") end diff --git a/spec/bundler/commands/cache_spec.rb b/spec/bundler/commands/cache_spec.rb index bd92a84e185315..e223d07f7fc1e7 100644 --- a/spec/bundler/commands/cache_spec.rb +++ b/spec/bundler/commands/cache_spec.rb @@ -37,7 +37,7 @@ gem 'bundler' D - bundle "config set cache_all true" + bundle_config "cache_all true" bundle :cache expect(bundled_app("vendor/cache/myrack-1.0.0.gem")).to exist @@ -68,7 +68,7 @@ gemspec D - bundle "config set cache_all true" + bundle_config "cache_all true" bundle :cache expect(bundled_app("vendor/cache/myrack-1.0.0.gem")).to exist @@ -100,7 +100,7 @@ gemspec D - bundle "config set cache_all true" + bundle_config "cache_all true" bundle :cache expect(bundled_app("vendor/cache/myrack-1.0.0.gem")).to exist @@ -145,7 +145,7 @@ gemspec :name => 'mygem_test' D - bundle "config set cache_all true" + bundle_config "cache_all true" bundle :cache expect(bundled_app("vendor/cache/myrack-1.0.0.gem")).to exist @@ -227,7 +227,7 @@ end end - bundle "config set --local without wo" + bundle_config "without wo" install_gemfile <<-G, artifice: "compact_index_extra_api" source "https://main.repo" gem "myrack" @@ -243,14 +243,14 @@ expect(the_bundle).to include_gem "myrack 1.0" expect(the_bundle).not_to include_gems "weakling", "uninstallable" - bundle "config set --local without wo" + bundle_config "without wo" bundle :install, artifice: "compact_index_extra_api" expect(the_bundle).to include_gem "myrack 1.0" expect(the_bundle).not_to include_gems "weakling" end it "does not fail to cache gems in excluded groups when there's a lockfile but gems not previously installed" do - bundle "config set --local without wo" + bundle_config "without wo" gemfile <<-G source "https://gem.repo1" gem "myrack" @@ -269,7 +269,7 @@ let(:app_cache) { bundled_app("vendor/cache") } before do - bundle "config set --local frozen true" + bundle_config "frozen true" end it "tries to install but fails when the lockfile is out of sync" do @@ -389,7 +389,7 @@ it "installs them properly from cache to a different path" do bundle "cache" - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" bundle "install --local" end end @@ -423,8 +423,8 @@ pristine_system_gems FileUtils.rm_r gem_repo2 - bundle "config set --local deployment true" - bundle "config set --local path vendor/bundle" + bundle_config "deployment true" + bundle_config "path vendor/bundle" bundle :install expect(the_bundle).to include_gems "myrack 1.0.0" end @@ -440,7 +440,7 @@ pristine_system_gems FileUtils.rm_r gem_repo2 - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" bundle :install expect(the_bundle).to include_gems "myrack 1.0.0" end @@ -456,8 +456,8 @@ pristine_system_gems FileUtils.rm_r gem_repo2 - bundle "config set --local cache_all_platforms true" - bundle "config set --local path vendor/bundle" + bundle_config "cache_all_platforms true" + bundle_config "path vendor/bundle" bundle "install --local" expect(out).not_to include("Fetching gem metadata") expect(the_bundle).to include_gems "myrack 1.0.0" @@ -506,8 +506,8 @@ L simulate_platform "x86_64-linux" do - bundle "config set cache_all_platforms true" - bundle "config set path vendor/bundle" + bundle_config "cache_all_platforms true" + bundle_config "path vendor/bundle" bundle :cache, artifice: "compact_index", env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s } # simulate removal of all remote gems @@ -549,7 +549,7 @@ pristine_system_gems - bundle "config set --local force_ruby_platform true" + bundle_config "force_ruby_platform true" install_gemfile <<-G source "https://gem.repo1" @@ -572,7 +572,7 @@ FileUtils.cp gem_repo4("gems/bcrypt_pbkdf-1.1.1-arm64-darwin.gem"), app_cache FileUtils.cp gem_repo4("gems/bcrypt_pbkdf-1.1.1.gem"), app_cache - bundle "config cache_all_platforms true" + bundle_config "cache_all_platforms true" lockfile <<~L GEM diff --git a/spec/bundler/commands/check_spec.rb b/spec/bundler/commands/check_spec.rb index 4dce7813a624f8..7fe6897ae3b5a9 100644 --- a/spec/bundler/commands/check_spec.rb +++ b/spec/bundler/commands/check_spec.rb @@ -88,7 +88,7 @@ it "prints a generic error if gem git source is not checked out" do build_git "foo", path: lib_path("foo") - bundle "config path vendor/bundle" + bundle_config "path vendor/bundle" install_gemfile <<-G source "https://gem.repo1" @@ -124,7 +124,7 @@ end it "uses the without setting" do - bundle "config set without foo" + bundle_config "without foo" install_gemfile <<-G source "https://gem.repo1" group :foo do @@ -142,7 +142,7 @@ gem "myrack", :group => :foo G - bundle "config set --local without foo" + bundle_config "without foo" bundle :install gemfile <<-G @@ -161,7 +161,7 @@ gem "myrack" G - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" bundle :cache uninstall_gem("myrack", env: { "GEM_HOME" => vendored_gems.to_s }) @@ -251,7 +251,7 @@ gem "foo" G - bundle "config set --local deployment true" + bundle_config "deployment true" bundle "install" FileUtils.rm(bundled_app_lock) @@ -499,7 +499,7 @@ build_gem "bar" end - bundle "config set path.system true" + bundle_config "path.system true" # Add all gems to ensure all gems are installed so that a bundle check # would be successful @@ -564,7 +564,7 @@ def lock_with(bundler_version = nil) end before do - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" install_gemfile <<-G source "https://gem.repo1" diff --git a/spec/bundler/commands/clean_spec.rb b/spec/bundler/commands/clean_spec.rb index 582bfd5fd1c3b1..c77859d3781205 100644 --- a/spec/bundler/commands/clean_spec.rb +++ b/spec/bundler/commands/clean_spec.rb @@ -25,8 +25,8 @@ def should_not_have_gems(*gems) gem "foo" G - bundle "config set path vendor/bundle" - bundle "config set clean false" + bundle_config "path vendor/bundle" + bundle_config "clean false" bundle "install" gemfile <<-G @@ -54,8 +54,8 @@ def should_not_have_gems(*gems) gem "foo" G - bundle "config set path vendor/bundle" - bundle "config set clean false" + bundle_config "path vendor/bundle" + bundle_config "clean false" bundle "install" gemfile <<-G @@ -84,8 +84,8 @@ def should_not_have_gems(*gems) gem "foo" G - bundle "config set path vendor/bundle" - bundle "config set clean false" + bundle_config "path vendor/bundle" + bundle_config "clean false" bundle "install" gemfile <<-G @@ -117,9 +117,9 @@ def should_not_have_gems(*gems) end G - bundle "config set path vendor/bundle" + bundle_config "path vendor/bundle" bundle "install" - bundle "config set without test_group" + bundle_config "without test_group" bundle "install" bundle :clean @@ -145,7 +145,7 @@ def should_not_have_gems(*gems) end G - bundle "config set path vendor/bundle" + bundle_config "path vendor/bundle" bundle "install" bundle :clean @@ -169,7 +169,7 @@ def should_not_have_gems(*gems) end G - bundle "config set path vendor/bundle" + bundle_config "path vendor/bundle" bundle "install" gemfile <<-G @@ -210,7 +210,7 @@ def should_not_have_gems(*gems) FileUtils.mkdir_p(bundled_app("real-path")) File.symlink(bundled_app("real-path"), bundled_app("symlink-path")) - bundle "config set path #{bundled_app("symlink-path")}" + bundle_config "path #{bundled_app("symlink-path")}" bundle "install" bundle :clean @@ -233,7 +233,7 @@ def should_not_have_gems(*gems) end G - bundle "config set path vendor/bundle" + bundle_config "path vendor/bundle" bundle "install" update_git "foo-bar", path: lib_path("foo-bar") @@ -265,7 +265,7 @@ def should_not_have_gems(*gems) gem "activesupport", :git => "#{lib_path("rails")}", :ref => '#{revision}' G - bundle "config set path vendor/bundle" + bundle_config "path vendor/bundle" bundle "install" bundle :clean expect(out).to include("") @@ -288,8 +288,8 @@ def should_not_have_gems(*gems) end end G - bundle "config set path vendor/bundle" - bundle "config set without test" + bundle_config "path vendor/bundle" + bundle_config "without test" bundle "install" bundle :clean @@ -311,15 +311,15 @@ def should_not_have_gems(*gems) end G - bundle "config set path vendor/bundle" - bundle "config set without development" + bundle_config "path vendor/bundle" + bundle_config "without development" bundle "install" bundle :clean end it "displays an error when used without --path" do - bundle "config set path.system true" + bundle_config "path.system true" install_gemfile <<-G source "https://gem.repo1" @@ -341,7 +341,7 @@ def should_not_have_gems(*gems) gem "foo" G - bundle "config set path vendor/bundle" + bundle_config "path vendor/bundle" bundle "install" gemfile <<-G @@ -364,7 +364,7 @@ def should_not_have_gems(*gems) end it "does not call clean automatically when using system gems" do - bundle "config set path.system true" + bundle_config "path.system true" install_gemfile <<-G source "https://gem.repo1" @@ -449,7 +449,7 @@ def should_not_have_gems(*gems) gem "thin" gem "myrack" G - bundle "config set path vendor/bundle" + bundle_config "path vendor/bundle" bundle "install" gemfile <<-G @@ -470,7 +470,7 @@ def should_not_have_gems(*gems) gem "foo" G - bundle "config set path vendor/bundle" + bundle_config "path vendor/bundle" bundle "install" update_repo2 do @@ -482,7 +482,7 @@ def should_not_have_gems(*gems) end it "does not clean on bundle update when installing to system gems" do - bundle "config set path.system true" + bundle_config "path.system true" build_repo2 @@ -503,7 +503,7 @@ def should_not_have_gems(*gems) end it "cleans system gems when --force is used" do - bundle "config set path.system true" + bundle_config "path.system true" gemfile <<-G source "https://gem.repo1" @@ -572,7 +572,7 @@ def should_not_have_gems(*gems) gem "foo", :git => "#{lib_path("foo-1.0")}" G - bundle "config set path vendor/bundle" + bundle_config "path vendor/bundle" bundle "install" # mimic 7 length git revisions in Gemfile.lock @@ -582,7 +582,7 @@ def should_not_have_gems(*gems) end lockfile(bundled_app_lock, gemfile_lock.join("\n")) - bundle "config set path vendor/bundle" + bundle_config "path vendor/bundle" bundle "install" bundle :clean @@ -593,7 +593,7 @@ def should_not_have_gems(*gems) end it "when using --force on system gems, it doesn't remove binaries" do - bundle "config set path.system true" + bundle_config "path.system true" build_repo2 do build_gem "bindir" do |s| @@ -649,7 +649,7 @@ def should_not_have_gems(*gems) gem "bar", "1.0", :path => "#{relative_path}" G - bundle "config set path vendor/bundle" + bundle_config "path vendor/bundle" bundle "install" bundle :clean end @@ -662,8 +662,8 @@ def should_not_have_gems(*gems) gem "foo" G - bundle "config set path vendor/bundle" - bundle "config set clean false" + bundle_config "path vendor/bundle" + bundle_config "clean false" bundle "install" gemfile <<-G @@ -692,8 +692,8 @@ def should_not_have_gems(*gems) gem "foo" G - bundle "config set path vendor/bundle" - bundle "config set clean false" + bundle_config "path vendor/bundle" + bundle_config "clean false" bundle "install" gemfile <<-G @@ -722,10 +722,10 @@ def should_not_have_gems(*gems) gem "foo" G - bundle "config set path vendor/bundle" - bundle "config set clean false" + bundle_config "path vendor/bundle" + bundle_config "clean false" bundle "install" - bundle "config set dry_run false" + bundle_config "dry_run false" gemfile <<-G source "https://gem.repo1" @@ -754,8 +754,8 @@ def should_not_have_gems(*gems) gem "foo" G - bundle "config set path vendor/bundle" - bundle "config set clean false" + bundle_config "path vendor/bundle" + bundle_config "clean false" bundle "install" gemfile <<-G @@ -765,7 +765,7 @@ def should_not_have_gems(*gems) gem "weakling" G - bundle "config set auto_install 1" + bundle_config "auto_install 1" bundle :clean expect(out).to include("Installing weakling 0.0.3") should_have_gems "thin-1.0", "myrack-1.0.0", "weakling-0.0.3" @@ -783,7 +783,7 @@ def should_not_have_gems(*gems) gem "very_simple_git_binary", :git => "#{lib_path("very_simple_git_binary-1.0")}", :ref => "#{revision}" G - bundle "config set path vendor/bundle" + bundle_config "path vendor/bundle" bundle "install" expect(vendored_gems("bundler/gems/extensions")).to exist expect(vendored_gems("bundler/gems/very_simple_git_binary-1.0-#{revision[0..11]}")).to exist @@ -804,7 +804,7 @@ def should_not_have_gems(*gems) gem "simple_binary" G - bundle "config set path vendor/bundle" + bundle_config "path vendor/bundle" bundle "install" very_simple_binary_extensions_dir = @@ -844,7 +844,7 @@ def should_not_have_gems(*gems) gem "very_simple_git_binary", :git => "#{lib_path("very_simple_git_binary-1.0")}", :ref => "#{revision}" G - bundle "config set path vendor/bundle" + bundle_config "path vendor/bundle" bundle "install" very_simple_binary_extensions_dir = @@ -888,8 +888,8 @@ def should_not_have_gems(*gems) G bundle :lock - bundle "config set without development" - bundle "config set path vendor/bundle" + bundle_config "without development" + bundle_config "path vendor/bundle" bundle "install", verbose: true bundle :clean @@ -906,7 +906,7 @@ def should_not_have_gems(*gems) gem "myrack" G - bundle "config set path vendor/bundle" + bundle_config "path vendor/bundle" bundle "install" version = Bundler.gem_version.to_s diff --git a/spec/bundler/commands/console_spec.rb b/spec/bundler/commands/console_spec.rb index ec44fe59f3a3f2..a44f60754609a1 100644 --- a/spec/bundler/commands/console_spec.rb +++ b/spec/bundler/commands/console_spec.rb @@ -124,7 +124,7 @@ def __pry__ gem "irb" gem "pry" G - bundle "config set console pry" + bundle_config "console pry" bundle "console" do |input, _, _| input.puts("__method__") @@ -136,7 +136,7 @@ def __pry__ it "falls back to IRB if the other REPL isn't available" do skip "Does not work in a ruby-core context if irb is in the default $LOAD_PATH because it enables the real IRB, not our dummy one" if ruby_core? && Gem.ruby_version < Gem::Version.new("3.5.0.a") - bundle "config set console pry" + bundle_config "console pry" # make sure pry isn't there bundle "console" do |input, _, _| @@ -201,7 +201,7 @@ def __pry__ gem "foo" G - bundle "config set auto_install 1" + bundle_config "auto_install 1" bundle :console do |input, _, _| input.puts("puts 'hello'") input.puts("exit") diff --git a/spec/bundler/commands/exec_spec.rb b/spec/bundler/commands/exec_spec.rb index 19e836053fa141..aa35685be8ff50 100644 --- a/spec/bundler/commands/exec_spec.rb +++ b/spec/bundler/commands/exec_spec.rb @@ -268,7 +268,7 @@ end end - bundle "config set --global path.system true" + bundle_config_global "path.system true" install_gemfile <<-G source "https://gem.repo1" @@ -289,7 +289,7 @@ end it "handles gems installed with --without" do - bundle "config set --local without middleware" + bundle_config "without middleware" install_gemfile <<-G source "https://gem.repo1" gem "myrack" # myrack 0.9.1 and 1.0 exist @@ -379,13 +379,13 @@ it "raises a helpful error when exec'ing to something outside of the bundle" do system_gems(%w[myrack-1.0.0 myrack-0.9.1], path: default_bundle_path) - bundle "config set clean false" # want to keep the myrackup binstub + bundle_config "clean false" # want to keep the myrackup binstub install_gemfile <<-G source "https://gem.repo1" gem "foo" G [true, false].each do |l| - bundle "config set disable_exec_load #{l}" + bundle_config "disable_exec_load #{l}" bundle "exec myrackup", raise_on_error: false expect(err).to include "can't find executable myrackup for gem myrack. myrack is not currently included in the bundle, perhaps you meant to add it to your Gemfile?" end @@ -582,7 +582,7 @@ gem "foo" G - bundle "config set auto_install 1" + bundle_config "auto_install 1" bundle "exec myrackup", artifice: "compact_index" expect(out).to include("Installing foo 1.0") end @@ -597,7 +597,7 @@ gem "foo", :git => "#{lib_path("foo-1.0")}" G - bundle "config set auto_install 1" + bundle_config "auto_install 1" bundle "exec foo", artifice: "compact_index" expect(out).to include("Fetching myrack 0.9.1") expect(out).to include("Fetching #{lib_path("foo-1.0")}") @@ -617,8 +617,8 @@ system_gems "optparse-999.999.998", gem_repo: gem_repo4 - bundle "config set auto_install 1" - bundle "config set --local path vendor/bundle" + bundle_config "auto_install 1" + bundle_config "path vendor/bundle" gemfile <<~G source "https://gem.repo4" @@ -671,7 +671,7 @@ def bin_path(a,b,c) end Bundler.rubygems.extend(Monkey) G - bundle "config set path.system true" + bundle_config "path.system true" bundle "install" bundle "exec ruby -e '`bundle -v`; puts $?.success?'", env: { "BUNDLER_VERSION" => Bundler::VERSION } expect(out).to match("true") @@ -951,7 +951,7 @@ def bin_path(a,b,c) end before do - bundle "config set disable_exec_load true" + bundle_config "disable_exec_load true" end it "runs" do @@ -1088,7 +1088,7 @@ def bin_path(a,b,c) source "https://gem.repo1" gem "myrack" G - bundle "config set path vendor/bundler" + bundle_config "path vendor/bundler" bundle :install end @@ -1155,8 +1155,8 @@ def require(path) end end - bundle "config set path vendor/bundle" - bundle "config set gemfile gemfiles/myrack_6_1.gemfile" + bundle_config "path vendor/bundle" + bundle_config "gemfile gemfiles/myrack_6_1.gemfile" gemfile(bundled_app("gemfiles/myrack_6_1.gemfile"), <<~RUBY) source "https://gem.repo2" @@ -1252,7 +1252,7 @@ def require(path) context "with a git gem that includes extensions", :ruby_repo do before do build_git "simple_git_binary", &:add_c_extension - bundle "config set --local path .bundle" + bundle_config "path .bundle" install_gemfile <<-G source "https://gem.repo1" gem "simple_git_binary", :git => '#{lib_path("simple_git_binary-1.0")}' diff --git a/spec/bundler/commands/fund_spec.rb b/spec/bundler/commands/fund_spec.rb index 6f4e61da30d777..5883b8a63ae92d 100644 --- a/spec/bundler/commands/fund_spec.rb +++ b/spec/bundler/commands/fund_spec.rb @@ -73,7 +73,7 @@ end it "considers fund information for installed optional dependencies" do - bundle "config set with whatever" + bundle_config "with whatever" install_gemfile <<-G source "https://gem.repo2" diff --git a/spec/bundler/commands/info_spec.rb b/spec/bundler/commands/info_spec.rb index f403db684f4dcf..a26b1696fbdf99 100644 --- a/spec/bundler/commands/info_spec.rb +++ b/spec/bundler/commands/info_spec.rb @@ -57,7 +57,7 @@ end it "doesn't claim that bundler is missing, even if using a custom path without bundler there" do - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" bundle "install" bundle "info bundler" expect(out).to include("\tPath: #{root}") @@ -235,7 +235,7 @@ context "with without configured" do it "does not find the gem, but gives a helpful error" do - bundle "config without test" + bundle_config "without test" install_gemfile <<-G source "https://gem.repo1" diff --git a/spec/bundler/commands/init_spec.rb b/spec/bundler/commands/init_spec.rb index 538e61fd47ee4e..989d6fa812f81f 100644 --- a/spec/bundler/commands/init_spec.rb +++ b/spec/bundler/commands/init_spec.rb @@ -119,7 +119,7 @@ end context "when init_gems_rb setting is enabled" do - before { bundle "config set init_gems_rb true" } + before { bundle_config "init_gems_rb true" } it "generates a gems.rb" do bundle :init diff --git a/spec/bundler/commands/install_spec.rb b/spec/bundler/commands/install_spec.rb index 86079e66b4d78b..bb9b2b1f98a500 100644 --- a/spec/bundler/commands/install_spec.rb +++ b/spec/bundler/commands/install_spec.rb @@ -917,7 +917,7 @@ describe "when requesting a quiet install via --quiet" do it "should be quiet if there are no warnings" do - bundle "config set force_ruby_platform true" + bundle_config "force_ruby_platform true" gemfile <<-G source "https://gem.repo1" @@ -930,7 +930,7 @@ end it "should still display warnings and errors" do - bundle "config set force_ruby_platform true" + bundle_config "force_ruby_platform true" create_file("install_with_warning.rb", <<~RUBY) require "#{lib_dir}/bundler" @@ -975,7 +975,7 @@ def run it "should display a proper message to explain the problem" do FileUtils.chmod(0o500, bundle_path) - bundle "config set --local path vendor" + bundle_config "path vendor" bundle :install, raise_on_error: false expect(err).to include(bundle_path.to_s) expect(err).to include("grant executable permissions") @@ -995,7 +995,7 @@ def run it "should display a proper message to explain the problem" do FileUtils.chmod("-x", gems_path) - bundle "config set --local path vendor" + bundle_config "path vendor" begin bundle :install, raise_on_error: false @@ -1025,7 +1025,7 @@ def run it "should display a proper message to explain the problem" do FileUtils.chmod("-x", full_gem_path) - bundle "config set --local path vendor" + bundle_config "path vendor" begin bundle :install, raise_on_error: false @@ -1055,7 +1055,7 @@ def run it "should display a proper message to explain the problem" do FileUtils.chmod("-x", bin_dir) - bundle "config set --local path vendor" + bundle_config "path vendor" begin bundle :install, raise_on_error: false @@ -1085,7 +1085,7 @@ def run it "should display a proper message to explain the problem" do FileUtils.chmod("-w", bin_dir) - bundle "config set --local path vendor" + bundle_config "path vendor" begin bundle :install, raise_on_error: false @@ -1115,7 +1115,7 @@ def run it "should display a proper message to explain the problem" do FileUtils.chmod("-x", extensions_path) - bundle "config set --local path vendor" + bundle_config "path vendor" begin bundle :install, raise_on_error: false @@ -1150,7 +1150,7 @@ def run end it "should display a proper message to explain the problem" do - bundle "config set --local path vendor" + bundle_config "path vendor" bundle :install expect(out).to include("Bundle complete!") expect(err).to be_empty @@ -1186,7 +1186,7 @@ def run end it "should still work" do - bundle "config set --local path vendor" + bundle_config "path vendor" bundle :install expect(out).to include("Bundle complete!") expect(err).to be_empty @@ -1221,7 +1221,7 @@ def run end it "should display a proper message to explain the problem" do - bundle "config set --local path vendor" + bundle_config "path vendor" bundle :install expect(out).to include("Bundle complete!") expect(err).to be_empty @@ -1252,7 +1252,7 @@ def run end it "does not try to remove the directory and thus don't abort with an error about unsafe directory removal" do - bundle "config set --local path vendor" + bundle_config "path vendor" FileUtils.mkdir_p(gems_path) FileUtils.chmod(0o777, gems_path) @@ -1276,7 +1276,7 @@ def run it "should display a proper message to explain the problem" do FileUtils.chmod(0o500, cache_path) - bundle "config set --local path vendor" + bundle_config "path vendor" bundle :install, raise_on_error: false expect(err).to include(cache_path.to_s) expect(err).to include("grant write permissions") @@ -1291,7 +1291,7 @@ def run source "https://gem.repo1" gem 'myrack' G - bundle "config path vendor/bundle" + bundle_config "path vendor/bundle" bundle :install expect(out).to include("Bundle complete!") expect(err).to be_empty @@ -1399,7 +1399,7 @@ def run end it "works" do - bundle "config path #{app_path}/vendor/bundle", dir: app_path + bundle "config set path #{app_path}/vendor/bundle", dir: app_path install_gemfile app_path.join("Gemfile"),<<~G, dir: app_path source "https://gem.repo4" @@ -1414,7 +1414,7 @@ def run source "https://gem.repo1" gem "myrack" G - bundle "config set --local path bundle" + bundle_config "path bundle" bundle "install", standalone: true end @@ -1504,7 +1504,7 @@ def run end it "fails loudly if frozen mode set" do - bundle "config set --local deployment true" + bundle_config "deployment true" bundle "install", raise_on_error: false expect(err).to eq( @@ -1580,7 +1580,7 @@ def run end it "automatically fixes the lockfile" do - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" simulate_platform "x86_64-linux" do bundle "install", artifice: "compact_index" @@ -1654,7 +1654,7 @@ def run end it "raises a clear error message when frozen" do - bundle "config set frozen true" + bundle_config "frozen true" bundle "install", raise_on_error: false expect(exitstatus).to eq(41) @@ -1666,7 +1666,7 @@ def run missing_dep = "myrack (0.9.1)" expect(lockfile).not_to include(missing_dep) - bundle "config set frozen false" + bundle_config "frozen false" bundle :install expect(lockfile).to include(missing_dep) @@ -1694,7 +1694,7 @@ def run context "with only option" do before do - bundle "config set only a:b" + bundle_config "only a:b" end it "installs only gems of the specified groups" do @@ -1808,7 +1808,7 @@ def run before do symlinked_bundled_app = tmp("bundled_app-symlink") File.symlink(bundled_app, symlinked_bundled_app) - bundle "config path #{File.join(symlinked_bundled_app, ".vendor")}" + bundle_config "path #{File.join(symlinked_bundled_app, ".vendor")}" binman_path = tmp("binman") FileUtils.mkdir_p binman_path @@ -1947,7 +1947,7 @@ def run end it "only installs executable files in bin" do - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" install_gemfile <<~G source "https://gem.repo1" diff --git a/spec/bundler/commands/licenses_spec.rb b/spec/bundler/commands/licenses_spec.rb index bfec938efd2c55..ebfad5ed4ace5f 100644 --- a/spec/bundler/commands/licenses_spec.rb +++ b/spec/bundler/commands/licenses_spec.rb @@ -30,7 +30,7 @@ gem "foo" G - bundle "config set auto_install 1" + bundle_config "auto_install 1" bundle :licenses expect(out).to include("Installing foo 1.0") end diff --git a/spec/bundler/commands/lock_spec.rb b/spec/bundler/commands/lock_spec.rb index c8af9c8dd404fb..d19a610003bf1b 100644 --- a/spec/bundler/commands/lock_spec.rb +++ b/spec/bundler/commands/lock_spec.rb @@ -677,8 +677,8 @@ gem "thin" gem "myrack_middleware", :group => "test" G - bundle "config set without test" - bundle "config set path vendor/bundle" + bundle_config "without test" + bundle_config "path vendor/bundle" bundle "lock", verbose: true expect(bundled_app("vendor/bundle")).not_to exist end @@ -937,7 +937,7 @@ platform_specific L - bundle "config set force_ruby_platform true" + bundle_config "force_ruby_platform true" bundle "lock --add-platform java x86-mingw32" allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) @@ -1112,7 +1112,7 @@ #{Bundler::VERSION} G - bundle "config set --local force_ruby_platform true" + bundle_config "force_ruby_platform true" bundle :lock checksums.checksum gem_repo4, "ffi", "1.9.14" @@ -2195,7 +2195,7 @@ end end - bundle "config lockfile_checksums false" + bundle_config "lockfile_checksums false" simulate_platform "x86_64-linux" do install_gemfile <<-G @@ -2229,7 +2229,7 @@ build_gem "warning", "18.0.0" end - bundle "config lockfile_checksums false" + bundle_config "lockfile_checksums false" simulate_platform "x86_64-linux" do install_gemfile(<<-G, artifice: "endpoint") diff --git a/spec/bundler/commands/newgem_spec.rb b/spec/bundler/commands/newgem_spec.rb index 15564544e35e06..0053e0d8459cf9 100644 --- a/spec/bundler/commands/newgem_spec.rb +++ b/spec/bundler/commands/newgem_spec.rb @@ -47,8 +47,13 @@ def installed_go? git("config --global user.email user@example.com") git("config --global github.user bundleuser") - global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false", "BUNDLE_GEM__LINTER" => "false", - "BUNDLE_GEM__CI" => "false", "BUNDLE_GEM__CHANGELOG" => "false", "BUNDLE_GEM__BUNDLE" => "false" + bundle_config_global "gem.mit false" + bundle_config_global "gem.test false" + bundle_config_global "gem.coc false" + bundle_config_global "gem.linter false" + bundle_config_global "gem.ci false" + bundle_config_global "gem.changelog false" + bundle_config_global "gem.bundle false" end describe "git repo initialization" do @@ -524,7 +529,7 @@ def create_temporary_dir(dir) shared_examples_for "github_username configuration" do context "with github_username setting set to some value" do before do - global_config "BUNDLE_GEM__GITHUB_USERNAME" => "different_username" + bundle_config_global "gem.github_username different_username" bundle "gem #{gem_name}" end @@ -540,7 +545,7 @@ def create_temporary_dir(dir) context "with github_username setting set to false" do before do - global_config "BUNDLE_GEM__GITHUB_USERNAME" => "false" + bundle_config_global "gem.github_username false" bundle "gem #{gem_name}" end @@ -744,7 +749,7 @@ def create_temporary_dir(dir) context "init_gems_rb setting to true" do before do - bundle "config set init_gems_rb true" + bundle_config "init_gems_rb true" bundle "gem #{gem_name}" end @@ -762,7 +767,7 @@ def create_temporary_dir(dir) context "init_gems_rb setting to false" do before do - bundle "config set init_gems_rb false" + bundle_config "init_gems_rb false" bundle "gem #{gem_name}" end @@ -780,7 +785,7 @@ def create_temporary_dir(dir) context "gem.test setting set to rspec" do before do - bundle "config set gem.test rspec" + bundle_config "gem.test rspec" bundle "gem #{gem_name}" end @@ -798,7 +803,7 @@ def create_temporary_dir(dir) context "gem.test setting set to rspec and --test is set to minitest" do before do - bundle "config set gem.test rspec" + bundle_config "gem.test rspec" bundle "gem #{gem_name} --test=minitest" end @@ -853,7 +858,7 @@ def create_temporary_dir(dir) context "gem.test setting set to minitest" do before do - bundle "config set gem.test minitest" + bundle_config "gem.test minitest" bundle "gem #{gem_name}" end @@ -929,7 +934,7 @@ def create_temporary_dir(dir) context "gem.test set to rspec and --test with no arguments" do before do - bundle "config set gem.test rspec" + bundle_config "gem.test rspec" bundle "gem #{gem_name} --test" end @@ -951,7 +956,7 @@ def create_temporary_dir(dir) context "gem.test setting set to false and --test with no arguments", :readline do before do - bundle "config set gem.test false" + bundle_config "gem.test false" bundle "gem #{gem_name} --test" do |input, _, _| input.puts end @@ -970,7 +975,7 @@ def create_temporary_dir(dir) context "gem.test setting not set and --test with no arguments", :readline do before do - global_config "BUNDLE_GEM__TEST" => nil + bundle_config_global "BUNDLE_GEM__TEST" => nil bundle "gem #{gem_name} --test" do |input, _, _| input.puts end @@ -991,7 +996,7 @@ def create_temporary_dir(dir) context "gem.test setting set to a test framework and --no-test" do before do - bundle "config set gem.test rspec" + bundle_config "gem.test rspec" bundle "gem #{gem_name} --no-test" end @@ -1079,7 +1084,7 @@ def create_temporary_dir(dir) context "gem.ci setting set to github" do it "generates a GitHub Actions config file" do - bundle "config set gem.ci github" + bundle_config "gem.ci github" bundle "gem #{gem_name}" expect(bundled_app("#{gem_name}/.github/workflows/main.yml")).to exist @@ -1088,7 +1093,7 @@ def create_temporary_dir(dir) context "gem.ci setting set to gitlab" do it "generates a GitLab CI config file" do - bundle "config set gem.ci gitlab" + bundle_config "gem.ci gitlab" bundle "gem #{gem_name}" expect(bundled_app("#{gem_name}/.gitlab-ci.yml")).to exist @@ -1097,7 +1102,7 @@ def create_temporary_dir(dir) context "gem.ci setting set to circle" do it "generates a CircleCI config file" do - bundle "config set gem.ci circle" + bundle_config "gem.ci circle" bundle "gem #{gem_name}" expect(bundled_app("#{gem_name}/.circleci/config.yml")).to exist @@ -1106,7 +1111,7 @@ def create_temporary_dir(dir) context "gem.ci set to github and --ci with no arguments" do before do - bundle "config set gem.ci github" + bundle_config "gem.ci github" bundle "gem #{gem_name} --ci" end @@ -1121,7 +1126,7 @@ def create_temporary_dir(dir) context "gem.ci setting set to false and --ci with no arguments", :readline do before do - bundle "config set gem.ci false" + bundle_config "gem.ci false" bundle "gem #{gem_name} --ci" do |input, _, _| input.puts "github" end @@ -1138,7 +1143,7 @@ def create_temporary_dir(dir) context "gem.ci setting not set and --ci with no arguments", :readline do before do - global_config "BUNDLE_GEM__CI" => nil + bundle_config_global "BUNDLE_GEM__CI" => nil bundle "gem #{gem_name} --ci" do |input, _, _| input.puts "github" end @@ -1157,7 +1162,7 @@ def create_temporary_dir(dir) context "gem.ci setting set to a CI service and --no-ci" do before do - bundle "config set gem.ci github" + bundle_config "gem.ci github" bundle "gem #{gem_name} --no-ci" end @@ -1245,7 +1250,7 @@ def create_temporary_dir(dir) context "gem.linter setting set to rubocop" do before do - bundle "config set gem.linter rubocop" + bundle_config "gem.linter rubocop" bundle "gem #{gem_name}" end @@ -1260,7 +1265,7 @@ def create_temporary_dir(dir) context "gem.linter setting set to standard" do before do - bundle "config set gem.linter standard" + bundle_config "gem.linter standard" bundle "gem #{gem_name}" end @@ -1275,7 +1280,7 @@ def create_temporary_dir(dir) context "gem.linter set to rubocop and --linter with no arguments" do before do - bundle "config set gem.linter rubocop" + bundle_config "gem.linter rubocop" bundle "gem #{gem_name} --linter" end @@ -1294,7 +1299,7 @@ def create_temporary_dir(dir) context "gem.linter setting set to false and --linter with no arguments", :readline do before do - bundle "config set gem.linter false" + bundle_config "gem.linter false" bundle "gem #{gem_name} --linter" do |input, _, _| input.puts "rubocop" end @@ -1311,7 +1316,7 @@ def create_temporary_dir(dir) context "gem.linter setting not set and --linter with no arguments", :readline do before do - global_config "BUNDLE_GEM__LINTER" => nil + bundle_config_global "BUNDLE_GEM__LINTER" => nil bundle "gem #{gem_name} --linter" do |input, _, _| input.puts "rubocop" end @@ -1330,7 +1335,7 @@ def create_temporary_dir(dir) context "gem.linter setting set to a linter and --no-linter" do before do - bundle "config set gem.linter rubocop" + bundle_config "gem.linter rubocop" bundle "gem #{gem_name} --no-linter" end @@ -1433,7 +1438,7 @@ def create_temporary_dir(dir) context "with mit option in bundle config settings set to true" do before do - global_config "BUNDLE_GEM__MIT" => "true" + bundle_config_global "gem.mit true" end it_behaves_like "--mit flag" it_behaves_like "--no-mit flag" @@ -1441,7 +1446,7 @@ def create_temporary_dir(dir) context "with mit option in bundle config settings set to false" do before do - global_config "BUNDLE_GEM__MIT" => "false" + bundle_config_global "gem.mit false" end it_behaves_like "--mit flag" it_behaves_like "--no-mit flag" @@ -1449,7 +1454,7 @@ def create_temporary_dir(dir) context "with coc option in bundle config settings set to true" do before do - global_config "BUNDLE_GEM__COC" => "true" + bundle_config_global "gem.coc true" end it_behaves_like "--coc flag" it_behaves_like "--no-coc flag" @@ -1457,7 +1462,7 @@ def create_temporary_dir(dir) context "with coc option in bundle config settings set to false" do before do - global_config "BUNDLE_GEM__COC" => "false" + bundle_config_global "gem.coc false" end it_behaves_like "--coc flag" it_behaves_like "--no-coc flag" @@ -1465,7 +1470,7 @@ def create_temporary_dir(dir) context "with rubocop option in bundle config settings set to true" do before do - global_config "BUNDLE_GEM__RUBOCOP" => "true" + bundle_config_global "gem.rubocop true" end it_behaves_like "--linter=rubocop flag" it_behaves_like "--linter=standard flag" @@ -1474,7 +1479,7 @@ def create_temporary_dir(dir) context "with rubocop option in bundle config settings set to false" do before do - global_config "BUNDLE_GEM__RUBOCOP" => "false" + bundle_config_global "gem.rubocop false" end it_behaves_like "--linter=rubocop flag" it_behaves_like "--linter=standard flag" @@ -1483,7 +1488,7 @@ def create_temporary_dir(dir) context "with linter option in bundle config settings set to rubocop" do before do - global_config "BUNDLE_GEM__LINTER" => "rubocop" + bundle_config_global "gem.linter rubocop" end it_behaves_like "--linter=rubocop flag" it_behaves_like "--linter=standard flag" @@ -1492,7 +1497,7 @@ def create_temporary_dir(dir) context "with linter option in bundle config settings set to standard" do before do - global_config "BUNDLE_GEM__LINTER" => "standard" + bundle_config_global "gem.linter standard" end it_behaves_like "--linter=rubocop flag" it_behaves_like "--linter=standard flag" @@ -1501,7 +1506,7 @@ def create_temporary_dir(dir) context "with linter option in bundle config settings set to false" do before do - global_config "BUNDLE_GEM__LINTER" => "false" + bundle_config_global "gem.linter false" end it_behaves_like "--linter=rubocop flag" it_behaves_like "--linter=standard flag" @@ -1510,7 +1515,7 @@ def create_temporary_dir(dir) context "with changelog option in bundle config settings set to true" do before do - global_config "BUNDLE_GEM__CHANGELOG" => "true" + bundle_config_global "gem.changelog true" end it_behaves_like "--changelog flag" it_behaves_like "--no-changelog flag" @@ -1518,7 +1523,7 @@ def create_temporary_dir(dir) context "with changelog option in bundle config settings set to false" do before do - global_config "BUNDLE_GEM__CHANGELOG" => "false" + bundle_config_global "gem.changelog false" end it_behaves_like "--changelog flag" it_behaves_like "--no-changelog flag" @@ -1526,7 +1531,7 @@ def create_temporary_dir(dir) context "with bundle option in bundle config settings set to true" do before do - global_config "BUNDLE_GEM__BUNDLE" => "true" + bundle_config_global "gem.bundle true" end it_behaves_like "--bundle flag" it_behaves_like "--no-bundle flag" @@ -1539,7 +1544,7 @@ def create_temporary_dir(dir) context "with bundle option in bundle config settings set to false" do before do - global_config "BUNDLE_GEM__BUNDLE" => "false" + bundle_config_global "gem.bundle false" end it_behaves_like "--bundle flag" it_behaves_like "--no-bundle flag" @@ -1556,7 +1561,7 @@ def create_temporary_dir(dir) end context "with github-username option in bundle config settings set to some value" do before do - global_config "BUNDLE_GEM__GITHUB_USERNAME" => "different_username" + bundle_config_global "gem.github_username different_username" end it_behaves_like "--github-username option", "gh_user" end @@ -1565,7 +1570,7 @@ def create_temporary_dir(dir) context "with github-username option in bundle config settings set to false" do before do - global_config "BUNDLE_GEM__GITHUB_USERNAME" => "false" + bundle_config_global "gem.github_username false" end it_behaves_like "--github-username option", "gh_user" end @@ -1597,7 +1602,7 @@ def create_temporary_dir(dir) context "with git config github.user set" do context "with github-username option in bundle config settings set to some value" do before do - global_config "BUNDLE_GEM__GITHUB_USERNAME" => "different_username" + bundle_config_global "gem.github_username different_username" end it_behaves_like "--github-username option", "gh_user" end @@ -1606,7 +1611,7 @@ def create_temporary_dir(dir) context "with github-username option in bundle config settings set to false" do before do - global_config "BUNDLE_GEM__GITHUB_USERNAME" => "false" + bundle_config_global "gem.github_username false" end it_behaves_like "--github-username option", "gh_user" end @@ -2031,7 +2036,7 @@ def setup_rust_env context "on first run", :readline do it "asks about test framework" do - global_config "BUNDLE_GEM__TEST" => nil + bundle_config_global "BUNDLE_GEM__TEST" => nil bundle "gem foobar" do |input, _, _| input.puts "rspec" @@ -2054,7 +2059,7 @@ def setup_rust_env end it "asks about CI service" do - global_config "BUNDLE_GEM__CI" => nil + bundle_config_global "BUNDLE_GEM__CI" => nil bundle "gem foobar" do |input, _, _| input.puts "github" @@ -2064,7 +2069,7 @@ def setup_rust_env end it "asks about MIT license just once" do - global_config "BUNDLE_GEM__MIT" => nil + bundle_config_global "BUNDLE_GEM__MIT" => nil bundle "config list" @@ -2077,7 +2082,7 @@ def setup_rust_env end it "asks about CoC just once" do - global_config "BUNDLE_GEM__COC" => nil + bundle_config_global "BUNDLE_GEM__COC" => nil bundle "gem foobar" do |input, _, _| input.puts "yes" @@ -2088,7 +2093,7 @@ def setup_rust_env end it "asks about CHANGELOG just once" do - global_config "BUNDLE_GEM__CHANGELOG" => nil + bundle_config_global "BUNDLE_GEM__CHANGELOG" => nil bundle "gem foobar" do |input, _, _| input.puts "yes" diff --git a/spec/bundler/commands/open_spec.rb b/spec/bundler/commands/open_spec.rb index 77e7815017ee55..664dc58919cf62 100644 --- a/spec/bundler/commands/open_spec.rb +++ b/spec/bundler/commands/open_spec.rb @@ -139,7 +139,7 @@ gem "foo" G - bundle "config set auto_install 1" + bundle_config "auto_install 1" bundle "open rails", env: { "EDITOR" => "echo editor", "VISUAL" => "", "BUNDLER_EDITOR" => "" } expect(out).to include("Installing foo 1.0") end diff --git a/spec/bundler/commands/outdated_spec.rb b/spec/bundler/commands/outdated_spec.rb index e5460e55a5ab9c..28ed51d61e5b6a 100644 --- a/spec/bundler/commands/outdated_spec.rb +++ b/spec/bundler/commands/outdated_spec.rb @@ -120,7 +120,7 @@ end it "shows the location of the latest version's gemspec if installed" do - bundle "config set clean false" + bundle_config "clean false" update_repo2 { build_gem "activesupport", "3.0" } update_repo2 { build_gem "terranova", "9" } @@ -333,7 +333,7 @@ def test_group_option(group) build_gem "activesupport", "2.3.4" end - bundle "config set clean false" + bundle_config "clean false" install_gemfile <<-G source "https://gem.repo2" @@ -748,7 +748,7 @@ def test_group_option(group) gem "foo" G - bundle "config set auto_install 1" + bundle_config "auto_install 1" bundle :outdated, raise_on_error: false expect(out).to include("Installing foo 1.0") end @@ -764,7 +764,7 @@ def test_group_option(group) gem "foo" G bundle :lock - bundle "config deployment true" + bundle_config "deployment true" end it "outputs a helpful message about being in deployment mode" do @@ -792,7 +792,7 @@ def test_group_option(group) gem "myrack" gem "foo" G - bundle "config set --local deployment true" + bundle_config "deployment true" end it "outputs a helpful message about being in deployment mode" do diff --git a/spec/bundler/commands/post_bundle_message_spec.rb b/spec/bundler/commands/post_bundle_message_spec.rb index 9eecff593f7e33..088fc29fe1d385 100644 --- a/spec/bundler/commands/post_bundle_message_spec.rb +++ b/spec/bundler/commands/post_bundle_message_spec.rb @@ -22,7 +22,7 @@ describe "when installing to system gems" do before do - bundle "config set --local path.system true" + bundle_config "path.system true" end it "shows proper messages according to the configured groups" do @@ -32,21 +32,21 @@ expect(out).to include(bundle_complete_message) expect(out).to include(installed_gems_stats) - bundle "config set --local without emo" + bundle_config "without emo" bundle :install expect(out).to include(bundle_show_system_message) expect(out).to include("Gems in the group 'emo' were not installed") expect(out).to include(bundle_complete_message) expect(out).to include(installed_gems_stats) - bundle "config set --local without emo test" + bundle_config "without emo test" bundle :install expect(out).to include(bundle_show_system_message) expect(out).to include("Gems in the groups 'emo' and 'test' were not installed") expect(out).to include(bundle_complete_message) expect(out).to include("4 Gemfile dependencies, 2 gems now installed.") - bundle "config set --local without emo obama test" + bundle_config "without emo obama test" bundle :install expect(out).to include(bundle_show_system_message) expect(out).to include("Gems in the groups 'emo', 'obama' and 'test' were not installed") @@ -69,28 +69,28 @@ let(:bundle_path) { "./vendor" } it "shows proper messages according to the configured groups" do - bundle "config set --local path vendor" + bundle_config "path vendor" bundle :install expect(out).to include(bundle_show_path_message) expect(out).to_not include("Gems in the group") expect(out).to include(bundle_complete_message) - bundle "config set --local path vendor" - bundle "config set --local without emo" + bundle_config "path vendor" + bundle_config "without emo" bundle :install expect(out).to include(bundle_show_path_message) expect(out).to include("Gems in the group 'emo' were not installed") expect(out).to include(bundle_complete_message) - bundle "config set --local path vendor" - bundle "config set --local without emo test" + bundle_config "path vendor" + bundle_config "without emo test" bundle :install expect(out).to include(bundle_show_path_message) expect(out).to include("Gems in the groups 'emo' and 'test' were not installed") expect(out).to include(bundle_complete_message) - bundle "config set --local path vendor" - bundle "config set --local without emo obama test" + bundle_config "path vendor" + bundle_config "without emo obama test" bundle :install expect(out).to include(bundle_show_path_message) expect(out).to include("Gems in the groups 'emo', 'obama' and 'test' were not installed") @@ -102,7 +102,7 @@ let(:bundle_path) { bundled_app("cache") } it "shows proper messages according to the configured groups" do - bundle "config set --local path #{bundle_path}" + bundle_config "path #{bundle_path}" bundle :install expect(out).to include("Bundled gems are installed into `./cache`") expect(out).to_not include("Gems in the group") @@ -114,7 +114,7 @@ let(:bundle_path) { tmp("not_bundled_app") } it "shows proper messages according to the configured groups" do - bundle "config set --local path #{bundle_path}" + bundle_config "path #{bundle_path}" bundle :install expect(out).to include("Bundled gems are installed into `#{tmp("not_bundled_app")}`") expect(out).to_not include("Gems in the group") @@ -124,7 +124,7 @@ describe "with misspelled or non-existent gem name" do before do - bundle "config set force_ruby_platform true" + bundle_config "force_ruby_platform true" end it "should report a helpful error message" do @@ -161,19 +161,19 @@ expect(out).not_to include("Gems in the groups") expect(out).to include(bundle_updated_message) - bundle "config set --local without emo" + bundle_config "without emo" bundle :install bundle :update, all: true expect(out).to include("Gems in the group 'emo' were not updated") expect(out).to include(bundle_updated_message) - bundle "config set --local without emo test" + bundle_config "without emo test" bundle :install bundle :update, all: true expect(out).to include("Gems in the groups 'emo' and 'test' were not updated") expect(out).to include(bundle_updated_message) - bundle "config set --local without emo obama test" + bundle_config "without emo obama test" bundle :install bundle :update, all: true expect(out).to include("Gems in the groups 'emo', 'obama' and 'test' were not updated") diff --git a/spec/bundler/commands/pristine_spec.rb b/spec/bundler/commands/pristine_spec.rb index daeafea43bf87e..5f80b9e5348b21 100644 --- a/spec/bundler/commands/pristine_spec.rb +++ b/spec/bundler/commands/pristine_spec.rb @@ -79,7 +79,7 @@ it "displays warning and ignores changes when a local config exists" do spec = find_spec("foo") - bundle "config set local.#{spec.name} #{lib_path(spec.name)}" + bundle_config "local.#{spec.name} #{lib_path(spec.name)}" changes_txt = Pathname.new(spec.full_gem_path).join("lib/changes.txt") FileUtils.touch(changes_txt) @@ -227,7 +227,7 @@ let(:very_simple_binary) { find_spec("very_simple_binary") } let(:c_ext_dir) { Pathname.new(very_simple_binary.full_gem_path).join("ext") } let(:build_opt) { "--with-ext-lib=#{c_ext_dir}" } - before { bundle "config set build.very_simple_binary -- #{build_opt}" } + before { bundle_config "build.very_simple_binary -- #{build_opt}" } # This just verifies that the generated Makefile from the c_ext gem makes # use of the build_args from the bundle config @@ -244,7 +244,7 @@ let(:git_with_ext) { find_spec("git_with_ext") } let(:c_ext_dir) { Pathname.new(git_with_ext.full_gem_path).join("ext") } let(:build_opt) { "--with-ext-lib=#{c_ext_dir}" } - before { bundle "config set build.git_with_ext -- #{build_opt}" } + before { bundle_config "build.git_with_ext -- #{build_opt}" } # This just verifies that the generated Makefile from the c_ext gem makes # use of the build_args from the bundle config diff --git a/spec/bundler/commands/show_spec.rb b/spec/bundler/commands/show_spec.rb index 34e809f1358191..d0d55ffbb9b09b 100644 --- a/spec/bundler/commands/show_spec.rb +++ b/spec/bundler/commands/show_spec.rb @@ -179,7 +179,7 @@ gem "foo" G - bundle "config set auto_install 1" + bundle_config "auto_install 1" bundle :show expect(out).to include("Installing foo 1.0") end diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb index 3fc6bd38e41ab9..9bc5a8e1d187b7 100644 --- a/spec/bundler/commands/update_spec.rb +++ b/spec/bundler/commands/update_spec.rb @@ -110,7 +110,7 @@ end context "when update_requires_all_flag is set" do - before { bundle "config set update_requires_all_flag true" } + before { bundle_config "update_requires_all_flag true" } it "errors when passed nothing" do install_gemfile "source 'https://gem.repo1'" @@ -816,7 +816,7 @@ end it "should fail loudly" do - bundle "config deployment true" + bundle_config "deployment true" bundle "update", all: true, raise_on_error: false expect(last_command).to be_failure @@ -828,7 +828,7 @@ end it "should fail loudly when frozen is set globally" do - bundle "config set --global frozen 1" + bundle_config_global "frozen 1" bundle "update", all: true, raise_on_error: false expect(err).to eq <<~ERROR.strip Bundler is unlocking, but the lockfile can't be updated because frozen mode is set @@ -838,7 +838,7 @@ end it "should fail loudly when deployment is set globally" do - bundle "config set --global deployment true" + bundle_config_global "deployment true" bundle "update", all: true, raise_on_error: false expect(err).to eq <<~ERROR.strip Bundler is unlocking, but the lockfile can't be updated because frozen mode is set @@ -1525,7 +1525,7 @@ end it "updates the bundler version in the lockfile even if the latest version is not installed", :ruby_repo do - bundle "config path.system true" + bundle_config "path.system true" pristine_system_gems "bundler-9.0.0" @@ -1837,7 +1837,7 @@ context "with patch set as default update level in config" do it "should do a patch level update" do - bundle "config set --local prefer_patch true" + bundle_config "prefer_patch true" bundle "update foo" expect(the_bundle).to include_gems "foo 1.4.5", "bar 2.1.1", "qux 1.0.0" diff --git a/spec/bundler/commands/version_spec.rb b/spec/bundler/commands/version_spec.rb index 995a6e1e2063c3..4320ad0611a2f7 100644 --- a/spec/bundler/commands/version_spec.rb +++ b/spec/bundler/commands/version_spec.rb @@ -14,7 +14,7 @@ bundle "-v" expect(out).to eq(Bundler::VERSION.to_s) - bundle "config simulate_version 5" + bundle_config "simulate_version 5" bundle "-v" expect(out).to eq("#{Bundler::VERSION} (simulating Bundler 5)") end @@ -25,7 +25,7 @@ bundle "--version" expect(out).to eq(Bundler::VERSION.to_s) - bundle "config simulate_version 5" + bundle_config "simulate_version 5" bundle "--version" expect(out).to eq("#{Bundler::VERSION} (simulating Bundler 5)") end @@ -41,7 +41,7 @@ bundle "version" expect(out).to match(/\A4\.9\.9 \(2100-01-01 commit #{COMMIT_HASH}\)\z/) - bundle "config simulate_version 5" + bundle_config "simulate_version 5" bundle "version" expect(out).to match(/\A4\.9\.9 \(simulating Bundler 5\) \(2100-01-01 commit #{COMMIT_HASH}\)\z/) end @@ -56,7 +56,7 @@ bundle "version" expect(out).to match(/\A4\.9\.9 \(20\d{2}-\d{2}-\d{2} commit #{COMMIT_HASH}\)\z/) - bundle "config simulate_version 5" + bundle_config "simulate_version 5" bundle "version" expect(out).to match(/\A4\.9\.9 \(simulating Bundler 5\) \(20\d{2}-\d{2}-\d{2} commit #{COMMIT_HASH}\)\z/) end diff --git a/spec/bundler/install/allow_offline_install_spec.rb b/spec/bundler/install/allow_offline_install_spec.rb index 4889dbc943551a..c7ab7c3d7e513c 100644 --- a/spec/bundler/install/allow_offline_install_spec.rb +++ b/spec/bundler/install/allow_offline_install_spec.rb @@ -24,7 +24,7 @@ it "will install from the compact index" do system_gems ["myrack-1.0.0"], path: default_bundle_path - bundle "config set clean false" + bundle_config "clean false" install_gemfile <<-G, artifice: "compact_index" source "http://testgemserver.local" gem "myrack-obama" diff --git a/spec/bundler/install/binstubs_spec.rb b/spec/bundler/install/binstubs_spec.rb index 00765ac6dd6813..c2eccb3ef234f0 100644 --- a/spec/bundler/install/binstubs_spec.rb +++ b/spec/bundler/install/binstubs_spec.rb @@ -10,7 +10,7 @@ def Gem.bindir; "/usr/bin"; end gem "myrack" G - config "BUNDLE_SYSTEM_BINDIR" => system_gem_path("altbin").to_s + bundle_config "BUNDLE_SYSTEM_BINDIR" => system_gem_path("altbin").to_s bundle :install expect(the_bundle).to include_gems "myrack 1.0.0" expect(system_gem_path("altbin/myrackup")).to exist diff --git a/spec/bundler/install/bundler_spec.rb b/spec/bundler/install/bundler_spec.rb index 56f843118166ac..86c22dad556255 100644 --- a/spec/bundler/install/bundler_spec.rb +++ b/spec/bundler/install/bundler_spec.rb @@ -135,7 +135,7 @@ end it "causes a conflict if child dependencies conflict" do - bundle "config set force_ruby_platform true" + bundle_config "force_ruby_platform true" update_repo2 do build_gem "rails_pinned_to_old_activesupport" do |s| @@ -163,7 +163,7 @@ end it "causes a conflict if a child dependency conflicts with the Gemfile" do - bundle "config set force_ruby_platform true" + bundle_config "force_ruby_platform true" update_repo2 do build_gem "rails_pinned_to_old_activesupport" do |s| @@ -216,7 +216,7 @@ build_gem "rails", "7.0.4" end - bundle "config set path.system true" + bundle_config "path.system true" install_gemfile <<-G source "https://gem.repo4" @@ -238,7 +238,7 @@ end it "can install dependencies with newer bundler version with system gems" do - bundle "config set path.system true" + bundle_config "path.system true" system_gems "bundler-99999999.99.1" @@ -252,7 +252,7 @@ end it "can install dependencies with newer bundler version with a local path" do - bundle "config set path .bundle" + bundle_config "path .bundle" system_gems "bundler-99999999.99.1" diff --git a/spec/bundler/install/deploy_spec.rb b/spec/bundler/install/deploy_spec.rb index 6d845e03d1902f..a3b4a87ecfaa8d 100644 --- a/spec/bundler/install/deploy_spec.rb +++ b/spec/bundler/install/deploy_spec.rb @@ -9,13 +9,13 @@ end it "fails without a lockfile and says that deployment requires a lock" do - bundle "config deployment true" + bundle_config "deployment true" bundle "install", raise_on_error: false expect(err).to include("The deployment setting requires a lockfile") end it "fails without a lockfile and says that frozen requires a lock" do - bundle "config frozen true" + bundle_config "frozen true" bundle "install", raise_on_error: false expect(err).to include("The frozen setting requires a lockfile") end @@ -23,8 +23,8 @@ it "still works if you are not in the app directory and specify --gemfile" do bundle "install" pristine_system_gems - bundle "config set --local deployment true" - bundle "config set --local path vendor/bundle" + bundle_config "deployment true" + bundle_config "path vendor/bundle" bundle "install --gemfile #{tmp}/bundled_app/Gemfile", dir: tmp expect(the_bundle).to include_gems "myrack 1.0" end @@ -38,8 +38,8 @@ end G bundle :install - bundle "config set --local deployment true" - bundle "config set --local without test" + bundle_config "deployment true" + bundle_config "without test" bundle :install end @@ -47,7 +47,7 @@ skip "doesn't find bundle" if Gem.win_platform? bundle :install - bundle "config set --local deployment true" + bundle_config "deployment true" bundle :install bundle "exec bundle check", env: { "PATH" => path } end @@ -62,7 +62,7 @@ G bundle :install - bundle "config set --local deployment true" + bundle_config "deployment true" bundle :install end @@ -75,7 +75,7 @@ G bundle :install - bundle "config set --local deployment true" + bundle_config "deployment true" bundle :install end @@ -86,7 +86,7 @@ gem "myrack-obama", ">= 1.0" G - bundle "config set --local deployment true" + bundle_config "deployment true" bundle :install, artifice: "endpoint_strict_basic_authentication" end @@ -98,7 +98,7 @@ end G - bundle "config set --local deployment true" + bundle_config "deployment true" bundle :install expect(the_bundle).to include_gems "myrack 1.0" @@ -106,7 +106,7 @@ context "when replacing a host with the same host with credentials" do before do - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" bundle "install" gemfile <<-G source "http://user_name:password@localgemserver.test/" @@ -126,7 +126,7 @@ myrack G - bundle "config set --local deployment true" + bundle_config "deployment true" end it "allows the replace" do @@ -142,7 +142,7 @@ end it "installs gems by default to vendor/bundle" do - bundle "config set deployment true" + bundle_config "deployment true" expect do bundle "install" end.not_to change { bundled_app_lock.mtime } @@ -150,20 +150,20 @@ end it "installs gems to custom path if specified" do - bundle "config set path vendor/bundle2" - bundle "config set deployment true" + bundle_config "path vendor/bundle2" + bundle_config "deployment true" bundle "install" expect(out).to include("vendor/bundle2") end it "installs gems to custom path if specified, even when configured through ENV" do - bundle "config set deployment true" + bundle_config "deployment true" bundle "install", env: { "BUNDLE_PATH" => "vendor/bundle2" } expect(out).to include("vendor/bundle2") end it "works with the `frozen` setting" do - bundle "config set frozen true" + bundle_config "frozen true" expect do bundle "install" end.not_to change { bundled_app_lock.mtime } @@ -182,7 +182,7 @@ gem "myrack-obama" G - bundle "config set --local deployment true" + bundle_config "deployment true" bundle :install, raise_on_error: false expect(err).to include("frozen mode") expect(err).to include("You have added to the Gemfile") @@ -201,9 +201,9 @@ expect(the_bundle).to include_gems "path_gem 1.0" FileUtils.rm_r lib_path("path_gem-1.0") - bundle "config set --local path .bundle" - bundle "config set --local without development" - bundle "config set --local deployment true" + bundle_config "path .bundle" + bundle_config "without development" + bundle_config "deployment true" bundle :install, env: { "DEBUG" => "1" } run "puts :WIN" expect(out).to eq("WIN") @@ -268,8 +268,8 @@ expect(the_bundle).to include_gems "path_gem 1.0" FileUtils.rm_r lib_path("path_gem-1.0") - bundle "config set --local path .bundle" - bundle "config set --local deployment true" + bundle_config "path .bundle" + bundle_config "deployment true" bundle :install, raise_on_error: false expect(err).to include("The path `#{lib_path("path_gem-1.0")}` does not exist.") end @@ -340,7 +340,7 @@ gem "activesupport" G - bundle "config set --local deployment true" + bundle_config "deployment true" bundle :install, raise_on_error: false expect(err).to include("frozen mode") expect(err).to include("You have added to the Gemfile:\n* activesupport\n\n") @@ -351,7 +351,7 @@ it "explodes if you remove a gem and don't check in the lockfile" do gemfile 'source "https://gem.repo1"' - bundle "config set --local deployment true" + bundle_config "deployment true" bundle :install, raise_on_error: false expect(err).to include("Some dependencies were deleted") expect(err).to include("frozen mode") @@ -365,7 +365,7 @@ gem "myrack", :git => "git://hubz.com" G - bundle "config set --local deployment true" + bundle_config "deployment true" bundle :install, raise_on_error: false expect(err).to include("frozen mode") expect(err).not_to include("You have added to the Gemfile") @@ -385,7 +385,7 @@ gem "myrack" G - bundle "config set --local deployment true" + bundle_config "deployment true" bundle :install, raise_on_error: false expect(err).to include("frozen mode") expect(err).not_to include("You have deleted from the Gemfile") @@ -409,7 +409,7 @@ gem "foo", :git => "#{lib_path("myrack")}" G - bundle "config set --local deployment true" + bundle_config "deployment true" bundle :install, raise_on_error: false expect(err).to include("frozen mode") expect(err).to include("You have changed in the Gemfile:\n* myrack from `#{lib_path("myrack")}` to `no specified source`") @@ -430,7 +430,7 @@ gem "myrack", :git => "https:/my-git-repo-for-myrack" G - bundle "config set --local frozen true" + bundle_config "frozen true" bundle :install, raise_on_error: false expect(err).to include("frozen mode") expect(err).to include("You have changed in the Gemfile:\n* myrack from `#{lib_path("myrack")}` to `https:/my-git-repo-for-myrack`") @@ -441,7 +441,7 @@ it "remembers that the bundle is frozen at runtime" do bundle :lock - bundle "config set --local deployment true" + bundle_config "deployment true" gemfile <<-G source "https://gem.repo1" @@ -481,7 +481,7 @@ expect(out).to include("Updating files in vendor/cache") pristine_system_gems - bundle "config set --local deployment true" + bundle_config "deployment true" bundle "install --verbose" expect(out).not_to include("can't be updated because frozen mode is set") expect(out).not_to include("You have added to the Gemfile") diff --git a/spec/bundler/install/gemfile/eval_gemfile_spec.rb b/spec/bundler/install/gemfile/eval_gemfile_spec.rb index a507e524859307..3afa4f5daa8c43 100644 --- a/spec/bundler/install/gemfile/eval_gemfile_spec.rb +++ b/spec/bundler/install/gemfile/eval_gemfile_spec.rb @@ -85,7 +85,7 @@ # parsed lockfile and the evaluated gemfile. it "bundles with deployment mode configured" do bundle :install - bundle "config set --local deployment true" + bundle_config "deployment true" bundle :install end end diff --git a/spec/bundler/install/gemfile/gemspec_spec.rb b/spec/bundler/install/gemfile/gemspec_spec.rb index 3d9766d21ff66f..e51fc9247d37f2 100644 --- a/spec/bundler/install/gemfile/gemspec_spec.rb +++ b/spec/bundler/install/gemfile/gemspec_spec.rb @@ -126,7 +126,7 @@ # ghost pass in future, and will only catch a regression if the message # doesn't change. Exit codes should be used correctly (they can be more # than just 0 and 1). - bundle "config set --local deployment true" + bundle_config "deployment true" output = bundle("install", dir: tmp("foo"), artifice: "compact_index", env: { "BUNDLER_SPEC_GEM_REPO" => gem_repo1.to_s }) expect(output).not_to match(/You have added to the Gemfile/) expect(output).not_to match(/You have deleted from the Gemfile/) @@ -312,7 +312,7 @@ s.add_dependency "activesupport", ">= 1.0.1" end - bundle "config set --local deployment true" + bundle_config "deployment true" bundle :install, raise_on_error: false expect(err).to include("changed") @@ -435,7 +435,7 @@ gemspec G - bundle "config set --local force_ruby_platform true" + bundle_config "force_ruby_platform true" bundle "install" simulate_new_machine @@ -446,7 +446,7 @@ context "on ruby" do before do - bundle "config set --local force_ruby_platform true" + bundle_config "force_ruby_platform true" bundle :install end @@ -588,7 +588,7 @@ end it "installs the ruby platform gemspec" do - bundle "config set --local force_ruby_platform true" + bundle_config "force_ruby_platform true" install_gemfile <<-G source "https://gem.repo1" @@ -599,9 +599,9 @@ end it "installs the ruby platform gemspec and skips dev deps with `without development` configured" do - bundle "config set --local force_ruby_platform true" + bundle_config "force_ruby_platform true" - bundle "config set --local without development" + bundle_config "without development" install_gemfile <<-G source "https://gem.repo1" gemspec :path => '#{tmp("foo")}', :name => 'foo' diff --git a/spec/bundler/install/gemfile/git_spec.rb b/spec/bundler/install/gemfile/git_spec.rb index ed1c52f099e3f1..05081a8bce46a0 100644 --- a/spec/bundler/install/gemfile/git_spec.rb +++ b/spec/bundler/install/gemfile/git_spec.rb @@ -35,7 +35,7 @@ build_git "foo" revision = revision_for(lib_path("foo-1.0")) - bundle "config set lockfile_checksums true" + bundle_config "lockfile_checksums true" gemfile base_gemfile lockfile <<~L @@ -62,7 +62,7 @@ #{Bundler::VERSION} L - bundle "config set frozen true" + bundle_config "frozen true" bundle "install" expect(the_bundle).to include_gems("foo 1.0") @@ -83,7 +83,7 @@ it "caches the git repo globally and properly uses the cached repo on the next invocation" do install_base_gemfile pristine_system_gems - bundle "config set global_gem_cache true" + bundle_config "global_gem_cache true" bundle :install expect(Dir["#{home}/.bundle/cache/git/foo-1.0-*"]).to have_attributes size: 1 @@ -183,7 +183,7 @@ end it "still works after moving the application directory" do - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" install_base_gemfile FileUtils.mv bundled_app, tmp("bundled_app.bck") @@ -192,7 +192,7 @@ end it "can still install after moving the application directory" do - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" install_base_gemfile FileUtils.mv bundled_app, tmp("bundled_app.bck") @@ -381,7 +381,7 @@ it "does not download random non-head refs" do git("update-ref -m \"Bundler Spec!\" refs/bundler/1 main~1", lib_path("foo-1.0")) - bundle "config set global_gem_cache true" + bundle_config "global_gem_cache true" install_gemfile <<-G source "https://gem.repo1" @@ -1291,7 +1291,7 @@ pristine_system_gems - bundle "config set --local deployment true" + bundle_config "deployment true" bundle :install end end @@ -1674,7 +1674,7 @@ gem 'foo' end G - bundle "config set --global path vendor/bundle" + bundle_config_global "path vendor/bundle" bundle :install pristine_system_gems @@ -1685,7 +1685,7 @@ describe "when the git source is overridden with a local git repo" do before do - bundle "config set --global local.foo #{lib_path("foo")}" + bundle_config_global "local.foo #{lib_path("foo")}" end describe "and git output is colorized" do diff --git a/spec/bundler/install/gemfile/groups_spec.rb b/spec/bundler/install/gemfile/groups_spec.rb index 4727d5ef9b02cf..4013b112ecf338 100644 --- a/spec/bundler/install/gemfile/groups_spec.rb +++ b/spec/bundler/install/gemfile/groups_spec.rb @@ -86,13 +86,13 @@ end it "installs gems in the default group" do - bundle "config set --local without emo" + bundle_config "without emo" bundle :install expect(the_bundle).to include_gems "myrack 1.0.0", groups: [:default] end it "respects global `without` configuration, but does not save it locally" do - bundle "config set --global without emo" + bundle_config_global "without emo" bundle :install expect(the_bundle).to include_gems "myrack 1.0.0", groups: [:default] bundle "config list" @@ -101,26 +101,26 @@ end it "allows running application where groups where configured by a different user" do - bundle "config set without emo" + bundle_config "without emo" bundle :install bundle "exec ruby -e 'puts 42'", env: { "BUNDLE_USER_HOME" => tmp("new_home").to_s } expect(out).to include("42") end it "does not install gems from the excluded group" do - bundle "config set --local without emo" + bundle_config "without emo" bundle :install expect(the_bundle).not_to include_gems "activesupport 2.3.5", groups: [:default] end it "does not say it installed gems from the excluded group" do - bundle "config set --local without emo" + bundle_config "without emo" bundle :install expect(out).not_to include("activesupport") end it "allows Bundler.setup for specific groups" do - bundle "config set --local without emo" + bundle_config "without emo" bundle :install run("require 'myrack'; puts MYRACK", :default) expect(out).to eq("1.0.0") @@ -135,7 +135,7 @@ end G - bundle "config set --local without emo" + bundle_config "without emo" bundle :install expect(the_bundle).to include_gems "activesupport 2.3.2", groups: [:default] end @@ -158,7 +158,7 @@ end it "installs gems from the optional group when requested" do - bundle "config set --local with debugging" + bundle_config "with debugging" bundle :install expect(the_bundle).to include_gems "thin 1.0" end @@ -184,13 +184,13 @@ end it "has no effect when listing a not optional group in with" do - bundle "config set --local with emo" + bundle_config "with emo" bundle :install expect(the_bundle).to include_gems "activesupport 2.3.5" end it "has no effect when listing an optional group in without" do - bundle "config set --local without debugging" + bundle_config "without debugging" bundle :install expect(the_bundle).not_to include_gems "thin 1.0" end @@ -208,13 +208,13 @@ end it "installs gems in the default group" do - bundle "config set --local without emo lolercoaster" + bundle_config "without emo lolercoaster" bundle :install expect(the_bundle).to include_gems "myrack 1.0.0" end it "installs the gem if any of its groups are installed" do - bundle "config set --local without emo" + bundle_config "without emo" bundle :install expect(the_bundle).to include_gems "myrack 1.0.0", "activesupport 2.3.5" end @@ -236,15 +236,15 @@ end it "installs the gem unless all groups are excluded" do - bundle "config set --local without emo" + bundle_config "without emo" bundle :install expect(the_bundle).to include_gems "activesupport 2.3.5" - bundle "config set --local without lolercoaster" + bundle_config "without lolercoaster" bundle :install expect(the_bundle).to include_gems "activesupport 2.3.5" - bundle "config set --local without emo lolercoaster" + bundle_config "without emo lolercoaster" bundle :install expect(the_bundle).not_to include_gems "activesupport 2.3.5" @@ -269,13 +269,13 @@ end it "installs gems in the default group" do - bundle "config set --local without emo lolercoaster" + bundle_config "without emo lolercoaster" bundle :install expect(the_bundle).to include_gems "myrack 1.0.0" end it "installs the gem if any of its groups are installed" do - bundle "config set --local without emo" + bundle_config "without emo" bundle :install expect(the_bundle).to include_gems "myrack 1.0.0", "activesupport 2.3.5" end @@ -313,7 +313,7 @@ system_gems "myrack-0.9.1" - bundle "config set --local without myrack" + bundle_config "without myrack" install_gemfile <<-G source "https://gem.repo2" gem "myrack" @@ -337,7 +337,7 @@ it "does not hit the remote a second time" do FileUtils.rm_r gem_repo2 - bundle "config set --local without myrack" + bundle_config "without myrack" bundle :install, verbose: true expect(stdboth).not_to match(/fetching/i) end diff --git a/spec/bundler/install/gemfile/lockfile_spec.rb b/spec/bundler/install/gemfile/lockfile_spec.rb index ee747c05de6322..19bd7074b24dc2 100644 --- a/spec/bundler/install/gemfile/lockfile_spec.rb +++ b/spec/bundler/install/gemfile/lockfile_spec.rb @@ -17,7 +17,7 @@ context "with plugins disabled" do before do - bundle "config set plugins false" + bundle_config "plugins false" end it "does not evaluate the gemfile twice when the gem is already installed" do diff --git a/spec/bundler/install/gemfile/path_spec.rb b/spec/bundler/install/gemfile/path_spec.rb index 13a8c663e093b0..b0694885314887 100644 --- a/spec/bundler/install/gemfile/path_spec.rb +++ b/spec/bundler/install/gemfile/path_spec.rb @@ -125,7 +125,7 @@ gem 'foo', :path => File.expand_path("foo-1.0", __dir__) G - bundle "config set --local frozen true" + bundle_config "frozen true" bundle :install end diff --git a/spec/bundler/install/gemfile/platform_spec.rb b/spec/bundler/install/gemfile/platform_spec.rb index 6c5e5452c97337..e12933ebcfb9c6 100644 --- a/spec/bundler/install/gemfile/platform_spec.rb +++ b/spec/bundler/install/gemfile/platform_spec.rb @@ -65,7 +65,7 @@ platform_specific G - bundle "config set --local frozen true" + bundle_config "frozen true" install_gemfile <<-G source "https://gem.repo1" @@ -162,7 +162,7 @@ expect(the_bundle).to include_gems "nokogiri 1.4.2 java", "weakling 0.0.3" pristine_system_gems - bundle "config set --local force_ruby_platform true" + bundle_config "force_ruby_platform true" bundle "install" expect(the_bundle).to include_gems "nokogiri 1.4.2" @@ -365,7 +365,7 @@ gem "myrack", "1.0.0" G - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" bundle :install FileUtils.mv(vendored_gems, bundled_app("vendor/bundle", Gem.ruby_engine, "1.8")) @@ -394,7 +394,7 @@ #{checksums} G - bundle "config set --local force_ruby_platform true" + bundle_config "force_ruby_platform true" install_gemfile <<-G source "https://gem.repo1" @@ -542,7 +542,7 @@ end it "does not attempt to install gems from :rbx when using --local" do - bundle "config set --local force_ruby_platform true" + bundle_config "force_ruby_platform true" gemfile <<-G source "https://gem.repo1" @@ -554,7 +554,7 @@ end it "does not attempt to install gems from other rubies when using --local" do - bundle "config set --local force_ruby_platform true" + bundle_config "force_ruby_platform true" gemfile <<-G source "https://gem.repo1" gem "some_gem", platform: :ruby_22 @@ -565,7 +565,7 @@ end it "does not print a warning when a dependency is unused on a platform different from the current one" do - bundle "config set --local force_ruby_platform true" + bundle_config "force_ruby_platform true" gemfile <<-G source "https://gem.repo1" @@ -594,7 +594,7 @@ end it "resolves fine when a dependency is unused on a platform different from the current one, but reintroduced transitively" do - bundle "config set --local force_ruby_platform true" + bundle_config "force_ruby_platform true" build_repo4 do build_gem "listen", "3.7.1" do |s| diff --git a/spec/bundler/install/gemfile/sources_spec.rb b/spec/bundler/install/gemfile/sources_spec.rb index c72a2b982a99ec..654d638e1fe0f5 100644 --- a/spec/bundler/install/gemfile/sources_spec.rb +++ b/spec/bundler/install/gemfile/sources_spec.rb @@ -42,7 +42,7 @@ expect(bundled_app("vendor/cache/myrack-1.0.0.gem")).to exist expect(bundled_app("vendor/cache/myrack-obama-1.0.gem")).to exist - bundle "config set --local deployment true" + bundle_config "deployment true" bundle :install, artifice: "compact_index" expect(the_bundle).to include_gems("myrack-obama 1.0.0", "myrack 1.0.0") @@ -566,7 +566,7 @@ gem 'bar', '~> 0.1', :source => 'https://gem.repo4' G - bundle "config set --local path ../gems/system" + bundle_config "path ../gems/system" bundle :install, artifice: "compact_index" # And then we add some new versions... diff --git a/spec/bundler/install/gemfile/specific_platform_spec.rb b/spec/bundler/install/gemfile/specific_platform_spec.rb index 448800d57817f3..2c811a666d18a0 100644 --- a/spec/bundler/install/gemfile/specific_platform_spec.rb +++ b/spec/bundler/install/gemfile/specific_platform_spec.rb @@ -70,7 +70,7 @@ setup_multiplatform_gem # Consistent location to install and look for gems - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" install_gemfile(google_protobuf) @@ -92,7 +92,7 @@ L # force strict usage of the lockfile by setting frozen mode - bundle "config set --local frozen true" + bundle_config "frozen true" # make sure the platform that got actually installed with the old bundler is used expect(the_bundle).to include_gem("google-protobuf 3.0.0.alpha.5.0.5.1 universal-darwin") @@ -104,7 +104,7 @@ setup_multiplatform_gem # Consistent location to install and look for gems - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" gemfile google_protobuf @@ -275,7 +275,7 @@ end # Consistent location to install and look for gems - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" gemfile <<-G source "https://gem.repo2" @@ -359,7 +359,7 @@ simulate_platform "x86_64-darwin-15" do setup_multiplatform_gem gemfile(google_protobuf) - bundle "config set --local cache_all_platforms true" + bundle_config "cache_all_platforms true" bundle "cache" expect(cached_gem("google-protobuf-3.0.0.alpha.5.0.5.1-universal-darwin")).to exist diff --git a/spec/bundler/install/gemfile_spec.rb b/spec/bundler/install/gemfile_spec.rb index 87326f67af693c..83875a3d0e300f 100644 --- a/spec/bundler/install/gemfile_spec.rb +++ b/spec/bundler/install/gemfile_spec.rb @@ -65,7 +65,7 @@ gem 'myrack' G - bundle "config set --local gemfile #{bundled_app("NotGemfile")}" + bundle_config "gemfile #{bundled_app("NotGemfile")}" end it "uses the gemfile to install" do bundle "install" diff --git a/spec/bundler/install/gems/compact_index_spec.rb b/spec/bundler/install/gems/compact_index_spec.rb index d082b9be72ce59..9db73b84b5abc8 100644 --- a/spec/bundler/install/gems/compact_index_spec.rb +++ b/spec/bundler/install/gems/compact_index_spec.rb @@ -95,7 +95,7 @@ G bundle :install, artifice: "compact_index" - bundle "config set --local deployment true" + bundle_config "deployment true" bundle :install, artifice: "compact_index" expect(out).to include("Fetching gem metadata from #{source_uri}") expect(the_bundle).to include_gems "myrack 1.0.0" @@ -132,7 +132,7 @@ bundle :install, artifice: "compact_index" - bundle "config set --local deployment true" + bundle_config "deployment true" bundle :install, artifice: "compact_index" expect(the_bundle).to include_gems("rails 2.3.2") @@ -146,7 +146,7 @@ G bundle "install", artifice: "compact_index" - bundle "config set --local deployment true" + bundle_config "deployment true" bundle :install, artifice: "compact_index" expect(the_bundle).to include_gems("foo 1.0") @@ -302,7 +302,7 @@ def require(*args) end system_gems %w[myrack-1.0.0 thin-1.0 net_a-1.0], gem_repo: gem_repo2 - bundle "config set --local path.system true" + bundle_config "path.system true" ENV["BUNDLER_SPEC_ALL_REQUESTS"] = <<~EOS.strip #{source_uri}/versions #{source_uri}/info/myrack @@ -471,7 +471,7 @@ def require(*args) G bundle :install, artifice: "compact_index_extra" - bundle "config set --local deployment true" + bundle_config "deployment true" bundle :install, artifice: "compact_index_extra" expect(the_bundle).to include_gems "back_deps 1.0" end @@ -956,7 +956,7 @@ def start end it "does not raise when disable_checksum_validation is set" do - bundle "config set disable_checksum_validation true" + bundle_config "disable_checksum_validation true" install_gemfile <<-G, artifice: "compact_index_wrong_gem_checksum" source "#{source_uri}" gem "myrack" diff --git a/spec/bundler/install/gems/dependency_api_fallback_spec.rb b/spec/bundler/install/gems/dependency_api_fallback_spec.rb index 7890cbdb993bbc..c7b0c537e459a7 100644 --- a/spec/bundler/install/gems/dependency_api_fallback_spec.rb +++ b/spec/bundler/install/gems/dependency_api_fallback_spec.rb @@ -3,7 +3,7 @@ RSpec.describe "gemcutter's dependency API" do context "when Gemcutter API takes too long to respond" do before do - bundle "config set timeout 1" + bundle_config "timeout 1" end it "times out and falls back on the modern index" do diff --git a/spec/bundler/install/gems/dependency_api_spec.rb b/spec/bundler/install/gems/dependency_api_spec.rb index ac986a0c67a2f9..32a1b98b6d04f5 100644 --- a/spec/bundler/install/gems/dependency_api_spec.rb +++ b/spec/bundler/install/gems/dependency_api_spec.rb @@ -60,7 +60,7 @@ G bundle :install, artifice: "endpoint" - bundle "config set --local deployment true" + bundle_config "deployment true" bundle :install, artifice: "endpoint" expect(out).to include("Fetching gem metadata from #{source_uri}") expect(the_bundle).to include_gems "myrack 1.0.0" @@ -97,7 +97,7 @@ bundle :install, artifice: "endpoint" - bundle "config set --local deployment true" + bundle_config "deployment true" bundle :install, artifice: "endpoint" expect(the_bundle).to include_gems("rails 2.3.2") @@ -111,7 +111,7 @@ G bundle "install", artifice: "endpoint" - bundle "config set --local deployment true" + bundle_config "deployment true" bundle :install, artifice: "endpoint" expect(the_bundle).to include_gems("foo 1.0") @@ -378,7 +378,7 @@ def require(*args) G bundle :install, artifice: "endpoint_extra" - bundle "config set --local deployment true" + bundle_config "deployment true" bundle "install", artifice: "endpoint_extra" expect(the_bundle).to include_gems "back_deps 1.0" end diff --git a/spec/bundler/install/gems/flex_spec.rb b/spec/bundler/install/gems/flex_spec.rb index b34dbbfa2a57b4..a30b53d6ad7a2c 100644 --- a/spec/bundler/install/gems/flex_spec.rb +++ b/spec/bundler/install/gems/flex_spec.rb @@ -191,7 +191,7 @@ end it "discards the locked gems when the Gemfile requires different versions than the lock" do - bundle "config set force_ruby_platform true" + bundle_config "force_ruby_platform true" nice_error = <<~E.strip Could not find compatible versions @@ -208,7 +208,7 @@ end it "does not include conflicts with a single requirement tree, because that can't possibly be a conflict" do - bundle "config set force_ruby_platform true" + bundle_config "force_ruby_platform true" bad_error = <<~E.strip Bundler could not find compatible versions for gem "myrack-obama": diff --git a/spec/bundler/install/gems/fund_spec.rb b/spec/bundler/install/gems/fund_spec.rb index 0855a62b86c7d2..8a3a51270ab3a3 100644 --- a/spec/bundler/install/gems/fund_spec.rb +++ b/spec/bundler/install/gems/fund_spec.rb @@ -54,7 +54,7 @@ context "when gems include a fund URI but `ignore_funding_requests` is configured" do before do - bundle "config set ignore_funding_requests true" + bundle_config "ignore_funding_requests true" end it "does not display the plural fund message after installing" do diff --git a/spec/bundler/install/gems/gemfile_source_header_spec.rb b/spec/bundler/install/gems/gemfile_source_header_spec.rb index 9e63fa7551a4da..dc35c8d741a08e 100644 --- a/spec/bundler/install/gems/gemfile_source_header_spec.rb +++ b/spec/bundler/install/gems/gemfile_source_header_spec.rb @@ -11,7 +11,7 @@ gem 'weakling' G - bundle "config set --local mirror.#{mirror} https://gem.repo2" + bundle_config "mirror.#{mirror} https://gem.repo2" end it "sets the 'X-Gemfile-Source' and 'User-Agent' headers and bundles successfully" do diff --git a/spec/bundler/install/gems/mirror_probe_spec.rb b/spec/bundler/install/gems/mirror_probe_spec.rb index 436f116cacf37a..564062ccf6f104 100644 --- a/spec/bundler/install/gems/mirror_probe_spec.rb +++ b/spec/bundler/install/gems/mirror_probe_spec.rb @@ -12,8 +12,8 @@ context "with a specific fallback timeout" do before do - global_config("BUNDLE_MIRROR__HTTPS://GEM__REPO2/__FALLBACK_TIMEOUT/" => "true", - "BUNDLE_MIRROR__HTTPS://GEM__REPO2/" => "https://gem.mirror") + bundle_config_global("BUNDLE_MIRROR__HTTPS://GEM__REPO2/__FALLBACK_TIMEOUT/" => "true", + "BUNDLE_MIRROR__HTTPS://GEM__REPO2/" => "https://gem.mirror") end it "install a gem using the original uri when the mirror is not responding" do @@ -27,8 +27,8 @@ context "with a global fallback timeout" do before do - global_config("BUNDLE_MIRROR__ALL__FALLBACK_TIMEOUT/" => "1", - "BUNDLE_MIRROR__ALL" => "https://gem.mirror") + bundle_config_global("BUNDLE_MIRROR__ALL__FALLBACK_TIMEOUT/" => "1", + "BUNDLE_MIRROR__ALL" => "https://gem.mirror") end it "install a gem using the original uri when the mirror is not responding" do @@ -42,7 +42,7 @@ context "with a specific mirror without a fallback timeout" do before do - global_config("BUNDLE_MIRROR__HTTPS://GEM__REPO2/" => "https://gem.mirror") + bundle_config_global("BUNDLE_MIRROR__HTTPS://GEM__REPO2/" => "https://gem.mirror") end it "fails to install the gem with a timeout error when the mirror is not responding" do @@ -55,7 +55,7 @@ context "with a global mirror without a fallback timeout" do before do - global_config("BUNDLE_MIRROR__ALL" => "https://gem.mirror") + bundle_config_global("BUNDLE_MIRROR__ALL" => "https://gem.mirror") end it "fails to install the gem with a timeout error when the mirror is not responding" do diff --git a/spec/bundler/install/gems/mirror_spec.rb b/spec/bundler/install/gems/mirror_spec.rb index 70c0da50ef8145..e1fbeac4547f20 100644 --- a/spec/bundler/install/gems/mirror_spec.rb +++ b/spec/bundler/install/gems/mirror_spec.rb @@ -8,7 +8,7 @@ gem "myrack" G - bundle "config set --local mirror.http://gems.example.org http://gem-mirror.example.org" + bundle_config "mirror.http://gems.example.org http://gem-mirror.example.org" end it "installs from the normal location" do @@ -26,7 +26,7 @@ gem "myrack" G - bundle "config set --local mirror.https://gem.repo2 https://gem.repo1" + bundle_config "mirror.https://gem.repo2 https://gem.repo1" end it "installs the gem from the mirror" do diff --git a/spec/bundler/install/gems/native_extensions_spec.rb b/spec/bundler/install/gems/native_extensions_spec.rb index 7f230d132b9eab..d5b10d2c8fc865 100644 --- a/spec/bundler/install/gems/native_extensions_spec.rb +++ b/spec/bundler/install/gems/native_extensions_spec.rb @@ -37,7 +37,7 @@ gem "c_extension" G - bundle "config set build.c_extension --with-c_extension=hello" + bundle_config "build.c_extension --with-c_extension=hello" bundle "install" expect(out).to include("Installing c_extension 1.0 with native extensions") @@ -75,7 +75,7 @@ C end - bundle "config set build.c_extension --with-c_extension=hello" + bundle_config "build.c_extension --with-c_extension=hello" install_gemfile <<-G source "https://gem.repo1" @@ -122,8 +122,8 @@ build_git "gems", path: lib_path("gems"), gemspec: false end - bundle "config set build.c_extension_one --with-c_extension_one=one" - bundle "config set build.c_extension_two --with-c_extension_two=two" + bundle_config "build.c_extension_one --with-c_extension_one=one" + bundle_config "build.c_extension_two --with-c_extension_two=two" # 1st time, require only one gem -- only one of the extensions gets built. install_gemfile <<-G @@ -171,7 +171,7 @@ C end - bundle "config set build.c_extension --with-c_extension=hello --with-c_extension_bundle-dir=hola" + bundle_config "build.c_extension --with-c_extension=hello --with-c_extension_bundle-dir=hola" install_gemfile <<-G source "https://gem.repo1" diff --git a/spec/bundler/install/gems/post_install_spec.rb b/spec/bundler/install/gems/post_install_spec.rb index af753dba3e3ec7..e49fd2a9a349ba 100644 --- a/spec/bundler/install/gems/post_install_spec.rb +++ b/spec/bundler/install/gems/post_install_spec.rb @@ -127,7 +127,7 @@ gem "myrack" G - bundle "config set ignore_messages.myrack true" + bundle_config "ignore_messages.myrack true" bundle :install expect(out).not_to include("Post-install message") @@ -141,7 +141,7 @@ gem "myrack" G - bundle "config set ignore_messages true" + bundle_config "ignore_messages true" bundle :install expect(out).not_to include("Post-install message") diff --git a/spec/bundler/install/gems/standalone_spec.rb b/spec/bundler/install/gems/standalone_spec.rb index 37997ffe482409..96a305bb7632b7 100644 --- a/spec/bundler/install/gems/standalone_spec.rb +++ b/spec/bundler/install/gems/standalone_spec.rb @@ -125,7 +125,7 @@ source "https://gem.repo1" gem "rails" G - bundle "config set --local path #{bundled_app("bundle")}" + bundle_config "path #{bundled_app("bundle")}" bundle :install, standalone: true, dir: cwd end @@ -164,7 +164,7 @@ bundle "lock", dir: cwd - bundle "config set --local path #{bundled_app("bundle")}" + bundle_config "path #{bundled_app("bundle")}" bundle :install, standalone: true, dir: cwd, env: { "BUNDLER_GEM_DEFAULT_DIR" => system_gem_path.to_s } @@ -191,7 +191,7 @@ gem "baz" G - bundle "config set --local path #{bundled_app("bundle")}" + bundle_config "path #{bundled_app("bundle")}" bundle "lock", dir: cwd @@ -270,7 +270,7 @@ describe "with gems with native extension" do before do - bundle "config set --local path #{bundled_app("bundle")}" + bundle_config "path #{bundled_app("bundle")}" install_gemfile <<-G, standalone: true, dir: cwd source "https://gem.repo1" gem "very_simple_binary" @@ -308,7 +308,7 @@ end G end - bundle "config set --local path #{bundled_app("bundle")}" + bundle_config "path #{bundled_app("bundle")}" install_gemfile <<-G, standalone: true, dir: cwd, raise_on_error: false source "https://gem.repo1" gem "bar", :git => "#{lib_path("bar-1.0")}" @@ -330,7 +330,7 @@ gem "rails" gem "devise", :git => "#{lib_path("devise-1.0")}" G - bundle "config set --local path #{bundled_app("bundle")}" + bundle_config "path #{bundled_app("bundle")}" bundle :install, standalone: true, dir: cwd end @@ -358,7 +358,7 @@ gem "myrack-test" end G - bundle "config set --local path #{bundled_app("bundle")}" + bundle_config "path #{bundled_app("bundle")}" bundle :install, standalone: true, dir: cwd end @@ -372,7 +372,7 @@ include_examples "common functionality" it "allows creating a standalone file with limited groups" do - bundle "config set --local path #{bundled_app("bundle")}" + bundle_config "path #{bundled_app("bundle")}" bundle :install, standalone: "default", dir: cwd load_error_ruby <<-RUBY, "spec" @@ -389,8 +389,8 @@ end it "allows `without` configuration to limit the groups used in a standalone" do - bundle "config set --local path #{bundled_app("bundle")}" - bundle "config set --local without test" + bundle_config "path #{bundled_app("bundle")}" + bundle_config "without test" bundle :install, standalone: true, dir: cwd load_error_ruby <<-RUBY, "spec" @@ -407,7 +407,7 @@ end it "allows `path` configuration to change the location of the standalone bundle" do - bundle "config set --local path path/to/bundle" + bundle_config "path path/to/bundle" bundle "install", standalone: true, dir: cwd ruby <<-RUBY @@ -422,9 +422,9 @@ end it "allows `without` to limit the groups used in a standalone" do - bundle "config set --local without test" + bundle_config "without test" bundle :install, dir: cwd - bundle "config set --local path #{bundled_app("bundle")}" + bundle_config "path #{bundled_app("bundle")}" bundle :install, standalone: true, dir: cwd load_error_ruby <<-RUBY, "spec" @@ -450,7 +450,7 @@ source "#{source_uri}" gem "rails" G - bundle "config set --local path #{bundled_app("bundle")}" + bundle_config "path #{bundled_app("bundle")}" bundle :install, standalone: true, artifice: "endpoint", dir: cwd end @@ -484,7 +484,7 @@ context "when path set to a relative path" do before do - bundle "config set --local path bundle" + bundle_config "path bundle" end it "generates the script in the proper place" do diff --git a/spec/bundler/install/git_spec.rb b/spec/bundler/install/git_spec.rb index b711f6e614082f..78e902cb73fa7a 100644 --- a/spec/bundler/install/git_spec.rb +++ b/spec/bundler/install/git_spec.rb @@ -85,8 +85,8 @@ foo! L - bundle "config set --local path vendor/bundle" - bundle "config set --local without development" + bundle_config "path vendor/bundle" + bundle_config "without development" bundle :install expect(out).to include("Bundle complete!") @@ -188,8 +188,8 @@ build_git "foo", "1.0", path: lib_path("foo") rev = revision_for(lib_path("foo")) - bundle "config set path vendor/bundle" - bundle "config set clean true" + bundle_config "path vendor/bundle" + bundle_config "clean true" install_gemfile <<-G, verbose: true source "https://gem.repo1" gem "foo", :git => "#{lib_path("foo")}" @@ -310,7 +310,7 @@ bundle :install # Set without and reinstall - bundle "config set --local without development" + bundle_config "without development" bundle :install # Verify only production gem is available diff --git a/spec/bundler/install/global_cache_spec.rb b/spec/bundler/install/global_cache_spec.rb index 268b63e8badabb..4cffa65b2a9d97 100644 --- a/spec/bundler/install/global_cache_spec.rb +++ b/spec/bundler/install/global_cache_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true RSpec.describe "global gem caching" do + # Uses subprocess because this setting must apply across multiple app directories (bundled_app and bundled_app2) before { bundle "config set global_gem_cache true" } describe "using the cross-application user cache" do @@ -96,7 +97,7 @@ def source2_global_cache(*segments) describe "when the same gem from different sources is installed" do it "should use the appropriate one from the global cache" do - bundle "config set path.system true" + bundle_config "path.system true" install_gemfile <<-G, artifice: "compact_index" source "#{source}" @@ -141,7 +142,7 @@ def source2_global_cache(*segments) end it "should not install if the wrong source is provided" do - bundle "config set path.system true" + bundle_config "path.system true" gemfile <<-G source "#{source}" @@ -199,7 +200,7 @@ def source2_global_cache(*segments) describe "when installing gems from a different directory" do it "uses the global cache as a source" do - bundle "config set path.system true" + bundle_config "path.system true" install_gemfile <<-G, artifice: "compact_index" source "#{source}" @@ -289,7 +290,7 @@ def source2_global_cache(*segments) gem_binary_cache.join("very_simple_binary_c.rb").open("w") {|f| f << "puts File.basename(__FILE__)" } git_binary_cache.join("very_simple_git_binary_c.rb").open("w") {|f| f << "puts File.basename(__FILE__)" } - bundle "config set --local path different_path" + bundle_config "path different_path" bundle :install expect(Dir[home(".bundle", "cache", "extensions", "**", "*binary_c*")]).to all(end_with(".rb")) diff --git a/spec/bundler/install/path_spec.rb b/spec/bundler/install/path_spec.rb index 8c0793642baf15..49360e511ef76b 100644 --- a/spec/bundler/install/path_spec.rb +++ b/spec/bundler/install/path_spec.rb @@ -14,14 +14,14 @@ end it "does not use available system gems with `vendor/bundle" do - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" bundle :install expect(the_bundle).to include_gems "myrack 1.0.0" end it "uses system gems with `path.system` configured with more priority than `path`" do - bundle "config set --local path.system true" - bundle "config set --global path vendor/bundle" + bundle_config "path.system true" + bundle_config_global "path vendor/bundle" bundle :install run "require 'myrack'", raise_on_error: false expect(out).to include("FAIL") @@ -31,7 +31,7 @@ dir = bundled_app("bun++dle") dir.mkpath - bundle "config set --local path #{dir.join("vendor/bundle")}" + bundle_config "path #{dir.join("vendor/bundle")}" bundle :install, dir: dir expect(out).to include("installed into `./vendor/bundle`") @@ -39,13 +39,13 @@ end it "prints a message to let the user know where gems where installed" do - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" bundle :install expect(out).to include("gems are installed into `./vendor/bundle`") end it "installs the bundle relatively to repository root, when Bundler run from the same directory" do - bundle "config path vendor/bundle", dir: bundled_app.parent + bundle "config set path vendor/bundle", dir: bundled_app.parent bundle "install --gemfile='#{bundled_app}/Gemfile'", dir: bundled_app.parent expect(out).to include("installed into `./bundled_app/vendor/bundle`") expect(bundled_app("vendor/bundle")).to be_directory @@ -53,7 +53,7 @@ end it "installs the bundle relatively to repository root, when Bundler run from a different directory" do - bundle "config path vendor/bundle", dir: bundled_app + bundle "config set path vendor/bundle", dir: bundled_app bundle "install --gemfile='#{bundled_app}/Gemfile'", dir: bundled_app.parent expect(out).to include("installed into `./bundled_app/vendor/bundle`") expect(bundled_app("vendor/bundle")).to be_directory @@ -97,7 +97,7 @@ def set_bundle_path(type, location) context "when set via #{type}" do it "installs gems to a path if one is specified" do set_bundle_path(type, bundled_app("vendor2").to_s) - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" bundle :install expect(vendored_gems("gems/myrack-1.0.0")).to be_directory @@ -107,7 +107,7 @@ def set_bundle_path(type, location) it "installs gems to ." do set_bundle_path(type, ".") - bundle "config set --global disable_shared_gems true" + bundle_config_global "disable_shared_gems true" bundle :install @@ -138,7 +138,7 @@ def set_bundle_path(type, location) end it "installs gems to BUNDLE_PATH from .bundle/config" do - config "BUNDLE_PATH" => bundled_app("vendor/bundle").to_s + bundle_config "BUNDLE_PATH" => bundled_app("vendor/bundle").to_s bundle :install @@ -147,7 +147,7 @@ def set_bundle_path(type, location) end it "sets BUNDLE_PATH as the first argument to bundle install" do - bundle "config set --local path ./vendor/bundle" + bundle_config "path ./vendor/bundle" bundle :install expect(vendored_gems("gems/myrack-1.0.0")).to be_directory @@ -157,7 +157,7 @@ def set_bundle_path(type, location) it "disables system gems when passing a path to install" do # This is so that vendored gems can be distributed to others build_gem "myrack", "1.1.0", to_system: true - bundle "config set --local path ./vendor/bundle" + bundle_config "path ./vendor/bundle" bundle :install expect(vendored_gems("gems/myrack-1.0.0")).to be_directory @@ -174,7 +174,7 @@ def set_bundle_path(type, location) gem "very_simple_binary" G - bundle "config set --local path ./vendor/bundle" + bundle_config "path ./vendor/bundle" bundle :install expect(vendored_gems("gems/very_simple_binary-1.0")).to be_directory @@ -186,7 +186,7 @@ def set_bundle_path(type, location) run "require 'very_simple_binary_c'", raise_on_error: false expect(err).to include("Bundler::GemNotFound") - bundle "config set --local path ./vendor/bundle" + bundle_config "path ./vendor/bundle" bundle :install expect(vendored_gems("gems/very_simple_binary-1.0")).to be_directory @@ -206,7 +206,7 @@ def set_bundle_path(type, location) gem "myrack" G - bundle "config set --local path bundle" + bundle_config "path bundle" bundle :install, raise_on_error: false expect(err).to include("file already exists") end diff --git a/spec/bundler/install/yanked_spec.rb b/spec/bundler/install/yanked_spec.rb index 08d6bbdc2a3ad2..c92af7bfb09526 100644 --- a/spec/bundler/install/yanked_spec.rb +++ b/spec/bundler/install/yanked_spec.rb @@ -118,7 +118,7 @@ build_gem "foo", "9.0.0" end - bundle "config set force_ruby_platform true" + bundle_config "force_ruby_platform true" install_gemfile <<-G, raise_on_error: false source "https://gem.repo4" diff --git a/spec/bundler/other/major_deprecation_spec.rb b/spec/bundler/other/major_deprecation_spec.rb index 24d4153dfabea0..6eeb70abe50b6f 100644 --- a/spec/bundler/other/major_deprecation_spec.rb +++ b/spec/bundler/other/major_deprecation_spec.rb @@ -435,7 +435,7 @@ context "bundle install with flags" do before do - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" install_gemfile <<-G source "https://gem.repo1" @@ -520,7 +520,7 @@ "Your lockfile contains a single rubygems source section with multiple remotes, which is insecure. " \ "Make sure you run `bundle install` in non frozen mode and commit the result to make your lockfile secure." ) - bundle "config set --local frozen true" + bundle_config "frozen true" bundle "install", raise_on_error: false expect(err).to include( @@ -754,8 +754,11 @@ describe "removing rubocop" do before do - global_config "BUNDLE_GEM__MIT" => "false", "BUNDLE_GEM__TEST" => "false", "BUNDLE_GEM__COC" => "false", - "BUNDLE_GEM__CI" => "false", "BUNDLE_GEM__CHANGELOG" => "false" + bundle_config_global "gem.mit false" + bundle_config_global "gem.test false" + bundle_config_global "gem.coc false" + bundle_config_global "gem.ci false" + bundle_config_global "gem.changelog false" end context "bundle gem --rubocop" do diff --git a/spec/bundler/plugins/install_spec.rb b/spec/bundler/plugins/install_spec.rb index dc3a12913eefe4..dcacf764bef6b0 100644 --- a/spec/bundler/plugins/install_spec.rb +++ b/spec/bundler/plugins/install_spec.rb @@ -371,7 +371,7 @@ def exec(command, args) gem 'myrack', "1.0.0" G - bundle "config set --local deployment true" + bundle_config "deployment true" install_gemfile <<-G source 'https://gem.repo2' plugin 'foo' diff --git a/spec/bundler/plugins/source/example_spec.rb b/spec/bundler/plugins/source/example_spec.rb index e64e4d6330198c..4cd4a1a9318fee 100644 --- a/spec/bundler/plugins/source/example_spec.rb +++ b/spec/bundler/plugins/source/example_spec.rb @@ -135,7 +135,7 @@ def install(spec, opts) end it "copies repository to vendor cache and uses it even when installed with `path` configured" do - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" bundle :install bundle :cache @@ -146,7 +146,7 @@ def install(spec, opts) end it "bundler package copies repository to vendor cache" do - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" bundle :install bundle :cache diff --git a/spec/bundler/runtime/executable_spec.rb b/spec/bundler/runtime/executable_spec.rb index 86cd1d00395629..89cee21b00faf8 100644 --- a/spec/bundler/runtime/executable_spec.rb +++ b/spec/bundler/runtime/executable_spec.rb @@ -20,7 +20,7 @@ end it "allows the location of the gem stubs to be configured" do - bundle "config bin gbin" + bundle_config "bin gbin" bundle "binstubs myrack" expect(bundled_app("bin")).not_to exist @@ -31,7 +31,7 @@ end it "allows absolute paths as a specification of where to install bin stubs" do - bundle "config bin #{tmp("bin")}" + bundle_config "bin #{tmp("bin")}" bundle "binstubs myrack" gembin tmp("bin/myrackup") diff --git a/spec/bundler/runtime/gem_tasks_spec.rb b/spec/bundler/runtime/gem_tasks_spec.rb index f87207f0ab3e86..b855142e60586f 100644 --- a/spec/bundler/runtime/gem_tasks_spec.rb +++ b/spec/bundler/runtime/gem_tasks_spec.rb @@ -132,7 +132,7 @@ before do define_local_gem_using_gem_tasks - bundle "config set path vendor/bundle" + bundle_config "path vendor/bundle" end it "works", :ruby_repo do diff --git a/spec/bundler/runtime/inline_spec.rb b/spec/bundler/runtime/inline_spec.rb index 91f4ae999368f0..c6f9bbdbd7326f 100644 --- a/spec/bundler/runtime/inline_spec.rb +++ b/spec/bundler/runtime/inline_spec.rb @@ -499,7 +499,7 @@ def confirm(msg, newline = nil) end it "skips platform warnings" do - bundle "config set --local force_ruby_platform true" + bundle_config "force_ruby_platform true" script <<-RUBY gemfile(true) do @@ -512,7 +512,7 @@ def confirm(msg, newline = nil) end it "still installs if the application has `bundle package` no_install config set" do - bundle "config set --local no_install true" + bundle_config "no_install true" script <<-RUBY gemfile do diff --git a/spec/bundler/runtime/platform_spec.rb b/spec/bundler/runtime/platform_spec.rb index 68b5626ed4f33a..6d967589562d03 100644 --- a/spec/bundler/runtime/platform_spec.rb +++ b/spec/bundler/runtime/platform_spec.rb @@ -219,7 +219,7 @@ gem "platform_specific" G - bundle "config set force_ruby_platform true" + bundle_config "force_ruby_platform true" bundle "install" @@ -233,7 +233,7 @@ gem "platform_specific" G - bundle "config set force_ruby_platform true" + bundle_config "force_ruby_platform true" bundle "install" @@ -247,7 +247,7 @@ gem "platform_specific" G - bundle "config set force_ruby_platform true" + bundle_config "force_ruby_platform true" bundle "install" @@ -377,7 +377,7 @@ gem "platform_specific" G - bundle "config set force_ruby_platform true" + bundle_config "force_ruby_platform true" bundle "install" @@ -398,7 +398,7 @@ bundle :lock simulate_platform "x86-mswin32" do - bundle "config set force_ruby_platform true" + bundle_config "force_ruby_platform true" bundle "install" expect(the_bundle).to include_gems "myrack 1.0" diff --git a/spec/bundler/runtime/self_management_spec.rb b/spec/bundler/runtime/self_management_spec.rb index 34382df2681780..176c2a3121774d 100644 --- a/spec/bundler/runtime/self_management_spec.rb +++ b/spec/bundler/runtime/self_management_spec.rb @@ -31,7 +31,7 @@ it "installs locked version when using system path and uses it" do lockfile_bundled_with(previous_minor) - bundle "config set --local path.system true" + bundle_config "path.system true" bundle "install" expect(out).to include("Bundler #{current_version} is running, but your lockfile was generated with #{previous_minor}. Installing Bundler #{previous_minor} and restarting using that version.") @@ -67,7 +67,7 @@ it "installs locked version when using local path and uses it" do lockfile_bundled_with(previous_minor) - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" bundle "install" expect(out).to include("Bundler #{current_version} is running, but your lockfile was generated with #{previous_minor}. Installing Bundler #{previous_minor} and restarting using that version.") expect(vendored_gems("gems/bundler-#{previous_minor}")).to exist @@ -108,7 +108,7 @@ it "installs locked version when using deployment option and uses it" do lockfile_bundled_with(previous_minor) - bundle "config set --local deployment true" + bundle_config "deployment true" bundle "install" expect(out).to include("Bundler #{current_version} is running, but your lockfile was generated with #{previous_minor}. Installing Bundler #{previous_minor} and restarting using that version.") expect(vendored_gems("gems/bundler-#{previous_minor}")).to exist @@ -163,7 +163,7 @@ it "installs BUNDLE_VERSION version when using bundle config version x.y.z" do lockfile_bundled_with(current_version) - bundle "config set --local version #{previous_minor}" + bundle_config "version #{previous_minor}" bundle "install" expect(out).to include("Bundler #{current_version} is running, but your configuration was #{previous_minor}. Installing Bundler #{previous_minor} and restarting using that version.") @@ -178,8 +178,8 @@ lockfile_bundled_with(current_version) - bundle "config set --local version #{previous_minor}" - bundle "config set --local path.system true" + bundle_config "version #{previous_minor}" + bundle_config "path.system true" bundle "install" script = bundled_app("script.rb") @@ -192,7 +192,7 @@ it "does not try to install when using bundle config version global" do lockfile_bundled_with(previous_minor) - bundle "config set version system" + bundle_config "version system" bundle "install" expect(out).not_to match(/restarting using that version/) @@ -203,7 +203,7 @@ it "does not try to install when using bundle config version " do lockfile_bundled_with(previous_minor) - bundle "config set version #{previous_minor}.dev" + bundle_config "version #{previous_minor}.dev" bundle "install" expect(out).not_to match(/restarting using that version/) diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb index e3fa82f8560a23..a1c656bc3c89cd 100644 --- a/spec/bundler/runtime/setup_spec.rb +++ b/spec/bundler/runtime/setup_spec.rb @@ -135,7 +135,7 @@ def clean_load_path(lp) end it "orders the load path correctly when there are dependencies" do - bundle "config set path.system true" + bundle_config "path.system true" install_gemfile <<-G source "https://gem.repo1" @@ -163,7 +163,7 @@ def clean_load_path(lp) end it "falls back to order the load path alphabetically for backwards compatibility" do - bundle "config set path.system true" + bundle_config "path.system true" install_gemfile <<-G source "https://gem.repo1" @@ -286,7 +286,7 @@ def clean_load_path(lp) G bundle "install" - bundle "config set --local deployment true" + bundle_config "deployment true" ENV["BUNDLE_GEMFILE"] = "Gemfile" ruby <<-R @@ -316,7 +316,7 @@ def clean_load_path(lp) gem "activesupport", "2.3.5" G - bundle "config set --local gemfile #{bundled_app("CustomGemfile")}" + bundle_config "gemfile #{bundled_app("CustomGemfile")}" bundle "install" ruby <<-R @@ -490,7 +490,7 @@ def clean_load_path(lp) end it "does not randomly change the path when specifying --path and the bundle directory becomes read only" do - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" bundle :install with_read_only("#{bundled_app}/**/*") do @@ -499,7 +499,7 @@ def clean_load_path(lp) end it "finds git gem when default bundle path becomes read only" do - bundle "config set --local path .bundle" + bundle_config "path .bundle" bundle "install" with_read_only("#{bundled_app(".bundle")}/**/*") do @@ -594,7 +594,7 @@ def clean_load_path(lp) describe "when excluding groups" do it "doesn't change the resolve if --without is used" do - bundle "config set --local without rails" + bundle_config "without rails" install_gemfile <<-G source "https://gem.repo1" gem "activesupport" @@ -610,7 +610,7 @@ def clean_load_path(lp) end it "remembers --without and does not bail on bare Bundler.setup" do - bundle "config set --local without rails" + bundle_config "without rails" install_gemfile <<-G source "https://gem.repo1" gem "activesupport" @@ -626,7 +626,7 @@ def clean_load_path(lp) end it "remembers --without and does not bail on bare Bundler.setup, even in the case of path gems no longer available" do - bundle "config set --local without development" + bundle_config "without development" path = bundled_app(File.join("vendor", "foo")) build_lib "foo", path: path @@ -692,7 +692,7 @@ def clean_load_path(lp) end it "remembers --without and does not include groups passed to Bundler.setup" do - bundle "config set --local without rails" + bundle_config "without rails" install_gemfile <<-G source "https://gem.repo1" gem "activesupport" @@ -1114,7 +1114,7 @@ def clean_load_path(lp) describe "with system gems in the bundle" do before :each do - bundle "config set path.system true" + bundle_config "path.system true" system_gems "myrack-1.0.0" install_gemfile <<-G @@ -1228,7 +1228,7 @@ def lock_with(bundler_version = nil) end before do - bundle "config set --local path.system true" + bundle_config "path.system true" install_gemfile <<-G source "https://gem.repo1" @@ -1512,7 +1512,7 @@ def lock_with(ruby_version = nil) gem "net-http-pipeline", "1.0.1" G - bundle "config set --local path vendor/bundle" + bundle_config "path vendor/bundle" bundle :install @@ -1663,7 +1663,7 @@ def require(path) gem "myrack", :group => :test G - bundle "config set auto_install 1" + bundle_config "auto_install 1" ruby <<-RUBY, artifice: "compact_index" require 'bundler/setup' diff --git a/spec/bundler/support/filters.rb b/spec/bundler/support/filters.rb index 6c9127cd950eff..2be25b4a78a6fe 100644 --- a/spec/bundler/support/filters.rb +++ b/spec/bundler/support/filters.rb @@ -37,6 +37,6 @@ def inspect config.filter_run_when_matching :focus unless ENV["CI"] config.before(:each, :bundler) do |example| - bundle "config simulate_version #{example.metadata[:bundler]}" + bundle_config "simulate_version #{example.metadata[:bundler]}" end end diff --git a/spec/bundler/support/helpers.rb b/spec/bundler/support/helpers.rb index b763d83b059493..b0d4b5008ba742 100644 --- a/spec/bundler/support/helpers.rb +++ b/spec/bundler/support/helpers.rb @@ -191,7 +191,12 @@ def sys_exec(cmd, options = {}, &block) sh(cmd, options, &block) end - def config(config = nil, path = bundled_app(".bundle/config")) + def bundle_config(config = nil, path = bundled_app(".bundle/config")) + if config.is_a?(String) + key, value = config.split(" ", 2) + config = { Bundler::Settings.key_for(key) => value } + end + current = File.exist?(path) ? Psych.load_file(path) : {} return current unless config @@ -208,8 +213,8 @@ def config(config = nil, path = bundled_app(".bundle/config")) new_config end - def global_config(config = nil) - config(config, home(".bundle/config")) + def bundle_config_global(config = nil) + bundle_config(config, home(".bundle/config")) end def create_file(path, contents = "") diff --git a/spec/bundler/update/gemfile_spec.rb b/spec/bundler/update/gemfile_spec.rb index cb94799061f008..f8849640b6100c 100644 --- a/spec/bundler/update/gemfile_spec.rb +++ b/spec/bundler/update/gemfile_spec.rb @@ -25,7 +25,7 @@ gem 'myrack' G - bundle "config set --local gemfile #{bundled_app("NotGemfile")}" + bundle_config "gemfile #{bundled_app("NotGemfile")}" bundle :install end diff --git a/test/json/json_coder_test.rb b/test/json/json_coder_test.rb index 47e12ff919d660..a8477dd7be89b1 100755 --- a/test/json/json_coder_test.rb +++ b/test/json/json_coder_test.rb @@ -19,6 +19,11 @@ def test_json_coder_with_proc_with_unsupported_value assert_raise(JSON::GeneratorError) { coder.dump([Object.new]) } end + def test_json_coder_with_proc_returning_symbol + coder = JSON::Coder.new { _1 } + assert_equal %({"sym":"sym"}), coder.dump({ sym: :sym }) + end + def test_json_coder_hash_key obj = Object.new coder = JSON::Coder.new do |obj, is_key| diff --git a/test/json/json_generator_test.rb b/test/json/json_generator_test.rb index 0eb85a82653e7c..1cfd19da1228e7 100755 --- a/test/json/json_generator_test.rb +++ b/test/json/json_generator_test.rb @@ -82,6 +82,8 @@ def test_dump_strict assert_equal '"hello"', dump(:hello, strict: true) assert_equal '"hello"', :hello.to_json(strict: true) assert_equal '"World"', "World".to_json(strict: true) + assert_equal '["hello"]', dump([:hello], strict: true) + assert_equal '{"hello":"world"}', dump({ hello: :world }, strict: true) end def test_not_frozen diff --git a/test/prism/api/freeze_test.rb b/test/prism/api/freeze_test.rb index 5533a003313856..bf91792e6986a3 100644 --- a/test/prism/api/freeze_test.rb +++ b/test/prism/api/freeze_test.rb @@ -8,6 +8,11 @@ def test_parse assert_frozen(Prism.parse("1 + 2; %i{foo} + %i{bar}", freeze: true)) end + def test_offsets_usable + node = Prism.parse_statement("1 + 2", freeze: true) + assert_equal(1, node.start_line) + end + def test_lex assert_frozen(Prism.lex("1 + 2; %i{foo} + %i{bar}", freeze: true)) end diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb index dc48d9219f9919..6976bd97423bd9 100644 --- a/test/ruby/test_fiber.rb +++ b/test/ruby/test_fiber.rb @@ -508,20 +508,43 @@ def test_machine_stack_gc end def test_fiber_pool_stack_acquire_failure - omit "cannot determine max_map_count" unless File.exist?("/proc/sys/vm/max_map_count") - # On these platforms, excessive memory usage can cause the test to fail unexpectedly. - omit "not supported on IBM platforms" if RUBY_PLATFORM =~ /s390x|powerpc/ - omit "not supported with YJIT" if defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled? - omit "not supported with ZJIT" if defined?(RubyVM::ZJIT) && RubyVM::ZJIT.enabled? - - assert_separately([], <<~RUBY, timeout: 120) - max_map_count = File.read("/proc/sys/vm/max_map_count").to_i + environment = { + "RUBY_SHARED_FIBER_POOL_MINIMUM_COUNT" => "0", + "RUBY_SHARED_FIBER_POOL_MAXIMUM_COUNT" => "128" + } + + # This program requires, effectively, at most one fiber stack, since the fiber immediately becomes unreachable. + assert_separately([environment], <<~RUBY, timeout: 30) GC.disable + count_before = GC.count + + # Create more fibers than the pool can handle (but they become immediately unreachable): assert_nothing_raised do - (max_map_count + 10).times do - Fiber.new { Fiber.yield }.resume + 256.times do + Fiber.new{Fiber.yield}.resume + end + end + + # Major GC should have happened at least once: + assert_operator(GC.count, :>, count_before) + RUBY + end + + def test_fiber_pool_stack_acquire_failure_at_maximum_count + environment = { + "RUBY_SHARED_FIBER_POOL_MAXIMUM_COUNT" => "128" + } + + assert_separately([environment], <<~RUBY, timeout: 30) + GC.disable + fibers = [] + assert_raise(FiberError) do + loop do + Fiber.new{fibers << Fiber.current; Fiber.yield}.resume + raise "expected FiberError before this" if fibers.size > 128 end end + assert_operator fibers.size, :>=, 128 RUBY end end diff --git a/test/rubygems/test_gem_version.rb b/test/rubygems/test_gem_version.rb index 7ad085d480186e..5cd4228f2fccb9 100644 --- a/test/rubygems/test_gem_version.rb +++ b/test/rubygems/test_gem_version.rb @@ -220,6 +220,20 @@ def test_sort_key_is_not_computed_on_huge_numbers assert_nil v("2.30.1.250000").send(:sort_key) end + def test_sort_key_on_timestamped_version + a = v("1.0.0") + b = v("0.0.1.20220404083012") + + assert_operator a, :>, b + end + + def test_sort_key_when_segment_is_higher_than_radix + a = v("0.7.0") + b = v("0.6.63000") + + assert_operator(a, :>, b) + end + def test_sort_key_is_used_for_comparison a = v("18.0.1") b = v("18.0.2") diff --git a/test/socket/test_nonblock.rb b/test/socket/test_nonblock.rb index 5a4688bac3421a..68fefc44b3f032 100644 --- a/test/socket/test_nonblock.rb +++ b/test/socket/test_nonblock.rb @@ -104,7 +104,7 @@ def test_udp_recvfrom_nonblock assert_raise(IO::WaitReadable) { u1.recvfrom_nonblock(100) } u2.send("", 0, u1.getsockname) assert_nothing_raised("cygwin 1.5.19 has a problem to send an empty UDP packet. [ruby-dev:28915]") { - Timeout.timeout(1) { IO.select [u1] } + Timeout.timeout(30) { IO.select [u1] } } mesg, inet_addr = u1.recvfrom_nonblock(100) assert_equal("", mesg) @@ -126,7 +126,7 @@ def test_udp_recv_nonblock assert_raise(IO::WaitReadable) { u1.recv_nonblock(100) } u2.send("", 0, u1.getsockname) assert_nothing_raised("cygwin 1.5.19 has a problem to send an empty UDP packet. [ruby-dev:28915]") { - Timeout.timeout(1) { IO.select [u1] } + Timeout.timeout(30) { IO.select [u1] } } mesg = u1.recv_nonblock(100) assert_equal("", mesg) diff --git a/tool/lib/_tmpdir.rb b/tool/lib/_tmpdir.rb index a3b0739d85415c..89fd2b24cd6ae5 100644 --- a/tool/lib/_tmpdir.rb +++ b/tool/lib/_tmpdir.rb @@ -85,10 +85,15 @@ def list_tree(parent, indent = "", &block) warn colorize.notice("Children under ")+colorize.fail(tmpdir)+":" Dir.chdir(tmpdir) do ls.list_tree(".") do |path, st| - if st.directory? - Dir.rmdir(path) - else - File.unlink(path) + begin + if st.directory? + Dir.rmdir(path) + else + File.unlink(path) + end + rescue Errno::EACCES + # On Windows, a killed process may still hold file locks briefly. + # Ignore and let FileUtils.rm_rf handle it below. end end end diff --git a/zjit.rb b/zjit.rb index 5c7db11c933c9e..e298b509049039 100644 --- a/zjit.rb +++ b/zjit.rb @@ -243,14 +243,15 @@ def print_counters_with_prefix(buf:, stats:, prefix:, prompt:, limit: nil) return if counters.empty? counters.transform_keys! { |key| key.to_s.delete_prefix(prefix) } - key_pad = counters.keys.map(&:size).max - value_pad = counters.values.map { |value| number_with_delimiter(value).size }.max total = counters.values.sum counters = counters.to_a counters.sort_by! { |_, value| -value } counters = counters.first(limit) if limit + key_pad = counters.map { |key, _| key.size }.max + value_pad = counters.map { |_, value| number_with_delimiter(value).size }.max + buf << "Top-#{counters.size} " if limit buf << "#{prompt}" buf << " (%.1f%% of total #{number_with_delimiter(total)})" % (100.0 * counters.map(&:last).sum / total) if limit diff --git a/zjit/Cargo.lock b/zjit/Cargo.lock index b126e46befe2b4..1e7f1b3eec23ad 100644 --- a/zjit/Cargo.lock +++ b/zjit/Cargo.lock @@ -44,14 +44,13 @@ checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "console" -version = "0.15.11" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "054ccb5b10f9f2cbf51eb355ca1d05c2d279ce1804688d0db74b4733a5aeafd8" +checksum = "d64e8af5551369d19cf50138de61f1c42074ab970f74e99be916646777f8fc87" dependencies = [ "encode_unicode", "libc", - "once_cell", - "windows-sys 0.59.0", + "windows-sys", ] [[package]] @@ -67,7 +66,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys", ] [[package]] @@ -90,9 +89,9 @@ dependencies = [ [[package]] name = "insta" -version = "1.46.3" +version = "1.47.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e82db8c87c7f1ccecb34ce0c24399b8a73081427f3c7c50a5d597925356115e4" +checksum = "6f40e41efb5f592d3a0764f818e2f08e5e21c4f368126f74f37c81bd4af7a0c6" dependencies = [ "console", "once_cell", @@ -122,12 +121,68 @@ version = "1.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc" +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +dependencies = [ + "proc-macro2", +] + [[package]] name = "r-efi" version = "5.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" +[[package]] +name = "rand" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +dependencies = [ + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom", +] + [[package]] name = "rustix" version = "1.1.3" @@ -138,7 +193,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.61.2", + "windows-sys", ] [[package]] @@ -159,6 +214,17 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "syn" +version = "2.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "tempfile" version = "3.24.0" @@ -169,9 +235,15 @@ dependencies = [ "getrandom", "once_cell", "rustix", - "windows-sys 0.61.2", + "windows-sys", ] +[[package]] +name = "unicode-ident" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" + [[package]] name = "wasip2" version = "1.0.1+wasi-0.2.4" @@ -187,15 +259,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" -[[package]] -name = "windows-sys" -version = "0.59.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" -dependencies = [ - "windows-targets", -] - [[package]] name = "windows-sys" version = "0.61.2" @@ -206,74 +269,37 @@ dependencies = [ ] [[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" +name = "wit-bindgen" +version = "0.46.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" [[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +name = "yjit" +version = "0.1.0" +dependencies = [ + "jit", +] [[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" +name = "zerocopy" +version = "0.8.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +checksum = "efbb2a062be311f2ba113ce66f697a4dc589f85e78a4aea276200804cea0ed87" +dependencies = [ + "zerocopy-derive", +] [[package]] -name = "wit-bindgen" -version = "0.46.0" +name = "zerocopy-derive" +version = "0.8.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59" +checksum = "0e8bc7269b54418e7aeeef514aa68f8690b8c0489a06b0136e5f57c4c5ccab89" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "zjit" @@ -282,4 +308,6 @@ dependencies = [ "capstone", "insta", "jit", + "rand", + "yjit", ] diff --git a/zjit/Cargo.toml b/zjit/Cargo.toml index 1bfcc4aff06813..63c514e483cc3b 100644 --- a/zjit/Cargo.toml +++ b/zjit/Cargo.toml @@ -12,7 +12,7 @@ capstone = { version = "0.14.0", optional = true } jit = { version = "0.1.0", path = "../jit" } [dev-dependencies] -insta = "1.43.1" +insta = "1.47.0" rand = "0.9" yjit = { path = "../yjit" } diff --git a/zjit/src/codegen.rs b/zjit/src/codegen.rs index 916e7d02a3d093..2f2454f41e362a 100644 --- a/zjit/src/codegen.rs +++ b/zjit/src/codegen.rs @@ -636,6 +636,7 @@ fn gen_insn(cb: &mut CodeBlock, jit: &mut JITState, asm: &mut Assembler, functio Insn::FixnumAnd { left, right } => gen_fixnum_and(asm, opnd!(left), opnd!(right)), Insn::FixnumOr { left, right } => gen_fixnum_or(asm, opnd!(left), opnd!(right)), Insn::FixnumXor { left, right } => gen_fixnum_xor(asm, opnd!(left), opnd!(right)), + Insn::IntOr { left, right } => gen_int_or(asm, opnd!(left), opnd!(right)), &Insn::FixnumLShift { left, right, state } => { // We only create FixnumLShift when we know the shift amount statically and it's in [0, // 63]. @@ -2264,6 +2265,11 @@ fn gen_fixnum_or(asm: &mut Assembler, left: lir::Opnd, right: lir::Opnd) -> lir: asm.or(left, right) } +/// Compile C integer | C integer. +fn gen_int_or(asm: &mut Assembler, left: lir::Opnd, right: lir::Opnd) -> lir::Opnd { + asm.or(left, right) +} + /// Compile Fixnum ^ Fixnum fn gen_fixnum_xor(asm: &mut Assembler, left: lir::Opnd, right: lir::Opnd) -> lir::Opnd { // XOR and then re-tag the resulting fixnum diff --git a/zjit/src/codegen_tests.rs b/zjit/src/codegen_tests.rs index f897347f87cd7e..3a21b001cd13c6 100644 --- a/zjit/src/codegen_tests.rs +++ b/zjit/src/codegen_tests.rs @@ -432,6 +432,50 @@ fn test_getblockparam() { assert_snapshot!(assert_compiles("test { 2 }.call"), @"2"); } +#[test] +fn test_setblockparam() { + eval(" + def test(&block) + block = proc { 3 } + blk = block + blk.call + end + test { 1 } + "); + assert_contains_opcode("test", YARVINSN_setblockparam); + assert_snapshot!(assert_compiles("test { 1 }"), @"3"); +} + +#[test] +fn test_setblockparam_nested_block() { + eval(" + def test(&block) + proc do + block = proc { 3 } + blk = block + blk.call + end.call + end + test { 1 } + "); + assert_snapshot!(assert_compiles("test { 1 }"), @"3"); +} + +#[test] +fn test_setblockparam_side_exit() { + // This pattern side exits because `block.call` goes through + // getblockparamproxy's modified-block-parameter case. + eval(" + def test(&block) + block = proc { 3 } + block.call + end + test { 1 } + "); + assert_contains_opcode("test", YARVINSN_setblockparam); + assert_snapshot!(inspect("test { 1 }"), @"3"); +} + #[test] fn test_getblockparam_proxy_side_exit_restores_block_local() { eval(" diff --git a/zjit/src/hir.rs b/zjit/src/hir.rs index 71d0a99afda49a..591ca0aad7cf22 100644 --- a/zjit/src/hir.rs +++ b/zjit/src/hir.rs @@ -1040,6 +1040,7 @@ pub enum Insn { FixnumAnd { left: InsnId, right: InsnId }, FixnumOr { left: InsnId, right: InsnId }, FixnumXor { left: InsnId, right: InsnId }, + IntOr { left: InsnId, right: InsnId }, FixnumLShift { left: InsnId, right: InsnId, state: InsnId }, FixnumRShift { left: InsnId, right: InsnId }, @@ -1242,6 +1243,7 @@ macro_rules! for_each_operand_impl { | Insn::FixnumAnd { left, right } | Insn::FixnumOr { left, right } | Insn::FixnumXor { left, right } + | Insn::IntOr { left, right } | Insn::FixnumRShift { left, right } | Insn::IsBitEqual { left, right } | Insn::IsBitNotEqual { left, right } => { @@ -1577,6 +1579,7 @@ impl Insn { Insn::FixnumAnd { .. } => effects::Empty, Insn::FixnumOr { .. } => effects::Empty, Insn::FixnumXor { .. } => effects::Empty, + Insn::IntOr { .. } => effects::Empty, Insn::FixnumLShift { .. } => effects::Empty, Insn::FixnumRShift { .. } => effects::Empty, Insn::ObjToString { .. } => effects::Any, @@ -1954,6 +1957,7 @@ impl<'a> std::fmt::Display for InsnPrinter<'a> { Insn::FixnumAnd { left, right, .. } => { write!(f, "FixnumAnd {left}, {right}") }, Insn::FixnumOr { left, right, .. } => { write!(f, "FixnumOr {left}, {right}") }, Insn::FixnumXor { left, right, .. } => { write!(f, "FixnumXor {left}, {right}") }, + Insn::IntOr { left, right } => { write!(f, "IntOr {left}, {right}") }, Insn::FixnumLShift { left, right, .. } => { write!(f, "FixnumLShift {left}, {right}") }, Insn::FixnumRShift { left, right, .. } => { write!(f, "FixnumRShift {left}, {right}") }, Insn::GuardType { val, guard_type, .. } => { write!(f, "GuardType {val}, {}", guard_type.print(self.ptr_map)) }, @@ -2738,6 +2742,7 @@ impl Function { &FixnumAnd { left, right } => FixnumAnd { left: find!(left), right: find!(right) }, &FixnumOr { left, right } => FixnumOr { left: find!(left), right: find!(right) }, &FixnumXor { left, right } => FixnumXor { left: find!(left), right: find!(right) }, + &IntOr { left, right } => IntOr { left: find!(left), right: find!(right) }, &FixnumLShift { left, right, state } => FixnumLShift { left: find!(left), right: find!(right), state }, &FixnumRShift { left, right } => FixnumRShift { left: find!(left), right: find!(right) }, &ObjToString { val, cd, state } => ObjToString { @@ -2993,6 +2998,7 @@ impl Function { Insn::FixnumAnd { .. } => types::Fixnum, Insn::FixnumOr { .. } => types::Fixnum, Insn::FixnumXor { .. } => types::Fixnum, + Insn::IntOr { left, .. } => self.type_of(*left).unspecialized(), Insn::FixnumLShift { .. } => types::Fixnum, Insn::FixnumRShift { .. } => types::Fixnum, Insn::PutSpecialObject { .. } => types::BasicObject, @@ -6169,6 +6175,11 @@ impl Function { Err(ValidationError::MiscValidationError(insn_id, "IsBitEqual can only compare CInt/CInt or RubyValue/RubyValue".to_string())) } } + Insn::IntOr { left, right } => { + // TODO: Expand this to other matching C integer sizes when we need them. + self.assert_subtype(insn_id, left, types::CInt64)?; + self.assert_subtype(insn_id, right, types::CInt64) + } Insn::BoxBool { val } | Insn::IfTrue { val, .. } | Insn::IfFalse { val, .. } => { @@ -7442,6 +7453,32 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result { let level = get_arg(pc, 1).as_u32(); fun.push_insn(block, Insn::SetLocal { val: state.stack_pop()?, ep_offset, level }); } + YARVINSN_setblockparam => { + let ep_offset = get_arg(pc, 0).as_u32(); + let level = get_arg(pc, 1).as_u32(); + let val = state.stack_pop()?; + fun.push_insn(block, Insn::SetLocal { val, ep_offset, level }); + if level == 0 { + state.setlocal(ep_offset, val); + } + let ep = fun.push_insn(block, Insn::GetEP { level }); + let flags = fun.push_insn(block, Insn::LoadField { + recv: ep, + id: ID!(_env_data_index_flags), + offset: SIZEOF_VALUE_I32 * (VM_ENV_DATA_INDEX_FLAGS as i32), + return_type: types::CInt64, + }); + let modified_flag = fun.push_insn(block, Insn::Const { + val: Const::CInt64(VM_FRAME_FLAG_MODIFIED_BLOCK_PARAM.into()), + }); + let modified = fun.push_insn(block, Insn::IntOr { left: flags, right: modified_flag }); + fun.push_insn(block, Insn::StoreField { + recv: ep, + id: ID!(_env_data_index_flags), + offset: SIZEOF_VALUE_I32 * (VM_ENV_DATA_INDEX_FLAGS as i32), + val: modified, + }); + } YARVINSN_getblockparamproxy => { let level = get_arg(pc, 1).as_u32(); diff --git a/zjit/src/hir/opt_tests.rs b/zjit/src/hir/opt_tests.rs index 8dd8f762c68231..2d3e43d0f1978b 100644 --- a/zjit/src/hir/opt_tests.rs +++ b/zjit/src/hir/opt_tests.rs @@ -4815,6 +4815,72 @@ mod hir_opt_tests { "); } + #[test] + fn test_setblockparam() { + eval(" + def test(&block) + block = nil + end + "); + assert_contains_opcode("test", YARVINSN_setblockparam); + assert_snapshot!(hir_string("test"), @" + fn test@:3: + bb1(): + EntryPoint interpreter + v1:BasicObject = LoadSelf + v2:CPtr = LoadSP + v3:BasicObject = LoadField v2, :block@0x1000 + Jump bb3(v1, v3) + bb2(): + EntryPoint JIT(0) + v6:BasicObject = LoadArg :self@0 + v7:BasicObject = LoadArg :block@1 + Jump bb3(v6, v7) + bb3(v9:BasicObject, v10:BasicObject): + v14:NilClass = Const Value(nil) + SetLocal :block, l0, EP@3, v14 + v18:CPtr = GetEP 0 + v19:CInt64 = LoadField v18, :_env_data_index_flags@0x1001 + v20:CInt64[512] = Const CInt64(512) + v21:CInt64 = IntOr v19, v20 + StoreField v18, :_env_data_index_flags@0x1001, v21 + CheckInterrupts + Return v14 + "); + } + + #[test] + fn test_setblockparam_nested_block() { + eval(" + def test(&block) + proc do + block = nil + end + end + "); + assert_snapshot!(hir_string_proc("test"), @" + fn block in test@:4: + bb1(): + EntryPoint interpreter + v1:BasicObject = LoadSelf + Jump bb3(v1) + bb2(): + EntryPoint JIT(0) + v4:BasicObject = LoadArg :self@0 + Jump bb3(v4) + bb3(v6:BasicObject): + v10:NilClass = Const Value(nil) + SetLocal :block, l1, EP@3, v10 + v14:CPtr = GetEP 1 + v15:CInt64 = LoadField v14, :_env_data_index_flags@0x1000 + v16:CInt64[512] = Const CInt64(512) + v17:CInt64 = IntOr v15, v16 + StoreField v14, :_env_data_index_flags@0x1000, v17 + CheckInterrupts + Return v10 + "); + } + #[test] fn test_getinstancevariable() { eval(" diff --git a/zjit/src/hir/tests.rs b/zjit/src/hir/tests.rs index 7a36d99cdf491c..a26f699c5be74f 100644 --- a/zjit/src/hir/tests.rs +++ b/zjit/src/hir/tests.rs @@ -3387,6 +3387,72 @@ pub mod hir_build_tests { "); } + #[test] + fn test_setblockparam() { + eval(" + def test(&block) + block = nil + end + "); + assert_contains_opcode("test", YARVINSN_setblockparam); + assert_snapshot!(hir_string("test"), @" + fn test@:3: + bb1(): + EntryPoint interpreter + v1:BasicObject = LoadSelf + v2:CPtr = LoadSP + v3:BasicObject = LoadField v2, :block@0x1000 + Jump bb3(v1, v3) + bb2(): + EntryPoint JIT(0) + v6:BasicObject = LoadArg :self@0 + v7:BasicObject = LoadArg :block@1 + Jump bb3(v6, v7) + bb3(v9:BasicObject, v10:BasicObject): + v14:NilClass = Const Value(nil) + SetLocal :block, l0, EP@3, v14 + v18:CPtr = GetEP 0 + v19:CInt64 = LoadField v18, :_env_data_index_flags@0x1001 + v20:CInt64[512] = Const CInt64(512) + v21:CInt64 = IntOr v19, v20 + StoreField v18, :_env_data_index_flags@0x1001, v21 + CheckInterrupts + Return v14 + "); + } + + #[test] + fn test_setblockparam_nested_block() { + eval(" + def test(&block) + proc do + block = nil + end + end + "); + assert_snapshot!(hir_string_proc("test"), @" + fn block in test@:4: + bb1(): + EntryPoint interpreter + v1:BasicObject = LoadSelf + Jump bb3(v1) + bb2(): + EntryPoint JIT(0) + v4:BasicObject = LoadArg :self@0 + Jump bb3(v4) + bb3(v6:BasicObject): + v10:NilClass = Const Value(nil) + SetLocal :block, l1, EP@3, v10 + v14:CPtr = GetEP 1 + v15:CInt64 = LoadField v14, :_env_data_index_flags@0x1000 + v16:CInt64[512] = Const CInt64(512) + v17:CInt64 = IntOr v15, v16 + StoreField v14, :_env_data_index_flags@0x1000, v17 + CheckInterrupts + Return v10 + "); + } + #[test] fn test_splatkw_unprofiled_side_exits() { eval("