Skip to content

Commit 00c2b82

Browse files
committed
[GR-47035] [GR-46289] Remove RbConfig::CONFIG['extra_bindirs'] and Gem::ExtraExecutablesInstaller
PullRequest: truffleruby/3935
2 parents cd498f7 + 2298323 commit 00c2b82

File tree

7 files changed

+44
-117
lines changed

7 files changed

+44
-117
lines changed

lib/cext/ABI_check.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6
1+
7

lib/patches/rubygems.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77

88
require Primitive.get_original_require(__FILE__)
99

10-
# Add TruffleRuby rubygems hooks to install and uninstall executables from additional
11-
# GraalVM bin directories (./bin, ./jre/bin on JDK8)
12-
unless RbConfig::CONFIG['extra_bindirs'].empty?
13-
require 'rubygems/extra_executables_installer'
14-
Gem::ExtraExecutablesInstaller.install_hooks_for RbConfig::CONFIG['extra_bindirs'].split(File::PATH_SEPARATOR)
15-
end
16-
1710
# Make sure we don't use foreign gem directories
1811
unless Truffle::Boot.get_option 'testing-rubygems'
1912
require 'rubygems/gem_dirs_verification'

lib/truffle/rbconfig.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ module RbConfig
5959
rmdir = Truffle::Platform.linux? ? 'rmdir --ignore-fail-on-non-empty' : 'rmdir'
6060

6161
prefix = ruby_home
62-
graalvm_home = TruffleRuby.graalvm_home
63-
extra_bindirs = graalvm_home ? ["#{graalvm_home}/bin"] : []
6462
rubyhdrdir = "#{prefix}/lib/cext/include"
6563

6664
ar = Truffle::Boot.toolchain_executable(:AR)
@@ -149,7 +147,6 @@ module RbConfig
149147
'exeext' => '',
150148
'EXEEXT' => '',
151149
'EXTOUT' => '.ext',
152-
'extra_bindirs' => extra_bindirs.join(File::PATH_SEPARATOR),
153150
'host_alias' => '',
154151
'host_cpu' => host_cpu,
155152
'host' => host,

lib/truffle/rubygems/extra_executables_installer.rb

Lines changed: 0 additions & 49 deletions
This file was deleted.

spec/tags/truffle/launcher_tags.txt

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,6 @@ slow:The launcher runs irb as an -S command
3535
slow:The launcher runs rake as an -S command
3636
slow:The launcher runs rdoc as an -S command
3737
slow:The launcher runs ri as an -S command
38-
slow:The launcher supports running bundle in any of the bin/ directories
39-
slow:The launcher supports running bundler in any of the bin/ directories
40-
slow:The launcher supports running gem in any of the bin/ directories
41-
slow:The launcher supports running irb in any of the bin/ directories
42-
slow:The launcher supports running rake in any of the bin/ directories
43-
slow:The launcher supports running rdoc in any of the bin/ directories
44-
slow:The launcher supports running ri in any of the bin/ directories
45-
slow:The launcher supports running ruby in any of the bin/ directories
46-
slow:The launcher supports running truffleruby in any of the bin/ directories
4738
slow:The launcher for gem can install and uninstall the hello-world gem
4839
slow:The launcher for gem shows that bundled gems are installed
4940
slow:The launcher '--vm.cp=' or '--vm.classpath=' add the jar
@@ -68,19 +59,26 @@ slow:The launcher runs erb as an -S command
6859
slow:The launcher runs racc as an -S command
6960
slow:The launcher runs racc2y as an -S command
7061
slow:The launcher runs y2racc as an -S command
71-
slow:The launcher supports running erb in any of the bin/ directories
72-
slow:The launcher supports running racc in any of the bin/ directories
73-
slow:The launcher supports running racc2y in any of the bin/ directories
74-
slow:The launcher supports running y2racc in any of the bin/ directories
7562
slow:The launcher supports running erb symlinked
7663
slow:The launcher supports running racc symlinked
7764
slow:The launcher supports running racc2y symlinked
7865
slow:The launcher supports running y2racc symlinked
7966
slow:The launcher warns if the locale is not set properly
8067
slow:The launcher runs rbs as an -S command
81-
slow:The launcher supports running rbs in any of the bin/ directories
8268
slow:The launcher supports running rbs symlinked
8369
slow:The launcher prints help:ruby containing ruby language options
8470
slow:The launcher runs rdbg as an -S command
85-
slow:The launcher supports running rdbg in any of the bin/ directories
8671
slow:The launcher supports running rdbg symlinked
72+
slow:The launcher supports running bundle in bin/
73+
slow:The launcher supports running bundler in bin/
74+
slow:The launcher supports running erb in bin/
75+
slow:The launcher supports running gem in bin/
76+
slow:The launcher supports running irb in bin/
77+
slow:The launcher supports running racc in bin/
78+
slow:The launcher supports running rake in bin/
79+
slow:The launcher supports running rbs in bin/
80+
slow:The launcher supports running rdbg in bin/
81+
slow:The launcher supports running rdoc in bin/
82+
slow:The launcher supports running ri in bin/
83+
slow:The launcher supports running ruby in bin/
84+
slow:The launcher supports running truffleruby in bin/

