Commit graph

115 commits

Author SHA1 Message Date
David Rodríguez
95fdaa5c3b
(Temporarily?) delay path changes and global cache changes
There are several issues with these which I'm not sure I'll have time to
address properly. I prefer to keep our default branch in a releasable
state just in case. Once they are fixed, this can be reverted.
2025-07-28 10:01:58 +09:00
David Rodríguez
2690d21067 [rubygems/rubygems] The install_gemfile helper has not set "retry" for a long time
41dab5954f
2025-07-28 09:39:02 +09:00
David Rodríguez
60fca1defc
Cancel --force deprecation in favor of --redownload
I realized `--redownload` is not a good name, because it does not
necessarily redownloads gems. It only forces reinstallation even if gem
is already installed.

So I believe `--force` is actually a better name and the introduction of
`--force` was a misunderstanding of what the `--force` flag did at the
time.

Let's cancel the deprecation of `--force`.

For now the `--redownload` alias is left around until we decide what to
do with it.
2025-07-17 11:10:46 +09:00
David Rodríguez
c4c646d1bb
[rubygems/rubygems] Handle connection refused and Errno::EADDRNOTAVAIL as non-retryable
cd529776d5
2025-07-02 10:34:19 +09:00
David Rodríguez
9e566141cd [rubygems/rubygems] Remove "double CI" for testing Bundler 4 mode
Since now every functionality that changes in Bundler 4 is under a
setting, we can enable that setting to test the new functionality,
without having to run our full CI twice.

This can actually be seen as increasing coverage, because Bundler 4
functionality will now be tested on Windows, MacOS, or any other
environment where previously "Bundler 4 mode" was not running.

1cb3e009fc
2025-06-30 12:56:50 +09:00
David Rodríguez
8f009601f9 [rubygems/rubygems] Handle Errno::EADDRNOTAVAIL gracefully
As showed by the unskiped spec, on Windows trying to use the 0.0.0.0
interface raises this error, and it's raised as a generic system error
when trying to create a `bundler.lock` file. Here's is a better place to
handle that.

e32c5a9e5c
2025-06-23 11:07:02 +09:00
David Rodríguez
f3ea6c35cc
[rubygems/rubygems] Normalize Bundler version spec filters
28b6a7cf5e
2025-06-19 10:23:36 +09:00
Randy Stauner
b5beb19825 [rubygems/rubygems] Validate dependencies when doing bundle install
b0983f392f
2025-06-11 08:48:55 +09:00
David Rodríguez
d95f7a3c43
[rubygems/rubygems] Extract stdboth spec helper
bb13f4e702
2025-06-06 10:09:14 +09:00
David Rodríguez
58663e8e2c [rubygems/rubygems] Change behavior when gemfile and gemspec dep deps conflict
7026b5f2e5
2025-03-24 13:25:07 +09:00
David Rodríguez
afda30774c [rubygems/rubygems] Reword log message about current platform being missing
It reads better this way I think.

ce9743290d
2025-03-24 13:25:07 +09:00
David Rodríguez
bb1b5877a7 [rubygems/rubygems] Consistently use "lockfile" over "lock file"
e891be9197
2025-03-24 13:25:07 +09:00
David Rodríguez
51958bae66 [rubygems/rubygems] Prefer FileUtils.rm_r to FileUtils.rm_rf for specs
Because it does not swallow errors if it fails to remove the given
folders, making issues easier to debug.

0db12d7afc
2025-03-12 18:02:09 +09:00
David Rodríguez
f656d34f10 [rubygems/rubygems] Refactor specs to not try to remove folders that don't exist
This has the following benefits:

* Avoid duplicated work in some specs that first build a repo, and then
  overwrite it with a completely different set of gems.
* Reduce RSpec nesting and improve readability.
* The change also made surfaces several specs that were incorrect since
  they were unintentionally not testing the right thing.

ed430883e0
2025-03-12 18:02:09 +09:00
David Rodríguez
158e4cc4ec [rubygems/rubygems] Improve log message about adding a new platform
This message is printed when running `bundle lock --add-platform`. This
command affects the lockfile, not the gemfile, and I think it's better
to use "You are adding" rather than "You added", because the addition is
happening during the current invocation (as opposed to other log
messages that talk about a change made to the Gemfile prior to running
the command).

aba1e55f5b
2025-02-25 15:36:46 +09:00
David Rodríguez
8b952e6489 [rubygems/rubygems] Improve log message when resolving due to local platform not in lockfile
Current it says "you added a new platform to your gemfile", but that's
not actually the case here.

1e39527a38
2025-02-25 15:36:46 +09:00
David Rodríguez
5d8fe7a595
[rubygems/rubygems] Make sure empty gems are not reinstalled every time
Unfortunately this requires reverting a previous enhancement of
reinstalling gems if they incorrectly ship with an empty installation
dir.

