aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2024-03-11 13:08:40 -0300
committerHisham Muhammad <hisham@gobolinux.org>2024-03-11 19:46:44 +0000
commit24a8f07810f2b961b2f14b013bac7a5365354b40 (patch)
tree7fcbc6c4f192442e957fed485bb5c88c4496b8cb
parent1f8530a08c0d7d8ccd7b3b4510eddceb231b11ce (diff)
downloadluarocks-24a8f07810f2b961b2f14b013bac7a5365354b40.tar.gz
luarocks-24a8f07810f2b961b2f14b013bac7a5365354b40.tar.bz2
luarocks-24a8f07810f2b961b2f14b013bac7a5365354b40.zip
always make --global target the system tree
This alleviates the issue in the specific invocation given in #1425, but I don't think it is a full solution. See #1425.
-rw-r--r--src/luarocks/cmd.lua19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua
index 6085fc9d..09468208 100644
--- a/src/luarocks/cmd.lua
+++ b/src/luarocks/cmd.lua
@@ -79,10 +79,11 @@ do
79 process_tree_args = function(args, project_dir) 79 process_tree_args = function(args, project_dir)
80 80
81 if args.global then 81 if args.global then
82 cfg.local_by_default = false 82 local ok, err = set_named_tree(args, "system")
83 end 83 if not ok then
84 84 return nil, err
85 if args.tree then 85 end
86 elseif args.tree then
86 local named = set_named_tree(args, args.tree) 87 local named = set_named_tree(args, args.tree)
87 if not named then 88 if not named then
88 local root_dir = fs.absolute_name(args.tree) 89 local root_dir = fs.absolute_name(args.tree)
@@ -97,7 +98,10 @@ do
97 "You are running as a superuser, which is intended for system-wide operation.\n".. 98 "You are running as a superuser, which is intended for system-wide operation.\n"..
98 "To force using the superuser's home, use --tree explicitly." 99 "To force using the superuser's home, use --tree explicitly."
99 else 100 else
100 set_named_tree(args, "user") 101 local ok, err = set_named_tree(args, "user")
102 if not ok then
103 return nil, err
104 end
101 end 105 end
102 elseif args.project_tree then 106 elseif args.project_tree then
103 local tree = args.project_tree 107 local tree = args.project_tree
@@ -105,7 +109,10 @@ do
105 manif.load_rocks_tree_manifests() 109 manif.load_rocks_tree_manifests()
106 path.use_tree(tree) 110 path.use_tree(tree)
107 elseif cfg.local_by_default then 111 elseif cfg.local_by_default then
108 set_named_tree(args, "user") 112 local ok, err = set_named_tree(args, "user")
113 if not ok then
114 return nil, err
115 end
109 elseif project_dir then 116 elseif project_dir then
110 local project_tree = project_dir .. "/lua_modules" 117 local project_tree = project_dir .. "/lua_modules"
111 table.insert(cfg.rocks_trees, 1, { name = "project", root = project_tree } ) 118 table.insert(cfg.rocks_trees, 1, { name = "project", root = project_tree } )