spec/truffle/launcher_spec.rb

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@
3434
}
3535

3636
before :all do
37-
@default_bindir = RbConfig::CONFIG['bindir']
38-
@bin_dirs = [RbConfig::CONFIG['bindir']]
39-
@bin_dirs += RbConfig::CONFIG['extra_bindirs'].to_s.split(File::PATH_SEPARATOR) if defined?(::TruffleRuby)
37+
@bindir = RbConfig::CONFIG['bindir']
4038
end
4139

4240
before :each do
@@ -76,7 +74,7 @@ def check_status_or_print(stdout_and_stderr)
7674
end
7775

7876
it "is in the bindir" do
79-
File.dirname(RbConfig.ruby).should == @default_bindir
77+
File.dirname(RbConfig.ruby).should == @bindir
8078
end
8179

8280
it "all launchers are in @launchers" do
@@ -98,30 +96,26 @@ def check_status_or_print(stdout_and_stderr)
9896
end
9997

10098
@launchers.each do |launcher, test|
101-
it "supports running #{launcher} in any of the bin/ directories" do
99+
it "supports running #{launcher} in bin/" do
102100
redirect = launcher == :erb ? (touch @stderr; '2>&1') : @redirect
103-
@bin_dirs.each do |bin_dir|
104-
out = `#{bin_dir}/#{launcher} --version #{redirect}`
105-
check_status_and_empty_stderr
106-
out.should =~ test
107-
end
101+
out = `#{@bindir}/#{launcher} --version #{redirect}`
102+
check_status_and_empty_stderr
103+
out.should =~ test
108104
end
109105
end
110106

