Commit graph

67 commits

Author SHA1 Message Date
David Rodríguez
441f18df52
Skip to Bundler 4 directly 2025-06-19 10:23:36 +09:00
Samuel Giddins
c0a1e877b3
Move most of Bundler::GemHelpers to Gem::Platform
This will help centralize wheel platform selection logic eventually

Signed-off-by: Samuel Giddins <segiddins@segiddins.me>
2025-06-06 10:22:18 +09:00
David Rodríguez
000f019772 [rubygems/rubygems] Simplify passing "gemspec" option to path sources
9c6b57c01d
2025-03-24 13:25:07 +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
504b4bd9f5 [rubygems/rubygems] Use name argument consistently
4e66fe4208
2025-03-24 13:25:07 +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
johnnyshields
e11401f799
[rubygems/rubygems] Deprecate legacy windows platforms (mswin, mingw) in the Bundler DSL, in favor of using platform :windows
This commit is only deprecation and does not change/remove any actual functionality.

0ca6dc3984
2025-02-14 16:13:27 +09:00
David Rodríguez
d9267b4a71
[rubygems/rubygems] Fix type and gemfile not getting reported as invalid options
5b6077a1e8
2025-02-13 09:37:51 +09:00
Edouard CHIN
2ed30c9944 [rubygems/rubygems] Consolidate the platform into a single list:
- Similar change than 29a1be0008,
  keep a single source of truth where we store the platform.

  The only change worth highlighing is the platform "maglev".
  It was not part of the supported platform of dependencies,
  so calling `gem 'foo', plaftorm: 'maglev'` would not work.
  However, it was supposed to according to 45ec86e2e5.
  That's why it was possible to do `Bundler.current_ruby.maglev?` or
  `Bundler.current_ruby.maglev_30?`.

  I didn't change the current behaviour and maglev is not supported,
  though I kept the `*maglev` methods as I believe CurrentRuby is
  public API.

29e219ebcf
2025-01-31 14:34:26 +09:00
David Rodríguez
963f98a94f [rubygems/rubygems] Enable Performance/MapCompact cop
0c3a65871a
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
d4a18d4a78 [rubygems/rubygems] Allow using gemspec DSL twice with same dependency and compatible requirements
a8d14c1fc2
2024-10-17 07:10:38 +00:00
John Bampton
3fc1495c30 Fix spelling 2024-10-09 07:14:44 +09:00
David Rodríguez
89eba5074e [rubygems/rubygems] Only raise DSLError during Gemfile parsing when it's actually useful
DSLError prints the specific line in a Gemfile where the error was
raised. That's helpful when the error was explicitly raised by the
Gemfile DSL or, in the case it's implicitly raised, when the offending
code lives right in the Gemfile.

If it's an internal error, or something buried dowm in user code called
from the Gemfile, `DSLError` is not helpful since it hides the actual
culprit.

This commit tries to only raise `DSLError` in the cases mentioned above
and otherwise let the original error be raised.

b30ff5a682
2024-09-11 11:28:12 +00:00
David Rodríguez
1d72b3bd1a [rubygems/rubygems] Don't rescue Exception when evaluating Gemfile
Things like OOM, or StackOverflow should be raised immediately.

11691ce492
2024-09-11 11:28:12 +00:00
David Rodríguez
f0b9baa2d6 [rubygems/rubygems] Refactor setting current gemfile in DSL
b4ecb66224
2024-09-11 11:28:11 +00:00
David Rodríguez
1d768ebd71 [rubygems/rubygems] The dsl_path parameter in DSLError is documented as a string
ab44fa9ee4
2024-09-11 11:28:11 +00:00
Jason Garber
6f224d66a5 [rubygems/rubygems] Add gitlab: Git source shorthand
This new shorthand, similar to the existing `github:` shorthand, adds
support for Gitlab repositories with a notable difference. Gitlab
projects may be organized into projects and subprojects. An example
Ruby gem exists at:

https://gitlab.com/gitlab-org/analytics-section/product-analytics/gl-application-sdk-rb

With the new shorthand, a user may install this gem from its repository
by adding:

```ruby
gem "gitlab-sdk", gitlab: "gitlab-org/analytics-section/product-analytics/gl-application-sdk-rb"
```

