diff options
-rw-r--r-- | src/luarocks/cmd.lua | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index 996900ff..ea906726 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua | |||
@@ -25,6 +25,9 @@ cmd.errorcodes = { | |||
25 | 25 | ||
26 | local function is_ownership_ok(directory) | 26 | local function is_ownership_ok(directory) |
27 | local me = fs.current_user() | 27 | local me = fs.current_user() |
28 | if not me then | ||
29 | return nil, "can't determine current user's name" | ||
30 | end | ||
28 | for _ = 1,3 do -- try up to grandparent | 31 | for _ = 1,3 do -- try up to grandparent |
29 | local owner = fs.attributes(directory, "owner") | 32 | local owner = fs.attributes(directory, "owner") |
30 | if owner then | 33 | if owner then |
@@ -468,7 +471,8 @@ function cmd.run_command(description, commands, external_namespace, ...) | |||
468 | end | 471 | end |
469 | end | 472 | end |
470 | 473 | ||
471 | if not is_ownership_ok(cfg.local_cache) then | 474 | local user_owns_local_cache = is_ownership_ok(cfg.local_cache) |
475 | if user_owns_local_cache == false then | ||
472 | util.warning("The directory '" .. cfg.local_cache .. "' or its parent directory ".. | 476 | util.warning("The directory '" .. cfg.local_cache .. "' or its parent directory ".. |
473 | "is not owned by the current user and the cache has been disabled. ".. | 477 | "is not owned by the current user and the cache has been disabled. ".. |
474 | "Please check the permissions and owner of that directory. ".. | 478 | "Please check the permissions and owner of that directory. ".. |