111107
@launchers.each do |launcher, test|
112108
it "supports running #{launcher} symlinked" do
113109
redirect = launcher == :erb ? (touch @stderr; '2>&1') : @redirect
114110
require 'tmpdir'
115-
@bin_dirs.each do |bin_dir|
116-
# Use the system tmp dir to not be under the Ruby home dir
117-
Dir.mktmpdir do |path|
118-
Dir.chdir(path) do
119-
linkname = "linkto#{launcher}"
120-
File.symlink("#{bin_dir}/#{launcher}", linkname)
121-
out = `./#{linkname} --version #{redirect}`
122-
check_status_and_empty_stderr
123-
out.should =~ test
124-
end
111+
# Use the system tmp dir to not be under the Ruby home dir
112+
Dir.mktmpdir do |path|
113+
Dir.chdir(path) do
114+
linkname = "linkto#{launcher}"
115+
File.symlink("#{@bindir}/#{launcher}", linkname)
116+
out = `./#{linkname} --version #{redirect}`
117+
check_status_and_empty_stderr
118+
out.should =~ test
125119
end
126120
end
127121
end
@@ -130,35 +124,31 @@ def check_status_or_print(stdout_and_stderr)
130124
it "for gem can install and uninstall the hello-world gem" do
131125
# install
132126
Dir.chdir(__dir__ + '/fixtures/hello-world') do
133-
`"#{@default_bindir}/gem" build hello-world.gemspec #{@redirect}`
127+
`"#{@bindir}/gem" build hello-world.gemspec #{@redirect}`
134128
check_status_and_empty_stderr
135-
`"#{@default_bindir}/gem" install --local hello-world-0.0.1.gem #{@redirect}`
129+
`"#{@bindir}/gem" install --local hello-world-0.0.1.gem #{@redirect}`
136130
check_status_and_empty_stderr
137131
end
138132

139133
begin
140-
# check that hello-world launchers are created and work
141-
@bin_dirs.each do |bin_dir|
142-
path = "#{bin_dir}/hello-world.rb"
143-
shebang = File.binread(path).lines.first.chomp
144-
if shebang.size > 127
145-
skip "shebang of #{path} is too long and might fail in execve(): #{shebang.size}\n#{shebang}"
146-
end
147-
out = `#{path} 2>&1`
148-
out.should == "Hello world! from #{RUBY_DESCRIPTION}\n"
134+
# check that hello-world launcher is created and works
135+
path = "#{@bindir}/hello-world.rb"
136+
shebang = File.binread(path).lines.first.chomp
137+
if shebang.size > 127
138+
skip "shebang of #{path} is too long and might fail in execve(): #{shebang.size}\n#{shebang}"
149139
end
140+
out = `#{path} 2>&1`
141+
out.should == "Hello world! from #{RUBY_DESCRIPTION}\n"
150142
ensure
151143
# uninstall
152-
`#{@default_bindir}/gem uninstall hello-world -x #{@redirect}`
144+
`#{@bindir}/gem uninstall hello-world -x #{@redirect}`
153145
check_status_and_empty_stderr
154-
@bin_dirs.each do |bin_dir|
155-
File.exist?(bin_dir + '/hello-world.rb').should == false
156-
end
146+
File.should_not.exist?(@bindir + '/hello-world.rb')
157147
end
158148
end
159149

160150
it "for gem shows that bundled gems are installed" do
161-
gem_list = `#{@default_bindir}/gem list #{@redirect}`
151+
gem_list = `#{@bindir}/gem list #{@redirect}`
162152
check_status_and_empty_stderr
163153
# see doc/contributor/stdlib.md
164154
@bundled_gems.each_pair do |gem, version|
@@ -342,8 +332,8 @@ def should_print_full_java_command(options, env: {})
342332
out.should include("--jvm")
343333
end
344334

345-
if TruffleRuby.graalvm_home
346-
# These options are only shown in GraalVM, as they are not available in a standalone distribution
335+
if TruffleRuby.graalvm_home or !TruffleRuby.native?
336+
# These options are only shown in GraalVM, they are not available in a native standalone
347337
out.should include("--polyglot")
348338
end
349339
end
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
require 'fileutils'
2+
require 'rbconfig'
23

34
repo = ARGV.fetch(0)
45
src = "#{repo}/exe/rake"
56
raise src unless File.exist? src
67

7-
bin_dirs = [RbConfig::CONFIG['bindir'], *RbConfig::CONFIG['extra_bindirs'].split(File::PATH_SEPARATOR)]
8-
bin_dirs.each do |dir|
9-
FileUtils::Verbose.cp(src, "#{dir}/rake")
10-
end
8+
FileUtils::Verbose.cp(src, "#{RbConfig::CONFIG['bindir']}/rake")

0 commit comments

Comments
 (0)