Skip to content

Commit 6a1ef8c

Browse files
committed
Fix runfiles resolution in libraries installed by bundle_install
1 parent 086d0b6 commit 6a1ef8c

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

ruby/private/BUILD.host_runtime.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ruby_toolchain(
1212
bundler = "//:bundler",
1313
init_files = ["//:init_loadpath"],
1414
rubyopt = [
15-
"-I../org_ruby_lang_ruby_host/bundler/lib",
15+
"-I$(RUNFILES_DIR)/org_ruby_lang_ruby_host/bundler/lib",
1616
],
1717
runtime = "//:runtime",
1818
rules_ruby_workspace = "{rules_ruby_workspace}",

ruby/private/binary_wrapper.tpl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,16 @@ def main(args)
107107

108108
main = {main}
109109
main = File.join(runfiles, main)
110-
rubyopt = {rubyopt}
110+
rubyopt = {rubyopt}.map do |opt|
111+
opt.gsub(/\${(.+?)}/o) do
112+
case $1
113+
when 'RUNFILES_DIR'
114+
runfiles
115+
else
116+
ENV[$1]
117+
end
118+
end
119+
end
111120
exec(ruby_program, '--disable-gems', *rubyopt, main, *args)
112121
# TODO(yugui) Support windows
113122
end

ruby/private/bundle/create_bundle_build_file.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
exclude = {exclude},
3131
),
3232
deps = [":bundler_setup"],
33-
rubyopt = ["-r../{repo_name}/lib/bundler/setup.rb"],
33+
rubyopt = ["-r${RUNFILES_DIR}/{repo_name}/lib/bundler/setup.rb"],
3434
)
3535
3636
# PULL EACH GEM INDIVIDUALLY
@@ -48,7 +48,7 @@
4848
exclude = {exclude},
4949
),
5050
deps = {deps},
51-
rubyopt = ["-r../{repo_name}/lib/bundler/setup.rb"],
51+
rubyopt = ["-r${RUNFILES_DIR}/{repo_name}/lib/bundler/setup.rb"],
5252
)
5353
5454
'
@@ -57,7 +57,7 @@
5757
ruby_library(
5858
name = "all",
5959
deps = {deps},
60-
rubyopt = ["-r../{repo_name}/lib/bundler/setup.rb"],
60+
rubyopt = ["-r${RUNFILES_DIR}/{repo_name}/lib/bundler/setup.rb"],
6161
)
6262
'
6363
require "bundler"

0 commit comments

Comments
 (0)