From 24a8f07810f2b961b2f14b013bac7a5365354b40 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 11 Mar 2024 13:08:40 -0300 Subject: 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. --- src/luarocks/cmd.lua | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src') 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 process_tree_args = function(args, project_dir) if args.global then - cfg.local_by_default = false - end - - if args.tree then + local ok, err = set_named_tree(args, "system") + if not ok then + return nil, err + end + elseif args.tree then local named = set_named_tree(args, args.tree) if not named then local root_dir = fs.absolute_name(args.tree) @@ -97,7 +98,10 @@ do "You are running as a superuser, which is intended for system-wide operation.\n".. "To force using the superuser's home, use --tree explicitly." else - set_named_tree(args, "user") + local ok, err = set_named_tree(args, "user") + if not ok then + return nil, err + end end elseif args.project_tree then local tree = args.project_tree @@ -105,7 +109,10 @@ do manif.load_rocks_tree_manifests() path.use_tree(tree) elseif cfg.local_by_default then - set_named_tree(args, "user") + local ok, err = set_named_tree(args, "user") + if not ok then + return nil, err + end elseif project_dir then local project_tree = project_dir .. "/lua_modules" table.insert(cfg.rocks_trees, 1, { name = "project", root = project_tree } ) -- cgit v1.2.3-55-g6feb