From c79d3a85820d5b69b3a8f309d456a9feb4eeb013 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Thu, 25 Jul 2019 14:57:25 -0300 Subject: Don't use project dir or default_lua_version with --force-config (#1054) Fixes #1045. --- src/luarocks/cmd.lua | 9 +++++++++ src/luarocks/core/cfg.lua | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index 08505129..4397ffbd 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua @@ -13,6 +13,11 @@ local dir = require("luarocks.dir") local fun = require("luarocks.fun") local fs = require("luarocks.fs") +local hc_ok, hardcoded = pcall(require, "luarocks.core.hardcoded") +if not hc_ok then + hardcoded = {} +end + local program = util.this_program("luarocks") cmd.errorcodes = { @@ -189,6 +194,10 @@ do end local function find_default_lua_version(flags, project_dir) + if hardcoded.FORCE_CONFIG then + return nil + end + local dirs = {} if project_dir then table.insert(dirs, dir.path(project_dir, ".luarocks")) diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua index d8442962..8c11d408 100644 --- a/src/luarocks/core/cfg.lua +++ b/src/luarocks/core/cfg.lua @@ -561,7 +561,7 @@ function cfg.init(detected, warning) local lua_incdir = detected.lua_incdir or hardcoded.LUA_INCDIR local lua_libdir = detected.lua_libdir or hardcoded.LUA_LIBDIR local lua_dir = detected.lua_dir or hardcoded.LUA_DIR or (lua_bindir and lua_bindir:gsub("[\\/]bin$", "")) - local project_dir = detected.project_dir + local project_dir = (not hardcoded.FORCE_CONFIG) and detected.project_dir local init = cfg.init @@ -695,7 +695,7 @@ function cfg.init(detected, warning) ---------------------------------------- -- Settings detected or given via the CLI (i.e. --lua-dir) take precedence over config files: - cfg.project_dir = detected.project_dir + cfg.project_dir = project_dir cfg.lua_version = detected.lua_version or cfg.lua_version cfg.luajit_version = detected.luajit_version or cfg.luajit_version cfg.lua_interpreter = detected.lua_interpreter or cfg.lua_interpreter -- cgit v1.2.3-55-g6feb