diff --git a/base/sysinfo.jl b/base/sysinfo.jl index 6cc6b55198a77d..c6620d0c0245d6 100644 --- a/base/sysinfo.jl +++ b/base/sysinfo.jl @@ -401,8 +401,8 @@ function which(program_name::String) end end - # If we couldn't find anything, complain - error("$program_name not found") + # If we couldn't find anything, don't return anything + nothing end which(program_name::AbstractString) = which(String(program_name)) diff --git a/test/spawn.jl b/test/spawn.jl index 5edfe11ab42213..6e0654c53bf98f 100644 --- a/test/spawn.jl +++ b/test/spawn.jl @@ -561,12 +561,12 @@ mktempdir() do dir @test Sys.which(foo_path) == realpath(foo_path) chmod(foo_path, 0o666) - @test_throws ErrorException Sys.which("foo") - @test_throws ErrorException Sys.which(foo_path) + @test Sys.which("foo") === nothing + @test Sys.which(foo_path) === nothing end - # Test that completely missing files also fail - @test_throws ErrorException Sys.which("this_is_not_a_command") + # Test that completely missing files also return nothing + @test Sys.which("this_is_not_a_command") === nothing end end