Skip to content

Commit 9bb8710

Browse files
committed
Search the PATH for CC/AR checks
`File::exist?` does not check the PATH, meaning the checks fail as long as `CC`/`AR` aren’t absolute paths. OTOH, `MakeMakefile#find_executable` does.
1 parent 0779fa9 commit 9bb8710

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ext/prism/extconf.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,22 @@ def make(env, target)
7777
# The C extension uses RbConfig, which contains values from the toolchain that built the running Ruby.
7878
env = RbConfig::CONFIG.slice("SOEXT", "CPPFLAGS", "CFLAGS", "CC", "AR", "ARFLAGS", "MAKEDIRS", "RMALL")
7979

80+
require "mkmf"
81+
8082
# It's possible that the Ruby that is being run wasn't actually compiled on this
8183
# machine, in which case parts of RbConfig might be incorrect. In this case
8284
# we'll need to do some additional checks and potentially fall back to defaults.
83-
if env.key?("CC") && !File.exist?(env["CC"])
85+
if env.key?("CC") && !find_executable(env["CC"])
8486
env.delete("CC")
8587
env.delete("CFLAGS")
8688
env.delete("CPPFLAGS")
8789
end
8890

89-
if env.key?("AR") && !File.exist?(env["AR"])
91+
if env.key?("AR") && !find_executable(env["AR"])
9092
env.delete("AR")
9193
env.delete("ARFLAGS")
9294
end
9395

94-
require "mkmf"
95-
9696
# First, ensure that we can find the header for the prism library.
9797
generate_templates # Templates should be generated before find_header.
9898
unless find_header("prism.h", File.expand_path("../../include", __dir__))

0 commit comments

Comments
 (0)