aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/cfg.lua2
-rw-r--r--src/luarocks/command_line.lua5
2 files changed, 6 insertions, 1 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua
index ea80e5b5..b4781840 100644
--- a/src/luarocks/cfg.lua
+++ b/src/luarocks/cfg.lua
@@ -139,7 +139,7 @@ else
139 cfg.home = os.getenv("HOME") or "" 139 cfg.home = os.getenv("HOME") or ""
140 sys_config_dir = sys_config_dir or "/etc/luarocks" 140 sys_config_dir = sys_config_dir or "/etc/luarocks"
141 home_config_dir = cfg.home.."/.luarocks" 141 home_config_dir = cfg.home.."/.luarocks"
142 cfg.home_tree = cfg.home.."/.luarocks/" 142 cfg.home_tree = (os.getenv("USER") ~= "root") and cfg.home.."/.luarocks/"
143end 143end
144 144
145cfg.variables = {} 145cfg.variables = {}
diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua
index c885575e..a92a3f9d 100644
--- a/src/luarocks/command_line.lua
+++ b/src/luarocks/command_line.lua
@@ -153,6 +153,11 @@ function command_line.run_command(...)
153 replace_tree(flags, args, root_dir) 153 replace_tree(flags, args, root_dir)
154 end 154 end
155 elseif flags["local"] then 155 elseif flags["local"] then
156 if not cfg.home_tree then
157 die("The --local flag is meant for operating in a user's home directory.\n"..
158 "You are running as a superuser, which is intended for system-wide operation.\n"..
159 "To force using the superuser's home, use --tree explicitly.")
160 end
156 replace_tree(flags, args, cfg.home_tree) 161 replace_tree(flags, args, cfg.home_tree)
157 else 162 else
158 local trees = cfg.rocks_trees 163 local trees = cfg.rocks_trees