Commit graph

22 commits

Author SHA1 Message Date
Daniel Colson
accda74cbe [rubygems/rubygems] Prevent gem activation in standalone mode
As discussed in https://github.com/rubygems/rubygems/issues/6273#issuecomment-1449176658

The `gem` method behaves awkwardly in standalone mode. Assuming bundler
isn't loaded at all, a call to gem might activate a gem that is not part
of the bundle (because it's the gem method defined in
lib/rubygems/core_ext/kernel_gem.rb and not
lib/bundler/rubygems_integration.rb). And when running with
`--disable-gems`, the gem method won't be defined at all so we'll get a
NoMethodError.

Calls to `gem` can appear in dependencies outside an application's
control. To work around this at GitHub we defined our own `Kernel#gem`
that no-ops.

I agree with https://github.com/rubygems/rubygems/issues/6273#issuecomment-1440755882

> people using standalone mode don't want to activate gems like Kernel.gem

This commit redefines `Kernel#gem` in the standalone script to no-op.

bea17b55f1
2023-10-03 17:16:19 +00:00
Ry Biesemeyer
bece880874 [rubygems/rubygems] Centralize logic using Pathname#relative_path_from
To avoid potential crashes when trying to jump from a drive to another
on Windows, and take the change refactor things a bit.

7c9a9a431a
2023-09-27 05:20:58 +00:00
David Rodriguez
0e808183ee [rubygems/rubygems] Allow standalone mode to work on a Windows edge case
If a gem is located in a different drive than the Gemfile, standalone
mode will fail to generate the `bundler/setup` script, failing with an
error like

```
ArgumentError: different prefix: "C:/" and "D:/a/rubygems/rubygems/bundler/tmp/2/bundled_app/bundle/bundler"
  C:/hostedtoolcache/windows/Ruby/3.0.5/x64/lib/ruby/3.0.0/pathname.rb:528:in `relative_path_from'
  D:/a/rubygems/rubygems/bundler/tmp/2/gems/system/gems/bundler-2.4.20/lib/bundler/installer/standalone.rb:58:in `gem_path'
  D:/a/rubygems/rubygems/bundler/tmp/2/gems/system/gems/bundler-2.4.20/lib/bundler/installer/standalone.rb:33:in `block (2 levels) in paths'
  D:/a/rubygems/rubygems/bundler/tmp/2/gems/system/gems/bundler-2.4.20/lib/bundler/installer/standalone.rb:32:in `map'
  D:/a/rubygems/rubygems/bundler/tmp/2/gems/system/gems/bundler-2.4.20/lib/bundler/installer/standalone.rb:32:in `block in paths'