As with the `github:` shorthand, a supplied string with no `/` will be
interpreted as `example/example`.

Also in keeping with the utility of the `github:` shorthand, the new
`gitlab:` shorthand also supports Merge Request URLs.

```ruby
gem "gitlab-sdk", gitlab: "https://gitlab.com/gitlab-org/analytics-section/product-analytics/gl-application-sdk-rb/-/merge_requests/27"
```

The `gitlab:` gem source shortcut is modeled on the existing `github:`
shortcut, so the new specs mimic the existing examples.

f4399018c0
2024-02-16 04:53:14 +00:00
Cody Cutrer
fa334ecd40 [rubygems/rubygems] use full path for instance_eval
so that __dir__ and __FILE__ will work properly from within that gemfile
fragment, if eval_gemfile is given a relative path

d521bf9790
2024-02-15 20:26:03 +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
David Rodríguez
c8e9cd2b8b [rubygems/rubygems] Fix Ruby DSL no longer working as expected
f6258e5679

Co-authored-by: AndrewSwerlick <andrew.swerlick@gmail.com>
2023-12-16 10:04:38 +08:00
Samuel Giddins
1cd4b59e8c [rubygems/rubygems] Save array allocation for every dependency in Gemfile
Only need to check for lack of git key when branch option is present

ebfca1b389
2023-12-15 14:53:10 +00:00
David Rodríguez
2755cb1b2f [rubygems/rubygems] Use modern hashes consistently
bb66253f2c
2023-12-07 22:29:33 +00:00
David Rodríguez
16669cd6ad [rubygems/rubygems] Fix crash when duplicating a dev dependency in Gemfile & gemspec
e78c0a4a48
2023-12-05 14:28:42 +09:00
Eric Mueller
73440e1ef2 [rubygems/rubygems] Many major_deprecations supply :removed_message
Generally the removed message is very similar, but often it needs to
specify that the feature has "been removed" instead of "will be
removed", or "been deprecated". And a few chunks of text needed more
substantial updates. And a number of them seemed to have been carefully
crafted to make sense in either context, so I left those alone.

8d42cf9104
2023-12-01 17:52:38 +00:00
David Rodríguez
5bdbe242b3 [rubygems/rubygems] Add a warning in an edge case of using gemspec DSL
If a Gemfile duplicates a development dependency also defined in a local
gemspec with a different requirement, the requirement in the local
gemspec will be silently ignored.

This surprised me.

I think we should either:

* Make sure both requirements are considered, like it happens for
  runtime dependencies (I added a spec to illustrate the current behavior
  here).

* Add a warning that the requirement in the gemspec will be ignored.

I think the former is slightly preferable, but it may cause some
bundle's that previously resolve to no longer resolver.

I went with the latter but the more I think about it, the more this
seems like it should behave like the former.

ad6843972f
2023-11-13 11:06:10 +09:00
David Rodríguez
e6c84d05d0 [rubygems/rubygems] Remove now unnecessary dup
3c1a6a7dfa
2023-11-13 11:06:10 +09:00
David Rodríguez
a4d80eee17 [rubygems/rubygems] Let RuboCop target Ruby 3.0
70243b1d72
2023-11-13 11:06:10 +09:00
David Rodríguez
50482cd1e5 [rubygems/rubygems] Drop support for Ruby 2.6 and Ruby 2.7 in Bundler
93619c97ff
2023-11-13 11:06:10 +09:00
Hiroshi SHIBATA
a43f1d90c2 Merge RubyGems and Bundler master
from 0635c1423d
2023-01-10 15:53:07 +09:00
Hiroshi SHIBATA
b7ad60a794 Merge RubyGems/Bundler master
from 72fd3dd209
2022-12-26 15:09:21 +09:00
Hiroshi SHIBATA
bbe56a6437 Merge RubyGems/Bundler master
from bfb0ae6977
2022-12-12 10:49:43 +09:00
David Rodríguez
8d2bcc88ff [rubygems/rubygems] This sorting seems unnecessary too
823cb1fef9
2022-09-12 22:13:29 +09:00
Takuya Noguchi
631b34ef95 [rubygems/rubygems] Bundler: change error/warning message for multiple global sources
Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>