However, there's no way to distinguish this kind of bad state from a gem
that's empty for real, for example, sorbet-static-and-runtime.

This reverts commit 9720a9b980, and adds a
spec to make sure empty gems are not reinstalled every time.

7c102394af
2025-02-19 11:04:09 +09:00
David Rodríguez
c8f4df4ae9 [rubygems/rubygems] Make Bundler never instantiate development dependencies
Bundler does not really have a concept of "development dependencies",
like RubyGems has. Bundler has the more generic concept of "groups".

Under the hood, the `gemspec` DSL will put gemspec development
dependencies under a `:development` Gemfile group, but there's no reason
to instantiate these as development dependencies, they are regular
runtime dependencies, except that they belong in a group named
:development.

By never instantiating development dependencies at all, we avoid having
to introduce hacks to "undo" the type Bundler does not know about, and I
also think the error messages read better.

9a06fa5bda
2025-02-17 11:04:39 +09:00
David Rodríguez
ee03df26ba
[rubygems/rubygems] --prefer-local should resolve to latest version if no gems are available locally
Filtering out remote specs should only apply where there are locally
installed specs. Otherwise they should always be considered.

118f8389a1
2025-02-13 09:37:51 +09:00
David Rodríguez
ac093f4350 [rubygems/rubygems] Auto-heal empty installation directory
9720a9b980
2025-02-06 15:58:00 +09:00
David Rodríguez
d8394461fd [rubygems/rubygems] Support installing arm native gems on Windows
96496e3f53

Co-authored-by: Johnny Shields <johnny.shields@gmail.com>
2025-01-28 15:31:53 +09:00
David Rodríguez
09b04fefb7 [rubygems/rubygems] Remove unnecessary platform helpers
I think they add unnecessary indirection and inconsistency to the specs.

609924d985
2025-01-28 15:31:49 +09:00
David Rodríguez
10e7e92bad [rubygems/rubygems] Extract logic to manipulate RUBYLIB in specs to a helper
0057382bb1
2025-01-16 19:41:11 +09:00
David Rodríguez
11e522b913 [rubygems/rubygems] Fix installs of subdependencies of unlocked dependencies to be conservative
When converging specification to pass the set of versions that should be
preserved from the lockfile during resolution, we should make sure all
top level gems are considered, and only exclude those gems themselves
(and not their dependencies) if their locked versions happen to not be
satisfied by an edited Gemfile.

ed2f1b7b88
2024-11-26 15:11:05 +09:00
David Rodríguez
ffcfaf4ce4 [rubygems/rubygems] Undeprecate Gemfiles without a global source
After having a second look at this deprecation, the explanation that
we're giving does not make a lot of sense. When working only with local
gems, Bundler will indeed generate a different lockfile depending on
the latest installed version of each gem is at `bundle install` time.

That's the same situation that happens with remote sources: Bundler will
generate a different lockfile depending on the latest version of each
gem available remotely.

So, I don't think "a consistent lockfile not getting generated" is a
good motivation for deprecating this.

Also, this deprecation brings additional challenges, since for example,
it should arguably not get printed when using `bundle install --local`?

The original problem when this deprecation was introduced was an
incorrect message about a missing gem having been yanked.

So, I think a better solution is to, as long as we give proper error
messages when things go wrong, let users do what's best for them and
undo the deprecation.

17499cb83f
2024-11-07 10:03:54 +00:00
David Rodríguez
50dbe19b68 [rubygems/rubygems] Fix incompatible encodings error
d478ec403f
2024-11-04 10:04:40 +00:00
David Rodríguez
438d36eb4b [rubygems/rubygems] Print a proper error when there's a previous empty installation path with bad permissions
07e7f0bf5e
2024-10-23 11:16:53 +00:00
David Rodríguez
cc29d737ef [rubygems/rubygems] Consistently use :create action when creating directories
It gives better errors.

bedae080ef
2024-10-23 08:53:18 +00:00
David Rodríguez
88b969cd19 [rubygems/rubygems] Fix out of date spec description
71fd896041
2024-10-23 08:53:17 +00:00
David Rodríguez
d4a18d4a78 [rubygems/rubygems] Allow using gemspec DSL twice with same dependency and compatible requirements
a8d14c1fc2
2024-10-17 07:10:38 +00:00
David Rodríguez
fab01b15e9 [rubygems/rubygems] Remove temporary .lock files left around by gem installer
edbb2e3475
2024-09-16 11:37:58 +00:00
David Rodríguez
bb511c3f10 [rubygems/rubygems] Don't try to remove previous install folder if it's empty
Ruby ships with empty directories for default gems. If Ruby
installations has unsafe world-writable permissions, we will complain
when about to install a gem that happens to be also a default gem,
because we'll start by removing the previous install folder and that's
supposed to be insecure due to too loose permissions.

