aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/luarocks/fs/lua.lua39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua
index 41711eab..0a95359a 100644
--- a/src/luarocks/fs/lua.lua
+++ b/src/luarocks/fs/lua.lua
@@ -821,28 +821,29 @@ end
821-- @return boolean or (boolean, string): true on success, false on failure, 821-- @return boolean or (boolean, string): true on success, false on failure,
822-- plus an error message. 822-- plus an error message.
823function fs_lua.check_command_permissions(flags) 823function fs_lua.check_command_permissions(flags)
824 local root_dir = path.root_dir(cfg.rocks_dir)
825 local ok = true 824 local ok = true
826 local err = "" 825 local err = ""
827 for _, dir in ipairs { cfg.rocks_dir, root_dir } do 826 for _, dir in ipairs { cfg.rocks_dir, cfg.deploy_lua_dir, cfg.deploy_bin_dir, cfg.deploy_lua_dir } do
828 if fs.exists(dir) and not fs.is_writable(dir) then 827 if fs.exists(dir) then
829 ok = false 828 if not fs.is_writable(dir) then
830 err = "Your user does not have write permissions in " .. dir 829 ok = false
831 break 830 err = "Your user does not have write permissions in " .. dir
832 end 831 break
833 end 832 end
834 if ok and not fs.exists(root_dir) then 833 else
835 local root = fs.root_of(root_dir) 834 local root = fs.root_of(dir)
836 local parent = root_dir 835 local parent = dir
837 repeat 836 repeat
838 parent = dir.dir_name(parent) 837 parent = dir.dir_name(parent)
839 if parent == "" then 838 if parent == "" then
840 parent = root 839 parent = root
840 end
841 until parent == root or fs.exists(parent)
842 if not fs.is_writable(parent) then
843 ok = false
844 err = dir.." does not exist and your user does not have write permissions in " .. parent
845 break
841 end 846 end
842 until parent == root or fs.exists(parent)
843 if not fs.is_writable(parent) then
844 ok = false
845 err = root_dir.." does not exist and your user does not have write permissions in " .. parent
846 end 847 end
847 end 848 end
848 if ok then 849 if ok then