Old versions of BUndler need a workaround to support nested `bundle
exec` invocations by overriding `Gem.activate_bin_path`. However,
RubyGems now uses this new `Gem.activate_and_load_bin_path` helper in
binstubs, which is of course not overridden in those Bundler versions
since it didn't exist at the time.
So, include the override here to workaround that.
e5ed95e242
Next version for both will be 4.0.0, however, extra work is necessary to
get CI passing against the new major. So for now, I'm bumping just the
minor version.
We were only avoiding them when the RUBYGEMS_GEMDEPS variable is used.
Avoid the warnings in general, whenever the entrypoint to Bundler is
`require`.
8683faef36
### Before
```
$ GEM_HOME=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/ bundle
Fetching gem metadata from https://rubygems.org/.
Source rubygems repository https://rubygems.org/ or installed locally is ignoring #<Bundler::StubSpecification name=sqlite3 version=1.3.13 platform=ruby> because it is missing extensions
Source rubygems repository https://rubygems.org/ or installed locally is ignoring #<Bundler::StubSpecification name=nokogiri version=1.13.8 platform=ruby> because it is missing extensions
Source rubygems repository https://rubygems.org/ or installed locally is ignoring #<Bundler::StubSpecification name=libxml-ruby version=3.2.1 platform=ruby> because it is missing extensions
Resolving dependencies...
Fetching ruby2_keywords 0.0.5
Retrying download gem from https://rubygems.org/ due to error (2/4): Bundler::GenericSystemCallError There was an error accessing `/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/cache/ruby2_keywords-0.0.5.gem`.
The underlying system error is Errno::EPERM: Operation not permitted @ rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/cache/ruby2_keywords-0.0.5.gem
Retrying download gem from https://rubygems.org/ due to error (3/4): Bundler::GenericSystemCallError There was an error accessing `/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/cache/ruby2_keywords-0.0.5.gem`.
The underlying system error is Errno::EPERM: Operation not permitted @ rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/cache/ruby2_keywords-0.0.5.gem
Retrying download gem from https://rubygems.org/ due to error (4/4): Bundler::GenericSystemCallError There was an error accessing `/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/cache/ruby2_keywords-0.0.5.gem`.
The underlying system error is Errno::EPERM: Operation not permitted @ rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/cache/ruby2_keywords-0.0.5.gem
Bundler::GenericSystemCallError: There was an error accessing `/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/cache/ruby2_keywords-0.0.5.gem`.
The underlying system error is Errno::EPERM: Operation not permitted @ rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/cache/ruby2_keywords-0.0.5.gem
/Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/shared_helpers.rb:119:in `rescue in filesystem_access'
/Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/shared_helpers.rb:104:in `filesystem_access'
/Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/rubygems_integration.rb:431:in `block in download_gem'
/Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/retry.rb:40:in `run'
/Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/retry.rb:30:in `attempt'
/Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/rubygems_integration.rb:423:in `download_gem'
/Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/source/rubygems.rb:479:in `download_gem'
/Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/source/rubygems.rb:436:in `fetch_gem'
/Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/source/rubygems.rb:420:in `fetch_gem_if_possible'
/Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/source/rubygems.rb:162:in `install'
/Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/installer/gem_installer.rb:55:in `install'
/Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/installer/gem_installer.rb:17:in `install_from_spec'
/Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/installer/parallel_installer.rb:133:in `do_install'
/Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/installer/parallel_installer.rb:124:in `block in worker_pool'
/Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/worker.rb:62:in `apply_func'
/Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/worker.rb:57:in `block in process_queue'
<internal:kernel>:187:in `loop'
/Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/worker.rb:54:in `process_queue'
/Users/deivid/code/rubygems/rubygems/bundler/lib/bundler/worker.rb:90:in `block (2 levels) in create_threads'
An error occurred while installing ruby2_keywords (0.0.5), and Bundler cannot continue.
In Gemfile:
ruby2_keywords
```
### After
```
$ GEM_HOME=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/ bundle
There was an error creating `/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/bundler.lock`.
The underlying system error is Errno::EPERM: Operation not permitted @ rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0/bundler.lock
```
345ec45f5a
Since `Gem.open_file` no longer locks the target file and is same as
`File.open` now, simply `Gem.read_binary` should read in binary mode.
Also the body of `Gem.write_binary` is same as `File.binwrite`.
44df9045df
There's an issue when multiple processes try to write the same binstub.
The problem is that our file locking mechanism is incorrect because
files are truncated _before_ they are locked. So it can happen that:
* Process A truncates binstub FOO.
* Process B truncates binstub FOO.
* Process A writes binstub FOO for gem BAR from the beginning of file.
* Process B writes binstub FOO for gem BAZ from the beginning of file.
If binstub FOO for gem BAR is bigger than binstub FOO for gem BAZ, then
some bytes will be left around at the end of the binstub, making it
corrupt.
This was not a problem in our specs until the spec testing binstubs with
the same name coming from different gems changed from using gems named
"fake" and "rack" to using gems named "fake" and "myrack". Because of
the difference in gem name length, the generated binstub for gem
"myrack" is now longer, causing the above problem if binstub for gem
myrack is written first.
The solution is to make sure when using flock to always use modes that
DON'T truncate the file when opening it. So, we use `r+` if the file
exists previously (it requires the file to exist previously), otherwise
we use `a+`.
ce8bcba90f
This patch adds `--target-rbconfig` option to specify the rbconfig.rb file
for the deployment target platform. This is useful when cross-compiling
gems. At the moment, this option is only available for `extconf.rb`-based
extensions.
cf2843f7a2
If a gem is required circular, and there are unresolved specs depending
on it, we may end up in an activation conflict.
The solution is to not try to activate unresolved gems when requiring a
default gem, regardless of it having already been activated or not.
3b2b8f4e3e
This is based on the list in Gem::UpdateSuggestion and Bundler::Fetcher;
these have similar purposes (determining whether/what CI we're executing
in), and can benefit from being combined and updated (they're both
slightly out of date).
Noteable changes:
* We'll consider ourselves to be on a CI in more cases - if CI_NAME or
TASKCLUSTER_ROOT_URL are set specifically, since those represent two
cases that were either overlooked or are no longer covered by the
existing implementation. (Or possibly TaskCluster still does provide
RUN_ID, but failed to document it)
* We will notice/track a few additional services in ci_strings (cirrus,
dsari, taskcluster), stop tracking 'snap' (they went under in 2017),
and update buildbox to buildkite (they've been called that for 8
years, and the BUILDBOX envs have been deprecated for 3).
* We'll also sort/uniq/downcase the values (all of which only matter
because of the special case of CI_NAME).
60652b942f