[前][次][番号順一覧][スレッド一覧]

ruby-changes:73658

From: Yuta <ko1@a...>
Date: Wed, 21 Sep 2022 15:26:45 +0900 (JST)
Subject: [ruby-changes:73658] 3f387e60ef (master): Rescue File.expand_path in MSpecScript#try_load if HOME is unavailable

https://git.ruby-lang.org/ruby.git/commit/?id=3f387e60ef

From 3f387e60ef87d61d5503132f02b96bba8caa32bd Mon Sep 17 00:00:00 2001
From: Yuta Saito <kateinoigakukun@g...>
Date: Thu, 17 Feb 2022 17:31:40 +0000
Subject: Rescue File.expand_path in MSpecScript#try_load if HOME is
 unavailable

mspec tries to load ~/.mspecrc, but some platforms (e.g. WASI) doesn't
have HOME concept, so `~` cannot be expanded and `File.expand_path` can
fail.
---
 spec/mspec/lib/mspec/utils/script.rb | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/spec/mspec/lib/mspec/utils/script.rb b/spec/mspec/lib/mspec/utils/script.rb
index b9f8b17fdc..dd1603c20a 100644
--- a/spec/mspec/lib/mspec/utils/script.rb
+++ b/spec/mspec/lib/mspec/utils/script.rb
@@ -84,7 +84,12 @@ class MSpecScript https://github.com/ruby/ruby/blob/trunk/spec/mspec/lib/mspec/utils/script.rb#L84
 
     names.each do |name|
       config[:path].each do |dir|
-        file = File.expand_path name, dir
+        begin
+          file = File.expand_path name, dir
+        rescue ArgumentError
+          # File.expand_path can issue error e.g. if HOME is not available
+          next
+        end
         if @loaded.include?(file)
           return true
         elsif File.exist? file
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]