From 17437fd52b648a6ad512c6e0587241c62b353f45 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Thu, 1 May 2014 22:20:28 +0200 Subject: fixes #251 - order of path; user vs system tree corrected. - bin directories of all trees included, instead of current tree --- src/luarocks/cfg.lua | 20 +++++++++++++------- src/luarocks/path_cmd.lua | 30 ++++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 1207d600..97b6a09e 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -523,18 +523,24 @@ local cfg_mt = { setmetatable(cfg, cfg_mt) function cfg.package_paths() - local new_path, new_cpath = { extra_luarocks_module_dir }, {} + local new_path, new_cpath, new_bin = {}, {}, {} for _,tree in ipairs(cfg.rocks_trees) do if type(tree) == "string" then - table.insert(new_path, 1, tree..cfg.lua_modules_path.."/?.lua;"..tree..cfg.lua_modules_path.."/?/init.lua") - table.insert(new_cpath, 1, tree..cfg.lib_modules_path.."/?."..cfg.lib_extension) + table.insert(new_path, tree..cfg.lua_modules_path.."/?.lua") + table.insert(new_path, tree..cfg.lua_modules_path.."/?/init.lua") + table.insert(new_cpath, tree..cfg.lib_modules_path.."/?."..cfg.lib_extension) + table.insert(new_bin, tree.."/bin") else - table.insert(new_path, 1, (tree.lua_dir or tree.root..cfg.lua_modules_path).."/?.lua;".. - (tree.lua_dir or tree.root..cfg.lua_modules_path).."/?/init.lua") - table.insert(new_cpath, 1, (tree.lib_dir or tree.root..cfg.lib_modules_path).."/?."..cfg.lib_extension) + table.insert(new_path, (tree.lua_dir or tree.root..cfg.lua_modules_path).."/?.lua") + table.insert(new_path, (tree.lua_dir or tree.root..cfg.lua_modules_path).."/?/init.lua") + table.insert(new_cpath, (tree.lib_dir or tree.root..cfg.lib_modules_path).."/?."..cfg.lib_extension) + table.insert(new_bin, (tree.bin_dir or tree.root.."/bin")) end end - return table.concat(new_path, ";"), table.concat(new_cpath, ";") + if extra_luarocks_module_dir then + table.insert(new_path, extra_luarocks_module_dir) + end + return table.concat(new_path, ";"), table.concat(new_cpath, ";"), table.concat(new_bin, ";") end function cfg.which_config() diff --git a/src/luarocks/path_cmd.lua b/src/luarocks/path_cmd.lua index d52f985a..4aeba41c 100644 --- a/src/luarocks/path_cmd.lua +++ b/src/luarocks/path_cmd.lua @@ -12,8 +12,24 @@ path_cmd.help_summary = "Return the currently configured package path." path_cmd.help_arguments = "" path_cmd.help = [[ Returns the package path currently configured for this installation -of LuaRocks, formatted as shell commands to update LUA_PATH and -LUA_CPATH. (On Unix systems, you may run: eval `luarocks path`) +of LuaRocks, formatted as shell commands to update LUA_PATH and LUA_CPATH. + +--bin Adds the system path to the output + +--append Appends the paths to the existing paths. Default is to prefix + the LR paths to the existing paths. + +--lr-path Exports the Lua path (not formatted as shell command) + +--lr-cpath Exports the Lua cpath (not formatted as shell command) + +--lr-bin Exports the system path (not formatted as shell command) + + +On Unix systems, you may run: + eval `luarocks path` +And on Windows: + luarocks path > "%temp%\_lrp.bat" && call "%temp%\_lrp.bat" && del "%temp%\_lrp.bat" ]] --- Driver function for "path" command. @@ -22,8 +38,7 @@ function path_cmd.run(...) local flags = util.parse_flags(...) local deps_mode = deps.get_deps_mode(flags) - local lr_path, lr_cpath = cfg.package_paths() - local bin_dirs = path.map_trees(deps_mode, path.deploy_bin_dir) + local lr_path, lr_cpath, lr_bin = cfg.package_paths() if flags["lr-path"] then util.printout(util.remove_path_dupes(lr_path, ';')) @@ -32,7 +47,6 @@ function path_cmd.run(...) util.printout(util.remove_path_dupes(lr_cpath, ';')) return true elseif flags["lr-bin"] then - local lr_bin = util.remove_path_dupes(table.concat(bin_dirs, cfg.export_path_separator), cfg.export_path_separator) util.printout(util.remove_path_dupes(lr_bin, ';')) return true end @@ -40,17 +54,17 @@ function path_cmd.run(...) if flags["append"] then lr_path = package.path .. ";" .. lr_path lr_cpath = package.cpath .. ";" .. lr_cpath + lr_bin = os.getenv("PATH") .. ";" .. lr_bin else lr_path = lr_path.. ";" .. package.path lr_cpath = lr_cpath .. ";" .. package.cpath + lr_bin = lr_bin .. ";" .. os.getenv("PATH") end util.printout(cfg.export_lua_path:format(util.remove_path_dupes(lr_path, ';'))) util.printout(cfg.export_lua_cpath:format(util.remove_path_dupes(lr_cpath, ';'))) if flags["bin"] then - table.insert(bin_dirs, 1, os.getenv("PATH")) - local lr_bin = util.remove_path_dupes(table.concat(bin_dirs, cfg.export_path_separator), cfg.export_path_separator) - util.printout(cfg.export_path:format(lr_bin)) + util.printout(cfg.export_path:format(util.remove_path_dupes(lr_bin,';'))) end return true end -- cgit v1.2.3-55-g6feb