From 007078e85fbf0d9d2e6d4d0390d622654e42ee49 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Wed, 13 Jan 2021 01:59:41 +1100 Subject: Fix running with empty PATH --- src/luarocks/cmd.lua | 2 +- src/luarocks/cmd/path.lua | 4 ++-- src/luarocks/core/sysdetect.lua | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index 9077652a..c8bcb552 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua @@ -179,7 +179,7 @@ end local function search_lua_in_path(lua_version, verbose) local path_sep = (package.config:sub(1, 1) == "\\" and ";" or ":") local all_tried = {} - for bindir in os.getenv("PATH"):gmatch("[^"..path_sep.."]+") do + for bindir in (os.getenv("PATH") or ""):gmatch("[^"..path_sep.."]+") do local parentdir = dir.path((bindir:gsub("[\\/][^\\/]+[\\/]?$", ""))) local detected, tried = util.find_lua(parentdir, lua_version) if detected then diff --git a/src/luarocks/cmd/path.lua b/src/luarocks/cmd/path.lua index 0038070b..9d6a8217 100644 --- a/src/luarocks/cmd/path.lua +++ b/src/luarocks/cmd/path.lua @@ -45,8 +45,8 @@ function path_cmd.command(args) return true end - local clean_path = util.cleanup_path(os.getenv("PATH"), path_sep, nil, true) - + local clean_path = util.cleanup_path(os.getenv("PATH") or "", path_sep, nil, true) + if args.append then lr_path = package.path .. ";" .. lr_path lr_cpath = package.cpath .. ";" .. lr_cpath diff --git a/src/luarocks/core/sysdetect.lua b/src/luarocks/core/sysdetect.lua index 81e62076..534ab89f 100644 --- a/src/luarocks/core/sysdetect.lua +++ b/src/luarocks/core/sysdetect.lua @@ -397,7 +397,7 @@ function sysdetect.detect(input_file) -- interpreter path is absolute table.insert(files, interp) else - for d in os.getenv("PATH"):gmatch("[^"..PATHsep.."]+") do + for d in (os.getenv("PATH") or ""):gmatch("[^"..PATHsep.."]+") do table.insert(files, d .. dirsep .. interp) end end -- cgit v1.2.3-55-g6feb