From 3f387e60ef87d61d5503132f02b96bba8caa32bd Mon Sep 17 00:00:00 2001 From: Yuta Saito 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(-) (limited to 'spec/mspec/lib/mspec/utils/script.rb') 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 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.3