diff options
| author | Sharad Singh <singhsharad071@gmail.com> | 2026-03-19 01:27:16 +0530 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2026-07-11 22:04:39 -0300 |
| commit | d158b68ef8fec9c80699dba9158ea0e70d1d656c (patch) | |
| tree | 9aede1db633ed70710268d6963008052ab008f75 | |
| parent | d31d02ccb6dd32057d3ca2bc609c7163f9205188 (diff) | |
| download | luarocks-d158b68ef8fec9c80699dba9158ea0e70d1d656c.tar.gz luarocks-d158b68ef8fec9c80699dba9158ea0e70d1d656c.tar.bz2 luarocks-d158b68ef8fec9c80699dba9158ea0e70d1d656c.zip | |
feat: warn on module name collisions during rock installation
When installing a rock that provides a module already provided by
another installed rock, print a warning indicating the collision
and which module will take priority.
Closes #1148
| -rw-r--r-- | src/luarocks/repos.lua | 23 | ||||
| -rw-r--r-- | src/luarocks/repos.tl | 23 |
2 files changed, 46 insertions, 0 deletions
diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua index 3898f234..0bfb2af8 100644 --- a/src/luarocks/repos.lua +++ b/src/luarocks/repos.lua | |||
| @@ -470,6 +470,13 @@ function repos.deploy_local_files(name, version, wrap_bin_scripts, deps_mode) | |||
| 470 | local paths = get_deploy_paths(name, version, "bin", file_path, repo) | 470 | local paths = get_deploy_paths(name, version, "bin", file_path, repo) |
| 471 | local mode, cur_name, cur_version = check_spot_if_available(name, version, "bin", file_path) | 471 | local mode, cur_name, cur_version = check_spot_if_available(name, version, "bin", file_path) |
| 472 | 472 | ||
| 473 | if cur_name and cur_name ~= name then | ||
| 474 | if mode == "nv" then | ||
| 475 | util.warning(string.format("Collision: '%s' from %s %s will take priority over '%s' provided by %s %s", file_path, name, version, file_path, cur_name, cur_version)) | ||
| 476 | else | ||
| 477 | util.warning(string.format("Collision: '%s' from %s %s will not take priority over '%s' provided by %s %s", file_path, name, version, file_path, cur_name, cur_version)) | ||
| 478 | end | ||
| 479 | end | ||
| 473 | if mode == "nv" and cur_name then | 480 | if mode == "nv" and cur_name then |
| 474 | local cur_paths = get_deploy_paths(cur_name, cur_version, "bin", file_path, repo) | 481 | local cur_paths = get_deploy_paths(cur_name, cur_version, "bin", file_path, repo) |
| 475 | table.insert(renames, { src = cur_paths.nv, dst = cur_paths.v, suffix = cfg.wrapper_suffix }) | 482 | table.insert(renames, { src = cur_paths.nv, dst = cur_paths.v, suffix = cfg.wrapper_suffix }) |
| @@ -491,6 +498,14 @@ function repos.deploy_local_files(name, version, wrap_bin_scripts, deps_mode) | |||
| 491 | local paths = get_deploy_paths(name, version, "lua", file_path, repo) | 498 | local paths = get_deploy_paths(name, version, "lua", file_path, repo) |
| 492 | local mode, cur_name, cur_version = check_spot_if_available(name, version, "lua", file_path) | 499 | local mode, cur_name, cur_version = check_spot_if_available(name, version, "lua", file_path) |
| 493 | 500 | ||
| 501 | if cur_name and cur_name ~= name then | ||
| 502 | local _, item_name = manif.get_provided_item("lua", file_path) | ||
| 503 | if mode == "nv" then | ||
| 504 | util.warning(string.format("Collision: module '%s' from %s %s will take priority over the same module provided by %s %s", item_name, name, version, cur_name, cur_version)) | ||
| 505 | else | ||
| 506 | util.warning(string.format("Collision: module '%s' from %s %s will not take priority over the same module provided by %s %s", item_name, name, version, cur_name, cur_version)) | ||
| 507 | end | ||
| 508 | end | ||
| 494 | if mode == "nv" and cur_name then | 509 | if mode == "nv" and cur_name then |
| 495 | local cur_paths = get_deploy_paths(cur_name, cur_version, "lua", file_path, repo) | 510 | local cur_paths = get_deploy_paths(cur_name, cur_version, "lua", file_path, repo) |
| 496 | table.insert(renames, { src = cur_paths.nv, dst = cur_paths.v }) | 511 | table.insert(renames, { src = cur_paths.nv, dst = cur_paths.v }) |
| @@ -511,6 +526,14 @@ function repos.deploy_local_files(name, version, wrap_bin_scripts, deps_mode) | |||
| 511 | local paths = get_deploy_paths(name, version, "lib", file_path, repo) | 526 | local paths = get_deploy_paths(name, version, "lib", file_path, repo) |
| 512 | local mode, cur_name, cur_version = check_spot_if_available(name, version, "lib", file_path) | 527 | local mode, cur_name, cur_version = check_spot_if_available(name, version, "lib", file_path) |
| 513 | 528 | ||
| 529 | if cur_name and cur_name ~= name then | ||
| 530 | local _, item_name = manif.get_provided_item("lib", file_path) | ||
| 531 | if mode == "nv" then | ||
| 532 | util.warning(string.format("Collision: module '%s' from %s %s will take priority over the same module provided by %s %s", item_name, name, version, cur_name, cur_version)) | ||
| 533 | else | ||
| 534 | util.warning(string.format("Collision: module '%s' from %s %s will not take priority over the same module provided by %s %s", item_name, name, version, cur_name, cur_version)) | ||
| 535 | end | ||
| 536 | end | ||
| 514 | if mode == "nv" and cur_name then | 537 | if mode == "nv" and cur_name then |
| 515 | local cur_paths = get_deploy_paths(cur_name, cur_version, "lua", file_path:gsub("%.[^.]+$", ".lua"), repo) | 538 | local cur_paths = get_deploy_paths(cur_name, cur_version, "lua", file_path:gsub("%.[^.]+$", ".lua"), repo) |
| 516 | table.insert(renames, { src = cur_paths.nv, dst = cur_paths.v }) | 539 | table.insert(renames, { src = cur_paths.nv, dst = cur_paths.v }) |
diff --git a/src/luarocks/repos.tl b/src/luarocks/repos.tl index 883fe4d4..a51692ea 100644 --- a/src/luarocks/repos.tl +++ b/src/luarocks/repos.tl | |||
| @@ -470,6 +470,13 @@ function repos.deploy_local_files(name: string, version: string, wrap_bin_script | |||
| 470 | local paths = get_deploy_paths(name, version, "bin", file_path, repo) | 470 | local paths = get_deploy_paths(name, version, "bin", file_path, repo) |
| 471 | local mode, cur_name, cur_version = check_spot_if_available(name, version, "bin", file_path) | 471 | local mode, cur_name, cur_version = check_spot_if_available(name, version, "bin", file_path) |
| 472 | 472 | ||
| 473 | if cur_name and cur_name ~= name then | ||
| 474 | if mode == "nv" then | ||
| 475 | util.warning(string.format("Collision: '%s' from %s %s will take priority over '%s' provided by %s %s", file_path, name, version, file_path, cur_name, cur_version)) | ||
| 476 | else | ||
| 477 | util.warning(string.format("Collision: '%s' from %s %s will not take priority over '%s' provided by %s %s", file_path, name, version, file_path, cur_name, cur_version)) | ||
| 478 | end | ||
| 479 | end | ||
| 473 | if mode == "nv" and cur_name then | 480 | if mode == "nv" and cur_name then |
| 474 | local cur_paths = get_deploy_paths(cur_name, cur_version, "bin", file_path, repo) | 481 | local cur_paths = get_deploy_paths(cur_name, cur_version, "bin", file_path, repo) |
| 475 | table.insert(renames, { src = cur_paths.nv, dst = cur_paths.v, suffix = cfg.wrapper_suffix }) | 482 | table.insert(renames, { src = cur_paths.nv, dst = cur_paths.v, suffix = cfg.wrapper_suffix }) |
| @@ -491,6 +498,14 @@ function repos.deploy_local_files(name: string, version: string, wrap_bin_script | |||
| 491 | local paths = get_deploy_paths(name, version, "lua", file_path, repo) | 498 | local paths = get_deploy_paths(name, version, "lua", file_path, repo) |
| 492 | local mode, cur_name, cur_version = check_spot_if_available(name, version, "lua", file_path) | 499 | local mode, cur_name, cur_version = check_spot_if_available(name, version, "lua", file_path) |
| 493 | 500 | ||
| 501 | if cur_name and cur_name ~= name then | ||
| 502 | local _, item_name = manif.get_provided_item("lua", file_path) | ||
| 503 | if mode == "nv" then | ||
| 504 | util.warning(string.format("Collision: module '%s' from %s %s will take priority over the same module provided by %s %s", item_name, name, version, cur_name, cur_version)) | ||
| 505 | else | ||
| 506 | util.warning(string.format("Collision: module '%s' from %s %s will not take priority over the same module provided by %s %s", item_name, name, version, cur_name, cur_version)) | ||
| 507 | end | ||
| 508 | end | ||
| 494 | if mode == "nv" and cur_name then | 509 | if mode == "nv" and cur_name then |
| 495 | local cur_paths = get_deploy_paths(cur_name, cur_version, "lua", file_path, repo) | 510 | local cur_paths = get_deploy_paths(cur_name, cur_version, "lua", file_path, repo) |
| 496 | table.insert(renames, { src = cur_paths.nv, dst = cur_paths.v }) | 511 | table.insert(renames, { src = cur_paths.nv, dst = cur_paths.v }) |
| @@ -511,6 +526,14 @@ function repos.deploy_local_files(name: string, version: string, wrap_bin_script | |||
| 511 | local paths = get_deploy_paths(name, version, "lib", file_path, repo) | 526 | local paths = get_deploy_paths(name, version, "lib", file_path, repo) |
| 512 | local mode, cur_name, cur_version = check_spot_if_available(name, version, "lib", file_path) | 527 | local mode, cur_name, cur_version = check_spot_if_available(name, version, "lib", file_path) |
| 513 | 528 | ||
| 529 | if cur_name and cur_name ~= name then | ||
| 530 | local _, item_name = manif.get_provided_item("lib", file_path) | ||
| 531 | if mode == "nv" then | ||
| 532 | util.warning(string.format("Collision: module '%s' from %s %s will take priority over the same module provided by %s %s", item_name, name, version, cur_name, cur_version)) | ||
| 533 | else | ||
| 534 | util.warning(string.format("Collision: module '%s' from %s %s will not take priority over the same module provided by %s %s", item_name, name, version, cur_name, cur_version)) | ||
| 535 | end | ||
| 536 | end | ||
| 514 | if mode == "nv" and cur_name then | 537 | if mode == "nv" and cur_name then |
| 515 | local cur_paths = get_deploy_paths(cur_name, cur_version, "lua", file_path:gsub("%.[^.]+$", ".lua"), repo) | 538 | local cur_paths = get_deploy_paths(cur_name, cur_version, "lua", file_path:gsub("%.[^.]+$", ".lua"), repo) |
| 516 | table.insert(renames, { src = cur_paths.nv, dst = cur_paths.v }) | 539 | table.insert(renames, { src = cur_paths.nv, dst = cur_paths.v }) |
