diff options
-rw-r--r-- | spec/cmd_spec.lua | 2 | ||||
-rw-r--r-- | src/luarocks/cmd.lua | 74 | ||||
-rw-r--r-- | src/luarocks/cmd/init.lua | 4 | ||||
-rw-r--r-- | src/luarocks/core/cfg.lua | 2 | ||||
-rw-r--r-- | src/luarocks/deps.lua | 5 | ||||
-rw-r--r-- | src/luarocks/util.lua | 4 |
6 files changed, 50 insertions, 41 deletions
diff --git a/spec/cmd_spec.lua b/spec/cmd_spec.lua index fe27ab1b..5d6e729b 100644 --- a/spec/cmd_spec.lua +++ b/spec/cmd_spec.lua | |||
@@ -60,7 +60,7 @@ describe("LuaRocks command line #integration", function() | |||
60 | 60 | ||
61 | it("warns but continues if given an invalid version", function() | 61 | it("warns but continues if given an invalid version", function() |
62 | local output = run.luarocks("--lua-version=1.0") | 62 | local output = run.luarocks("--lua-version=1.0") |
63 | assert.match("Warning: Lua 1.0 interpreter not found", output, 1, true) | 63 | assert.match("LUA *: %(not found%)", output) |
64 | assert.match("Version%s*:%s*1.0", output) | 64 | assert.match("Version%s*:%s*1.0", output) |
65 | end) | 65 | end) |
66 | 66 | ||
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index 3067f4ce..30293d6b 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua | |||
@@ -340,14 +340,18 @@ Variables: | |||
340 | 340 | ||
341 | ]] | 341 | ]] |
342 | 342 | ||
343 | local function get_status(status) | 343 | local lua_example = package.config:sub(1, 1) == "\\" |
344 | return status and "ok" or "not found" | 344 | and "<d:\\path\\lua.exe>" |
345 | or "</path/lua>" | ||
346 | |||
347 | local function show_status(file, status) | ||
348 | return (file and file .. " " or "") .. (status and "(ok)" or "(not found)") | ||
345 | end | 349 | end |
346 | 350 | ||
347 | local function use_to_fix_location(key) | 351 | local function use_to_fix_location(key, what) |
348 | local buf = " ****************************************\n" | 352 | local buf = " ****************************************\n" |
349 | buf = buf .. " Use the command\n\n" | 353 | buf = buf .. " Use the command\n\n" |
350 | buf = buf .. " luarocks config " .. key .. " <dir>\n\n" | 354 | buf = buf .. " luarocks config " .. key .. " " .. (what or "<dir>") .. "\n\n" |
351 | buf = buf .. " to fix the location\n" | 355 | buf = buf .. " to fix the location\n" |
352 | buf = buf .. " ****************************************\n" | 356 | buf = buf .. " ****************************************\n" |
353 | return buf | 357 | return buf |
@@ -358,8 +362,6 @@ local function get_config_text(cfg) -- luacheck: ignore 431 | |||
358 | 362 | ||
359 | local libdir_ok = deps.check_lua_libdir(cfg.variables) | 363 | local libdir_ok = deps.check_lua_libdir(cfg.variables) |
360 | local incdir_ok = deps.check_lua_incdir(cfg.variables) | 364 | local incdir_ok = deps.check_lua_incdir(cfg.variables) |
361 | local bindir_ok = cfg.variables.LUA_BINDIR and fs.exists(cfg.variables.LUA_BINDIR) | ||
362 | local luadir_ok = cfg.variables.LUA_DIR and fs.exists(cfg.variables.LUA_DIR) | ||
363 | local lua_ok = cfg.variables.LUA and fs.exists(cfg.variables.LUA) | 365 | local lua_ok = cfg.variables.LUA and fs.exists(cfg.variables.LUA) |
364 | 366 | ||
365 | local buf = "Configuration:\n" | 367 | local buf = "Configuration:\n" |
@@ -368,31 +370,29 @@ local function get_config_text(cfg) -- luacheck: ignore 431 | |||
368 | if cfg.luajit_version then | 370 | if cfg.luajit_version then |
369 | buf = buf.." LuaJIT : "..cfg.luajit_version.."\n" | 371 | buf = buf.." LuaJIT : "..cfg.luajit_version.."\n" |
370 | end | 372 | end |
371 | buf = buf.." Interpreter: "..(cfg.variables.LUA or "").." ("..get_status(lua_ok)..")\n" | 373 | buf = buf.." LUA : "..show_status(cfg.variables.LUA, lua_ok).."\n" |
372 | buf = buf.." LUA_DIR : "..(cfg.variables.LUA_DIR or "").." ("..get_status(luadir_ok)..")\n" | ||
373 | if not lua_ok then | 374 | if not lua_ok then |
374 | buf = buf .. use_to_fix_location("lua_dir") | 375 | buf = buf .. use_to_fix_location("variables.LUA", lua_example) |
375 | end | 376 | end |
376 | buf = buf.." LUA_BINDIR : "..(cfg.variables.LUA_BINDIR or "").." ("..get_status(bindir_ok)..")\n" | 377 | buf = buf.." LUA_INCDIR : "..show_status(cfg.variables.LUA_INCDIR, incdir_ok).."\n" |
377 | buf = buf.." LUA_INCDIR : "..(cfg.variables.LUA_INCDIR or "").." ("..get_status(incdir_ok)..")\n" | ||
378 | if lua_ok and not incdir_ok then | 378 | if lua_ok and not incdir_ok then |
379 | buf = buf .. use_to_fix_location("variables.LUA_INCDIR") | 379 | buf = buf .. use_to_fix_location("variables.LUA_INCDIR") |
380 | end | 380 | end |
381 | buf = buf.." LUA_LIBDIR : "..(cfg.variables.LUA_LIBDIR or "").." ("..get_status(libdir_ok)..")\n" | 381 | buf = buf.." LUA_LIBDIR : "..show_status(cfg.variables.LUA_LIBDIR, libdir_ok).."\n" |
382 | if lua_ok and not libdir_ok then | 382 | if lua_ok and not libdir_ok then |
383 | buf = buf .. use_to_fix_location("variables.LUA_LIBDIR") | 383 | buf = buf .. use_to_fix_location("variables.LUA_LIBDIR") |
384 | end | 384 | end |
385 | 385 | ||
386 | buf = buf.."\n Configuration files:\n" | 386 | buf = buf.."\n Configuration files:\n" |
387 | local conf = cfg.config_files | 387 | local conf = cfg.config_files |
388 | buf = buf.." System : "..fs.absolute_name(conf.system.file).." ("..get_status(conf.system.found)..")\n" | 388 | buf = buf.." System : "..show_status(fs.absolute_name(conf.system.file), conf.system.found).."\n" |
389 | if conf.user.file then | 389 | if conf.user.file then |
390 | buf = buf.." User : "..fs.absolute_name(conf.user.file).." ("..get_status(conf.user.found)..")\n" | 390 | buf = buf.." User : "..show_status(fs.absolute_name(conf.user.file), conf.user.found).."\n" |
391 | else | 391 | else |
392 | buf = buf.." User : disabled in this LuaRocks installation.\n" | 392 | buf = buf.." User : disabled in this LuaRocks installation.\n" |
393 | end | 393 | end |
394 | if conf.project then | 394 | if conf.project then |
395 | buf = buf.." Project : "..fs.absolute_name(conf.project.file).." ("..get_status(conf.project.found)..")\n" | 395 | buf = buf.." Project : "..show_status(fs.absolute_name(conf.project.file), conf.project.found).."\n" |
396 | end | 396 | end |
397 | buf = buf.."\n Rocks trees in use: \n" | 397 | buf = buf.."\n Rocks trees in use: \n" |
398 | for _, tree in ipairs(cfg.rocks_trees) do | 398 | for _, tree in ipairs(cfg.rocks_trees) do |
@@ -638,33 +638,35 @@ function cmd.run_command(description, commands, external_namespace, ...) | |||
638 | cfg.variables.LUA_INCDIR = nil | 638 | cfg.variables.LUA_INCDIR = nil |
639 | cfg.variables.LUA_LIBDIR = nil | 639 | cfg.variables.LUA_LIBDIR = nil |
640 | end | 640 | end |
641 | else | ||
642 | cfg.variables.LUA = nil | ||
643 | cfg.variables.LUA_DIR = nil | ||
644 | cfg.variables.LUA_BINDIR = nil | ||
645 | cfg.variables.LUA_INCDIR = nil | ||
646 | cfg.variables.LUA_LIBDIR = nil | ||
641 | end | 647 | end |
642 | end | 648 | end |
643 | 649 | ||
644 | if lua_found then | 650 | if lua_found then |
645 | assert(cfg.variables.LUA) | 651 | assert(cfg.variables.LUA) |
646 | else | 652 | else |
647 | if args.command ~= "config" and args.command ~= "help" then | ||
648 | util.warning(tried .. | ||
649 | "\nModules may not install with the correct configurations. " .. | ||
650 | "You may want to configure the path prefix to your build " .. | ||
651 | "of Lua " .. cfg.lua_version .. " using\n\n" .. | ||
652 | " luarocks config --local lua_dir <your-lua-prefix>\n") | ||
653 | end | ||
654 | |||
655 | -- Fallback producing _some_ Lua configuration based on the running interpreter. | 653 | -- Fallback producing _some_ Lua configuration based on the running interpreter. |
656 | -- Most likely won't produce correct results when running from the standalone binary, | 654 | -- Most likely won't produce correct results when running from the standalone binary, |
657 | -- so eventually we need to drop this and outright fail if Lua is not found | 655 | -- so eventually we need to drop this and outright fail if Lua is not found |
658 | -- or explictly configured | 656 | -- or explictly configured |
659 | if not cfg.variables.LUA then | 657 | if not cfg.variables.LUA then |
660 | local first_arg = get_first_arg() | 658 | local first_arg = get_first_arg() |
661 | cfg.variables.LUA_DIR = dir.dir_name(fs.absolute_name(first_arg)) | 659 | local bin_dir = dir.dir_name(fs.absolute_name(first_arg)) |
662 | cfg.variables.LUA_BINDIR = cfg.variables.LUA_DIR | 660 | local exe = dir.base_name(first_arg) |
663 | local exe = fs.base_name(first_arg) | ||
664 | exe = exe:match("rocks") and ("lua" .. (cfg.arch:match("win") and ".exe" or "")) or exe | 661 | exe = exe:match("rocks") and ("lua" .. (cfg.arch:match("win") and ".exe" or "")) or exe |
665 | cfg.variables.LUA = dir.path(cfg.variables.LUA_BINDIR, exe) | 662 | local full_path = dir.path(bin_dir, exe) |
666 | cfg.variables.LUA_INCDIR = nil | 663 | if util.check_lua_version(full_path, cfg.lua_version) then |
667 | cfg.variables.LUA_LIBDIR = nil | 664 | cfg.variables.LUA = dir.path(bin_dir, exe) |
665 | cfg.variables.LUA_DIR = bin_dir:gsub("[/\\]bin[/\\]?$", "") | ||
666 | cfg.variables.LUA_BINDIR = bin_dir | ||
667 | cfg.variables.LUA_INCDIR = nil | ||
668 | cfg.variables.LUA_LIBDIR = nil | ||
669 | end | ||
668 | end | 670 | end |
669 | end | 671 | end |
670 | 672 | ||
@@ -718,10 +720,16 @@ function cmd.run_command(description, commands, external_namespace, ...) | |||
718 | os.exit(cmd.errorcodes.OK) | 720 | os.exit(cmd.errorcodes.OK) |
719 | end | 721 | end |
720 | 722 | ||
721 | if not cfg.variables["LUA_BINDIR"] then | 723 | if not cfg.variables["LUA"] and args.command ~= "config" and args.command ~= "help" then |
722 | return nil, "LUA_BINDIR not configured.\n" .. | 724 | local flag = (not cfg.project_tree) |
723 | "Please configure the location of the Lua interpreter with:\n" .. | 725 | and "--local " |
724 | " luarocks config variables.LUA_BINDIR <path>" | 726 | or "" |
727 | if args.lua_version then | ||
728 | flag = "--lua-version=" .. args.lua_version .. " " .. flag | ||
729 | end | ||
730 | die((tried or "Lua interpreter not found.") .. | ||
731 | "\nPlease set your Lua interpreter with:\n\n" .. | ||
732 | " luarocks " .. flag.. "config variables.LUA " .. lua_example .. "\n") | ||
725 | end | 733 | end |
726 | 734 | ||
727 | local cmd_mod = cmd_modules[args.command] | 735 | local cmd_mod = cmd_modules[args.command] |
diff --git a/src/luarocks/cmd/init.lua b/src/luarocks/cmd/init.lua index 20aa97a1..fabd92a1 100644 --- a/src/luarocks/cmd/init.lua +++ b/src/luarocks/cmd/init.lua | |||
@@ -125,10 +125,6 @@ function init.command(args) | |||
125 | 125 | ||
126 | util.title("Initializing project '" .. args.name .. "' for Lua " .. cfg.lua_version .. " ...") | 126 | util.title("Initializing project '" .. args.name .. "' for Lua " .. cfg.lua_version .. " ...") |
127 | 127 | ||
128 | util.printout("Checking your Lua installation ...") | ||
129 | if not cfg.lua_found then | ||
130 | return nil, "Lua installation is not found." | ||
131 | end | ||
132 | local ok, err = deps.check_lua_incdir(cfg.variables) | 128 | local ok, err = deps.check_lua_incdir(cfg.variables) |
133 | if not ok then | 129 | if not ok then |
134 | return nil, err | 130 | return nil, err |
diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua index 2e144c62..a420bb44 100644 --- a/src/luarocks/core/cfg.lua +++ b/src/luarocks/core/cfg.lua | |||
@@ -787,7 +787,7 @@ function cfg.init(detected, warning) | |||
787 | -- if only cfg.variables.LUA is given in config files, | 787 | -- if only cfg.variables.LUA is given in config files, |
788 | -- derive LUA_BINDIR and LUA_DIR from them. | 788 | -- derive LUA_BINDIR and LUA_DIR from them. |
789 | if cfg.variables.LUA and not cfg.variables.LUA_BINDIR then | 789 | if cfg.variables.LUA and not cfg.variables.LUA_BINDIR then |
790 | cfg.variables.LUA_BINDIR = cfg.variables.LUA:gsub("^(.*)[/\\][^/\\]*$") | 790 | cfg.variables.LUA_BINDIR = cfg.variables.LUA:match("^(.*)[/\\][^/\\]*$") |
791 | if not cfg.variables.LUA_DIR then | 791 | if not cfg.variables.LUA_DIR then |
792 | cfg.variables.LUA_DIR = cfg.variables.LUA_BINDIR:gsub("[/\\]bin$", "") or cfg.variables.LUA_BINDIR | 792 | cfg.variables.LUA_DIR = cfg.variables.LUA_BINDIR:gsub("[/\\]bin$", "") or cfg.variables.LUA_BINDIR |
793 | end | 793 | end |
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index 2680b64b..16631c58 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua | |||
@@ -706,7 +706,7 @@ local function lua_h_exists(d, luaver) | |||
706 | return nil, "Lua header found at " .. d .. " does not match Lua version " .. luaver .. ". You may want to override this by configuring LUA_INCDIR.", "dependency", 2 | 706 | return nil, "Lua header found at " .. d .. " does not match Lua version " .. luaver .. ". You may want to override this by configuring LUA_INCDIR.", "dependency", 2 |
707 | end | 707 | end |
708 | 708 | ||
709 | return nil, "Failed finding Lua header files. You may need to install them or configure LUA_INCDIR.", "dependency", 1 | 709 | return nil, "Failed finding Lua header files (searched at " .. d .. "). You may need to install them or configure LUA_INCDIR.", "dependency", 1 |
710 | end | 710 | end |
711 | 711 | ||
712 | local function find_lua_incdir(prefix, luaver, luajitver) | 712 | local function find_lua_incdir(prefix, luaver, luajitver) |
@@ -763,7 +763,7 @@ function deps.check_lua_incdir(vars) | |||
763 | return nil, err | 763 | return nil, err |
764 | end | 764 | end |
765 | 765 | ||
766 | return nil, "Failed finding Lua header files. You may need to install them or configure LUA_INCDIR.", "dependency" | 766 | return nil, "Failed finding Lua headers; neither LUA_DIR or LUA_INCDIR are set. You may need to install them or configure LUA_INCDIR.", "dependency" |
767 | end | 767 | end |
768 | 768 | ||
769 | function deps.check_lua_libdir(vars) | 769 | function deps.check_lua_libdir(vars) |
@@ -789,6 +789,7 @@ function deps.check_lua_libdir(vars) | |||
789 | } | 789 | } |
790 | if ljv then | 790 | if ljv then |
791 | table.insert(libnames, 1, "luajit-" .. cfg.lua_version) | 791 | table.insert(libnames, 1, "luajit-" .. cfg.lua_version) |
792 | table.insert(libnames, 2, "luajit") | ||
792 | end | 793 | end |
793 | local cache = {} | 794 | local cache = {} |
794 | local save_LUA_INCDIR = vars.LUA_INCDIR | 795 | local save_LUA_INCDIR = vars.LUA_INCDIR |
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index 902656fd..de9157fc 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
@@ -434,6 +434,10 @@ do | |||
434 | end | 434 | end |
435 | cfg.cache.luajit_version_checked = true | 435 | cfg.cache.luajit_version_checked = true |
436 | 436 | ||
437 | if not cfg.variables.LUA then | ||
438 | return nil | ||
439 | end | ||
440 | |||
437 | local ljv | 441 | local ljv |
438 | if cfg.lua_version == "5.1" then | 442 | if cfg.lua_version == "5.1" then |
439 | -- Ignores extra version info for custom builds, e.g. "LuaJIT 2.1.0-beta3 some-other-version-info" | 443 | -- Ignores extra version info for custom builds, e.g. "LuaJIT 2.1.0-beta3 some-other-version-info" |