From 44f9fa1b611b63a52331a87e3e8b407fc8bb01f5 Mon Sep 17 00:00:00 2001 From: dearblue Date: Sat, 6 May 2023 21:54:49 +0900 Subject: [PATCH] Correct the `MRuby::Build#define_installer` This is a complement to #5928. The previous PR had the following problem: - The `/bin/*` file could not be replaced if the destination of the symbolic link was lost. - The wrong link destination was written if `MRuby::Build.install_dir` was a relative path. --- lib/mruby/build.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/mruby/build.rb b/lib/mruby/build.rb index 4a69d1b7a..18ba6c349 100644 --- a/lib/mruby/build.rb +++ b/lib/mruby/build.rb @@ -388,7 +388,7 @@ EOS define_installer_outline(src, dst) do File.write dst, <<~BATCHFILE @echo off - call "#{src}" %* + call "#{File.expand_path(src)}" %* BATCHFILE end end @@ -396,8 +396,8 @@ EOS def define_installer(src) dst = "#{self.class.install_dir}/#{File.basename(src)}" define_installer_outline(src, dst) do - File.unlink(dst) if File.exist?(dst) - File.symlink(src, dst) + File.unlink(dst) rescue nil + File.symlink(File.expand_path(src), dst) end end end