Skip to content

Commit 49f199a

Browse files
committed
[GR-20580] Update bundler/bundle to match format expected by rubygems installer.
PullRequest: truffleruby/1264
2 parents 3ea67e4 + 9c4dd5e commit 49f199a

File tree

8 files changed

+121
-120
lines changed

8 files changed

+121
-120
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ Bug fixes:
7070
* Fixed `ENV.udpate` implementation.
7171
* Fixed argument handling in `Kernel.printf`.
7272
* Fixed character length after conversion to binary from a non-US-ASCII String.
73+
* Fixed issue with installing latest bundler (#1880).
7374

7475
Compatibility:
7576

bin/bundle

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env bash
2-
# ignored by Ruby interpreter
2+
#
3+
# This file was generated by RubyGems.
4+
# The above lines match the format expected by rubygems/installer.rb check_executable_overwrite
5+
# bash section ignored by the Ruby interpreter
36

47
# get the absolute path of the executable and resolve symlinks
58
SELF_PATH=$(cd "$(dirname "$0")" && pwd -P)/$(basename "$0")
@@ -16,34 +19,29 @@ exec "$(dirname $SELF_PATH)/ruby" "$SELF_PATH" "$@"
1619

1720
#!ruby
1821
# ^ marks start of Ruby interpretation
19-
20-
# from libexec/bundler (not libexec/bundle)
21-
22-
# Exit cleanly from an early interrupt
23-
Signal.trap("INT") do
24-
Bundler.ui.debug("\n#{caller.join("\n")}") if defined?(Bundler)
25-
exit 1
26-
end
27-
28-
require "bundler"
29-
# Check if an older version of bundler is installed
30-
$LOAD_PATH.each do |path|
31-
next unless path =~ %r{/bundler-0\.(\d+)} && $1.to_i < 9
32-
err = String.new
33-
err << "Looks like you have a version of bundler that's older than 0.9.\n"
34-
err << "Please remove your old versions.\n"
35-
err << "An easy way to do this is by running `gem cleanup bundler`."
36-
abort(err)
22+
#
23+
# This file was generated by RubyGems.
24+
#
25+
# The application 'bundler' is installed as part of a gem, and
26+
# this file is here to facilitate running it.
27+
#
28+
29+
require 'rubygems'
30+
31+
version = ">= 0.a"
32+
33+
str = ARGV.first
34+
if str
35+
str = str.b[/\A_(.*)_\z/, 1]
36+
if str and Gem::Version.correct?(str)
37+
version = str
38+
ARGV.shift
39+
end
3740
end
3841

39-
require "bundler/friendly_errors"
40-
Bundler.with_friendly_errors do
41-
require "bundler/cli"
42-
43-
# Allow any command to use --help flag to show help for that command
44-
help_flags = %w[--help -h]
45-
help_flag_used = ARGV.any? {|a| help_flags.include? a }
46-
args = help_flag_used ? Bundler::CLI.reformatted_help_args(ARGV) : ARGV
47-
48-
Bundler::CLI.start(args, :debug => true)
42+
if Gem.respond_to?(:activate_bin_path)
43+
load Gem.activate_bin_path('bundler', 'bundle', version)
44+
else
45+
gem "bundler", version
46+
load Gem.bin_path("bundler", "bundle", version)
4947
end

bin/bundler

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env bash
2-
# ignored by Ruby interpreter
2+
#
3+
# This file was generated by RubyGems.
4+
# The above lines match the format expected by rubygems/installer.rb check_executable_overwrite
5+
# bash section ignored by the Ruby interpreter
36

47
# get the absolute path of the executable and resolve symlinks
58
SELF_PATH=$(cd "$(dirname "$0")" && pwd -P)/$(basename "$0")
@@ -16,34 +19,29 @@ exec "$(dirname $SELF_PATH)/ruby" "$SELF_PATH" "$@"
1619

1720
#!ruby
1821
# ^ marks start of Ruby interpretation
19-
20-
# from libexec/bundler
21-
22-
# Exit cleanly from an early interrupt
23-
Signal.trap("INT") do
24-
Bundler.ui.debug("\n#{caller.join("\n")}") if defined?(Bundler)
25-
exit 1
26-
end
27-
28-
require "bundler"
29-
# Check if an older version of bundler is installed
30-
$LOAD_PATH.each do |path|
31-
next unless path =~ %r{/bundler-0\.(\d+)} && $1.to_i < 9
32-
err = String.new
33-
err << "Looks like you have a version of bundler that's older than 0.9.\n"
34-
err << "Please remove your old versions.\n"
35-
err << "An easy way to do this is by running `gem cleanup bundler`."
36-
abort(err)
22+
#
23+
# This file was generated by RubyGems.
24+
#
25+
# The application 'bundler' is installed as part of a gem, and
26+
# this file is here to facilitate running it.
27+
#
28+
29+
require 'rubygems'
30+
31+
version = ">= 0.a"
32+
33+
str = ARGV.first
34+
if str
35+
str = str.b[/\A_(.*)_\z/, 1]
36+
if str and Gem::Version.correct?(str)
37+
version = str
38+
ARGV.shift
39+
end
3740
end
3841

39-
require "bundler/friendly_errors"
40-
Bundler.with_friendly_errors do
41-
require "bundler/cli"
42-
43-
# Allow any command to use --help flag to show help for that command
44-
help_flags = %w[--help -h]
45-
help_flag_used = ARGV.any? {|a| help_flags.include? a }
46-
args = help_flag_used ? Bundler::CLI.reformatted_help_args(ARGV) : ARGV
47-
48-
Bundler::CLI.start(args, :debug => true)
42+
if Gem.respond_to?(:activate_bin_path)
43+
load Gem.activate_bin_path('bundler', 'bundler', version)
44+
else
45+
gem "bundler", version
46+
load Gem.bin_path("bundler", "bundler", version)
4947
end

bin/irb

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env bash
2-
# ignored by Ruby interpreter
2+
#
3+
# This file was generated by RubyGems.
4+
# The above lines match the format expected by rubygems/installer.rb check_executable_overwrite
5+
# bash section ignored by the Ruby interpreter
36

47
# get the absolute path of the executable and resolve symlinks
58
SELF_PATH=$(cd "$(dirname "$0")" && pwd -P)/$(basename "$0")
@@ -17,15 +20,22 @@ exec "$(dirname $SELF_PATH)/ruby" "$SELF_PATH" "$@"
1720
#!ruby
1821
# ^ marks start of Ruby interpretation
1922

20-
# from libexec/irb
23+
require 'rubygems'
2124

22-
#
23-
# irb.rb - interactive ruby
24-
# $Release Version: 0.9.6 $
25-
# $Revision$
26-
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
27-
#
25+
version = ">= 0.a"
2826

29-
require "irb"
27+
str = ARGV.first
28+
if str
29+
str = str.b[/\A_(.*)_\z/, 1]
30+
if str and Gem::Version.correct?(str)
31+
version = str
32+
ARGV.shift
33+
end
34+
end
3035

31-
IRB.start(__FILE__)
36+
if Gem.respond_to?(:activate_bin_path)
37+
load Gem.activate_bin_path('irb', 'irb', version)
38+
else
39+
gem "irb", version
40+
load Gem.bin_path("irb", "irb", version)
41+
end

bin/rake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env bash
2-
# ignored by Ruby interpreter
2+
#
3+
# This file was generated by RubyGems.
4+
# The above lines match the format expected by rubygems/installer.rb check_executable_overwrite
5+
# bash section ignored by the Ruby interpreter
36

47
# get the absolute path of the executable and resolve symlinks
58
SELF_PATH=$(cd "$(dirname "$0")" && pwd -P)/$(basename "$0")

bin/rdoc

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env bash
2-
# ignored by Ruby interpreter
2+
#
3+
# This file was generated by RubyGems.
4+
# The above lines match the format expected by rubygems/installer.rb check_executable_overwrite
5+
# bash section ignored by the Ruby interpreter
36

47
# get the absolute path of the executable and resolve symlinks
58
SELF_PATH=$(cd "$(dirname "$0")" && pwd -P)/$(basename "$0")
@@ -17,48 +20,22 @@ exec "$(dirname $SELF_PATH)/ruby" "$SELF_PATH" "$@"
1720
#!ruby
1821
# ^ marks start of Ruby interpretation
1922

20-
# from libexec/rdoc
21-
22-
#
23-
# RDoc: Documentation tool for source code
24-
# (see lib/rdoc/rdoc.rb for more information)
25-
#
26-
# Copyright (c) 2003 Dave Thomas
27-
# Released under the same terms as Ruby
28-
29-
begin
30-
gem 'rdoc'
31-
rescue NameError => e # --disable-gems
32-
raise unless e.name == :gem
33-
rescue Gem::LoadError
34-
end
23+
require 'rubygems'
3524

36-
require 'rdoc/rdoc'
25+
version = ">= 0.a"
3726

38-
begin
39-
r = RDoc::RDoc.new
40-
r.document ARGV
41-
rescue Errno::ENOSPC
42-
$stderr.puts 'Ran out of space creating documentation'
43-
$stderr.puts
44-
$stderr.puts 'Please free up some space and try again'
45-
rescue SystemExit
46-
raise
47-
rescue Exception => e
48-
if $DEBUG_RDOC then
49-
$stderr.puts e.message
50-
$stderr.puts "#{e.backtrace.join "\n\t"}"
51-
$stderr.puts
52-
elsif Interrupt === e then
53-
$stderr.puts
54-
$stderr.puts 'Interrupted'
55-
else
56-
$stderr.puts "uh-oh! RDoc had a problem:"
57-
$stderr.puts e.message
58-
$stderr.puts
59-
$stderr.puts "run with --debug for full backtrace"
27+
str = ARGV.first
28+
if str
29+
str = str.b[/\A_(.*)_\z/, 1]
30+
if str and Gem::Version.correct?(str)
31+
version = str
32+
ARGV.shift
6033
end
61-
62-
exit 1
6334
end
6435

36+
if Gem.respond_to?(:activate_bin_path)
37+
load Gem.activate_bin_path('rdoc', 'rdoc', version)
38+
else
39+
gem "rdoc", version
40+
load Gem.bin_path("rdoc", "rdoc", version)
41+
end

bin/ri

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#!/usr/bin/env bash
22
# ignored by Ruby interpreter
3+
#
4+
# This file was generated by RubyGems.
5+
# The above lines match the format expected by rubygems/installer.rb check_executable_overwrite
6+
# bash section ignored by the Ruby interpreter
37

48
# get the absolute path of the executable and resolve symlinks
59
SELF_PATH=$(cd "$(dirname "$0")" && pwd -P)/$(basename "$0")
@@ -17,15 +21,22 @@ exec "$(dirname $SELF_PATH)/ruby" "$SELF_PATH" "$@"
1721
#!ruby
1822
# ^ marks start of Ruby interpretation
1923

20-
# from libexec/ri
24+
require 'rubygems'
2125

22-
begin
23-
gem 'rdoc'
24-
rescue NameError => e # --disable-gems
25-
raise unless e.name == :gem
26-
rescue Gem::LoadError
27-
end
26+
version = ">= 0.a"
2827

29-
require 'rdoc/ri/driver'
28+
str = ARGV.first
29+
if str
30+
str = str.b[/\A_(.*)_\z/, 1]
31+
if str and Gem::Version.correct?(str)
32+
version = str
33+
ARGV.shift
34+
end
35+
end
3036

31-
RDoc::RI::Driver.run ARGV
37+
if Gem.respond_to?(:activate_bin_path)
38+
load Gem.activate_bin_path('rdoc', 'ri', version)
39+
else
40+
gem "rdoc", version
41+
load Gem.bin_path("rdoc", "ri", version)
42+
end

doc/contributor/updating-ruby.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,10 @@ shebang has a format as follows:
100100

101101
```bash
102102
#!/usr/bin/env bash
103-
# ignored by Ruby interpreter
103+
#
104+
# This file was generated by RubyGems.
105+
# The above lines match the format expected by rubygems/installer.rb check_executable_overwrite
106+
# bash section ignored by the Ruby interpreter
104107

105108
# get the absolute path of the executable and resolve symlinks
106109
SELF_PATH=$(cd "$(dirname "$0")" && pwd -P)/$(basename "$0")

0 commit comments

Comments
 (0)