316564b8fc
2022-07-19 23:51:47 +09:00
Hiroshi SHIBATA
437a5ae9d6 Merge RubyGems and Bundler master 2022-07-13 14:11:55 +09:00
David Rodríguez
12a5fa408b Sync RubyGems & Bundler with upstream repo 2022-06-24 10:52:02 +09:00
David Rodríguez
fd83b8887f [rubygems/rubygems] Skip duplicated dependency warning for gemspec dev deps
Generally this warning is skipped for gemspec development dependencies.
I think because it's common to override them in the Gemfile to change
the source, for example.

But the order of conditions was not correct and the warning was still
being printed in one case.

da9d1d6a3f
2022-06-01 00:14:31 +09:00
Hiroshi SHIBATA
aeea88174d
Merge RubyGems and Bundler HEAD
125415593e
2022-05-20 17:32:19 +09:00
Hiroshi SHIBATA
d6311cb1ca Track RubyGems 3.4.0dev and Bundler 2.4.0dev 2021-12-27 10:45:36 +09:00
Nobuyoshi Nakada
9736cb890b
Check if Kernel#untaint is defined instead of version comparison
Probably `RUBY_VERSION` seems overwritten somewhere in the tests.
2021-12-27 08:56:00 +09:00
David Rodríguez
f0ef9ffed1 [rubygems/rubygems] Cancel deprecation of custom git sources
99cd6e0627
2021-12-08 07:59:34 +09:00
Jean Boussier
715a51a0d6 [rubygems/rubygems] Feature: accept pull request URLs as github source
Very often github source is used to temporarily use a modified gem
while a PR upstream is being reviewed.

So for instance https://github.com/ruby/bigdecimal/pull/211 will look like:

```ruby
gem "bigdecimal", github: "casperisfine/bigdecimal", branch: "git-gem" # https://github.com/ruby/bigdecimal/pull/200
```

It's annoying because you have to fiddle with the branch name, which is copied as `casperisfine:git-gem`, etc etc.

If I could simply use the PR URL like this:

```
gem "bigdecimal", github: "https://github.com/ruby/bigdecimal/pull/211"
```

It would make a very common task for me so much simpler.

517c527751
2021-12-06 20:27:29 +09:00
Tim Sutton
d7c734a27e [rubygems/rubygems] typos in UI messages: fix a couple missing spaces between sentence breaks
5cdda53382
2021-08-31 19:06:14 +09:00
Daniel Niknam
49176e8c8c
[rubygems/rubygems] Refactor Bundler::Dsl#check_rubygems_source_safety to improve readability
`check_rubygems_source_safety` is responsible for:

1. if there are multiple global sources
  - for bundle 3.x raise an error
  - for bundle 2.x print a warning
2. print a warning if there is no explicit global source

The second responsibility was added recently and now the logic could be
extracted to improve readability. Conditions are still live in the `check_rubygems_source_safety` method
since we don't want to call both functions always and that would help us achieve that.

f3d7e946ee
2021-07-27 09:25:57 +09:00
Daniel Niknam
1ef360230e
[rubygems/rubygems] Deprecate Gemfile without an explicit global source
Raise a warning when parsing a Gemfile and it doesn't have a global source. Gemfiles like this, specially now that rubygems sources are are no longer merged into a single source for security, are very confusing because they generate a different lockfile depending on the gems you have locally installed. This is because bundler always use an implicit global source that defaults to locally installed gems.

b7523ad21c
2021-07-27 09:25:57 +09:00
David Rodríguez
227c2deff4
[rubygems/rubygems] Fix development gem unintentionally removed on an edge case
When a development dependency was duplicated inside the gemspec and
Gemfile with the same requirements, we went from printing a warning to
removing the gem altogether.

This change makes it not print a warning, but don't remove the gem
either.

8bb2488131
2021-07-16 15:40:07 +09:00
Hiroshi SHIBATA
896bbb9fad Merge RubyGems/Bundler master from 8459ebd6ad65ce3397233416dc64083ae7572bb9 2021-07-14 10:48:07 +09:00
Hiroshi SHIBATA
c082c6eb7c Sync RubyGems and Bundler with upstream 2021-07-07 15:31:52 +09:00
Hiroshi SHIBATA
ed149dbf46 Merge the master branch of Bundler 2021-04-15 15:36:15 +09:00