diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2024-02-23 20:59:47 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-02-25 23:35:01 -0300 |
commit | b65f5304f224ce7f9edd0faa2bbd152dc8f8ddf2 (patch) | |
tree | ec5430da4a553951bb3571e2f97c6270e681403f | |
parent | 2c4ff5240bf298fec07749f5984de2f08b8736ec (diff) | |
download | luarocks-b65f5304f224ce7f9edd0faa2bbd152dc8f8ddf2.tar.gz luarocks-b65f5304f224ce7f9edd0faa2bbd152dc8f8ddf2.tar.bz2 luarocks-b65f5304f224ce7f9edd0faa2bbd152dc8f8ddf2.zip |
fix: if --lua-* flags are given, don't use the hardcoded paths
Thanks @Frityet for the help with troubleshooting!
Fixes #1611
-rw-r--r-- | src/luarocks/cmd.lua | 11 | ||||
-rw-r--r-- | src/luarocks/core/cfg.lua | 30 |
2 files changed, 26 insertions, 15 deletions
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index 30293d6b..e8f05575 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua | |||
@@ -192,15 +192,8 @@ local function search_lua(lua_version, verbose, search_at) | |||
192 | local path_sep = (package.config:sub(1, 1) == "\\" and ";" or ":") | 192 | local path_sep = (package.config:sub(1, 1) == "\\" and ";" or ":") |
193 | local all_tried = {} | 193 | local all_tried = {} |
194 | for bindir in (os.getenv("PATH") or ""):gmatch("[^"..path_sep.."]+") do | 194 | for bindir in (os.getenv("PATH") or ""):gmatch("[^"..path_sep.."]+") do |
195 | local parentdir = dir.path((bindir:gsub("[\\/][^\\/]+[\\/]?$", ""))) | 195 | local searchdir = (bindir:gsub("[\\/]+bin[\\/]?$", "")) |
196 | local detected, tried = util.find_lua(parentdir, lua_version) | 196 | local detected, tried = util.find_lua(searchdir, lua_version) |
197 | if detected then | ||
198 | return detected | ||
199 | else | ||
200 | table.insert(all_tried, tried) | ||
201 | end | ||
202 | bindir = dir.path(bindir) | ||
203 | detected = util.find_lua(bindir, lua_version) | ||
204 | if detected then | 197 | if detected then |
205 | return detected | 198 | return detected |
206 | else | 199 | else |
diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua index b991f581..90e52150 100644 --- a/src/luarocks/core/cfg.lua +++ b/src/luarocks/core/cfg.lua | |||
@@ -611,19 +611,37 @@ function cfg.init(detected, warning) | |||
611 | 611 | ||
612 | -- Use detected values as defaults, overridable via config files or CLI args | 612 | -- Use detected values as defaults, overridable via config files or CLI args |
613 | 613 | ||
614 | cfg.lua_version = detected.lua_version or hardcoded.LUA_VERSION or _VERSION:sub(5) | 614 | local hardcoded_lua = hardcoded.LUA |
615 | local hardcoded_lua_dir = hardcoded.LUA_DIR | ||
616 | local hardcoded_lua_bindir = hardcoded.LUA_BINDIR | ||
617 | local hardcoded_lua_incdir = hardcoded.LUA_INCDIR | ||
618 | local hardcoded_lua_libdir = hardcoded.LUA_LIBDIR | ||
619 | local hardcoded_lua_version = hardcoded.LUA_VERSION or _VERSION:sub(5) | ||
620 | |||
621 | -- if --lua-version or --lua-dir are passed from the CLI, | ||
622 | -- don't use the hardcoded paths at all | ||
623 | if detected.given_lua_version or detected.given_lua_dir then | ||
624 | hardcoded_lua = nil | ||
625 | hardcoded_lua_dir = nil | ||
626 | hardcoded_lua_bindir = nil | ||
627 | hardcoded_lua_incdir = nil | ||
628 | hardcoded_lua_libdir = nil | ||
629 | hardcoded_lua_version = nil | ||
630 | end | ||
631 | |||
632 | cfg.lua_version = detected.lua_version or hardcoded_lua_version | ||
615 | cfg.project_dir = (not hardcoded.FORCE_CONFIG) and detected.project_dir | 633 | cfg.project_dir = (not hardcoded.FORCE_CONFIG) and detected.project_dir |
616 | 634 | ||
617 | do | 635 | do |
618 | local lua = detected.lua or hardcoded.LUA | 636 | local lua = detected.lua or hardcoded_lua |
619 | local lua_bindir = detected.lua_bindir or hardcoded.LUA_BINDIR | 637 | local lua_dir = detected.lua_dir or hardcoded_lua_dir |
620 | local lua_dir = detected.lua_dir or hardcoded.LUA_DIR | 638 | local lua_bindir = detected.lua_bindir or hardcoded_lua_bindir |
621 | cfg.variables = { | 639 | cfg.variables = { |
622 | LUA = lua, | 640 | LUA = lua, |
623 | LUA_DIR = lua_dir, | 641 | LUA_DIR = lua_dir, |
624 | LUA_BINDIR = lua_bindir, | 642 | LUA_BINDIR = lua_bindir, |
625 | LUA_LIBDIR = hardcoded.LUA_LIBDIR, | 643 | LUA_LIBDIR = hardcoded_lua_libdir, |
626 | LUA_INCDIR = hardcoded.LUA_INCDIR, | 644 | LUA_INCDIR = hardcoded_lua_incdir, |
627 | } | 645 | } |
628 | end | 646 | end |
629 | 647 | ||