From dde3ca9493dedbb950d5c1dfdf32a1bd1b152fca Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 8 Oct 2012 20:19:50 -0300 Subject: Check root parent only if root does not exist (useful for ~/.luarocks, avoids breakage with /usr/local). Closes #100. --- src/luarocks/fs/lua.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index c413ccb3..24b05a59 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua @@ -669,13 +669,18 @@ function check_command_permissions(flags) local root_dir = path.root_dir(cfg.rocks_dir) local ok = true local err = "" - for _, dir in ipairs { cfg.rocks_dir, root_dir, dir.dir_name(root_dir) } do + for _, dir in ipairs { cfg.rocks_dir, root_dir } do if fs.exists(dir) and not fs.is_writable(dir) then ok = false err = "Your user does not have write permissions in " .. dir break end end + local root_parent = dir.dir_name(root_dir) + if ok and not fs.exists(root_dir) and not fs.is_writable(root_parent) then + ok = false + err = root_dir.." does not exist and your user does not have write permissions in " .. root_parent + end if ok then return true else -- cgit v1.2.3-55-g6feb