However, if the folder is empty, we don't actually need to remove
anything, so we can skip the whole thing, avoiding the errors.

2f3cd8ac4e
2024-09-02 14:01:15 +00:00
David Rodríguez
b00b0d5f8f [rubygems/rubygems] Improve insecure gem overwrite message
7c71dac22e
2024-09-02 14:01:14 +00:00
David Rodríguez
2569413b1c [rubygems/rubygems] Fix --prefer-local flag
The original implementation of this flag was too naive and all it did
was restricting gems to locally installed versions if there are any
local versions installed.

However, it should be much smarter. For example:

* It should fallback to remote versions if locally installed version
  don't satisfy the requirements.
* It should pick locally installed versions even for subdependencies not
  yet discovered.

This commit fixes both issues by using a smarter approach similar to how
we resolve prereleases:

* First resolve optimistically using only locally installed gems.
* If any conflicts are found, scan those conflicts, allow remote
  versions for the specific gems that run into conflicts, and
  re-resolve.

607a3bf479

Co-authored-by: Gourav Khunger <gouravkhunger18@gmail.com>
2024-08-22 11:48:32 +00:00
David Rodríguez
0dda30d9eb [rubygems/rubygems] Print a better debug message when lockfile does not include the current platform
afb7a6d754
2024-07-30 14:02:03 +00:00
David Rodríguez
997642cfbd [rubygems/rubygems] The simulate_platform helper can take a string
680bafac1a
2024-07-30 14:02:02 +00:00
David Rodríguez
bfaccd6433 [rubygems/rubygems] Make all tests still pass when switching from truffleruby to cruby
4f3d9fa3bf
2024-07-26 08:05:53 +00:00
David Rodríguez
481c83453b [rubygems/rubygems] Enable checksums on Bundler 3 for fresh lockfiles
And get specs passing.

c23b5f5b84
2024-07-23 19:40:09 +00:00
David Rodríguez
1758d436e7 [rubygems/rubygems] Enforce passing a block to simulate_platform
0658903e25
2024-07-23 19:40:07 +00:00
David Rodríguez
1d97c46b35 [rubygems/rubygems] Minor Bundler spec improvements
While working on something else I noticed:

* Usage of uppercased "RUBY" and "JAVA" as platforms, when those don't
  really exist.
* Usage of some test gems with "1.0" as gemspec version and "1.0.0" as
  actual version.

This commit fixes both inconsistencies to make things more expectable.

e3ec32e247
2024-07-09 14:43:18 +00:00
Jerome Dalbert
bbb4da78c7 [rubygems/rubygems] Use preferred add_dependency instead of add_runtime_dependency
9a08043858
2024-07-05 02:24:53 +00:00
David Rodríguez
98c923ff4b
Synchronize Bundler & RubyGems (#11071) 2024-06-28 10:12:29 -04:00
David Rodríguez
815b345b41 [rubygems/rubygems] Print a proper error when bin dir does not have writable permission bit
979cd898f9
2024-06-27 12:53:05 +00:00
David Rodríguez
f88bb0e67d [rubygems/rubygems] Reword some specs to disambiguate chmod -x from chmod -w
2954ab79a9
2024-06-27 12:53:04 +00:00
David Rodríguez
6a474ef266 [rubygems/rubygems] Don't print bug report template when bin dir is not writable
f4ce3aae71
2024-06-14 10:05:20 +00:00
David Rodriguez
f5c6a395a5 [rubygems/rubygems] The tmp test helper already joins internally
2d9eeadb62
2024-06-06 18:44:37 +00:00
David Rodriguez
899568cce9 [rubygems/rubygems] Fix error when Bundler installation is corrupted
If one upgrades the default copy of Bundler through `gem update
--system`, and then reinstalls Ruby without removing the previous copy.
Then the new installation will have a correct default bundler gemspec,
but a higher copy installed in site_dir.

This causes a crash when running Bundler and prints the bug report
template.

This could probably be fixed in Ruby install script, by removing any
previous Bundler default copies, but if the problem is already there, I
think it's best to print a proper user error.

ada6de765d
2024-05-13 09:19:45 +00:00
David Rodríguez
d6cb62a88f [rubygems/rubygems] Show better error when installed gemspecs are unreadable
924f87c8a9
2024-04-29 08:57:35 +00:00
David Rodríguez
ef0705b3c2 [rubygems/rubygems] Fix development dependency not being added if introduced by two gemspecs
adc05bf1c3
2024-01-11 13:51:52 +09:00
Hiroshi SHIBATA
7d7a84e99f Merge RubyGems-3.5.3 and Bundler-2.5.3 2023-12-23 09:34:26 +09:00