```

I'm fixing this by falling back to using a full path in this case.

This was caught by a failing spec, so I'm not adding new specs.

3cb9b9ab7a
2023-09-25 07:13:21 +00:00
Hiroshi SHIBATA
de91ce980a [rubygems/rubygems] Use Kernel.singleton_class
9be984f281
2023-08-01 00:31:22 +00:00
Hiroshi SHIBATA
38fa8eb4cb Merge rubygems/bundler master
Pick from e9304aed7e
2023-02-21 19:28:12 +09:00
David Rodríguez
030050cdfa [rubygems/rubygems] Make --standalone play nice with --local
I'm not sure if using relative paths in the generated script is best for
this case, since it makes the script not movable, but that can be
improved later.

7f5bdbb842
2022-07-30 04:24:25 +09:00
David Rodríguez
6f229da2c0 [rubygems/rubygems] Fix standalone script generation for statically linked dev ruby
4d0d7b3c97
2022-06-23 18:17:37 +09:00
citrusmoose
8d689294d0 [rubygems/rubygems] Fix extension paths in generated standalone script
The paths for extensions of gems would contain the hardcoded ruby
version on which the extension was built. This will replace it with
runtime ruby version like the parent version directory. It will make the
standalone script compatible between different ruby version installations.

a9dae93d5d
2022-06-20 16:04:47 +09:00
David Rodríguez
f1c0729128 [rubygems/rubygems] Fix standalone generated script to deal with path sources
In the case of path sources, the path the source is pointing to should
be added directly to the `$LOAD_PATH` without any modifications.

d3bba936f0

Co-authored-by: Daniel Niknam <mhmd.niknam@gmail.com>
2021-08-31 19:06:14 +09:00
David Rodríguez
7465b94f8a [rubygems/rubygems] Remove unnecessary ruby_version local variable
Under some case, this variable might not end up being used, in which
case running the script would print unused variable warnings.

bf96030362
2021-08-31 19:06:14 +09:00
David Rodríguez
7566c85cc0 [rubygems/rubygems] Use same criteria for ruby engine as in the final script
fcb8c3d188
2021-08-31 19:06:14 +09:00
David Rodríguez
3aa087d533 [rubygems/rubygems] Remove unnecessary ruby_engine local variable
Under some case, this variable might not end up being used, in which
case running the script would print unused variable warnings.

a2d6392ada
2021-08-31 19:06:14 +09:00
David Rodríguez
1d6551a02d [rubygems/rubygems] Remove unnecessary path local variable
We can use `__dir__` directly.

0e6083ca94
2021-08-31 19:06:14 +09:00
David Rodríguez
97c0d3fead [rubygems/rubygems] Fix unnecessary $LOAD_PATH modification in standalone script
Due to the `bundler` gem itself being ignored from `$LOAD_PATHS`, a
`nil` value is being introduced here, resulting in the current folder
being added to the `$LOAD_PATH` by the standalone script.

I'm pretty sure this is unintentional.

df54b07b5e
2021-08-31 19:06:14 +09:00
Hiroshi SHIBATA
896bbb9fad Merge RubyGems/Bundler master from 8459ebd6ad65ce3397233416dc64083ae7572bb9 2021-07-14 10:48:07 +09:00
David Rodríguez
53468cc111 Sync latest development version of bundler & rubygems 2021-03-08 13:47:35 +09:00
Hiroshi SHIBATA
d386a58f6f Merge bundler-2.2.0.rc.2 2020-10-15 17:19:02 +09:00
David Rodríguez
7255f55dba
[bundler/bundler] RUBY_ENGINE should always be defined after 1.8.7
d6c9196d18
2019-08-03 09:30:00 +09:00
hsbt
59c8d50653 Added bundler as default gems. Revisit [Feature #12733]
* bin/*, lib/bundler/*, lib/bundler.rb, spec/bundler, man/*:
    Merge from latest stable branch of bundler/bundler repository and
    added workaround patches. I will backport them into upstream.
  * common.mk, defs/gmake.mk: Added `test-bundler` task for test suite
    of bundler.
  * tool/sync_default_gems.rb: Added sync task for bundler.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-02 23:07:56 +00:00
hsbt
7825e8363d Postponing the Bundler merge.
I faced a big issue about Bundler with ruby core.
  I have no time to resolve it issue before 2.5 final release.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61416 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-22 23:08:05 +00:00
hsbt
be7b592912 Update bundled bundler to 1.16.0.
* lib/bundler, spec/bundler: Merge bundler-1.16.0.
  * common.mk: rspec examples of bundler-1.16.0 needs require option.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-01 23:29:38 +00:00
hsbt
8598f8c2dc Merge bundler to standard libraries.
rubygems 2.7.x depends bundler-1.15.x. This is preparation for
  rubygems and bundler migration.

  * lib/bundler.rb, lib/bundler/*: files of bundler-1.15.4
  * spec/bundler/*: rspec examples of bundler-1.15.4. I applied patches.
    * https://github.com/bundler/bundler/pull/6007
    * Exclude not working examples on ruby repository.
    * Fake ruby interpriter instead of installed ruby.
  * Makefile.in: Added test task named `test-bundler`. This task is only
    working macOS/linux yet. I'm going to support Windows environment later.
  * tool/sync_default_gems.rb: Added sync task for bundler.

  [Feature #12733][ruby-core:77172]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-08 08:45:41 +00:00