diff tools/migration/prosody-migrator.lua @ 14068:2462247ec377 13.0

prosody, prosodyctl: Always search installation directory first Should solve for: - Running from a source directory like looks for ./{core,net,util}/*.lua first - `make install && prosody` looks for $prefix/prosody/{core,net,util}/*.lua first - Installation with luarocks or dh-lua into Lua search paths does not look for resources in the working directory.
author Kim Alvefur <zash@zash.se>
date Mon, 09 Feb 2026 18:30:57 +0100
parents b085d32af140
children af28d6debaca
line wrap: on
line diff
--- a/tools/migration/prosody-migrator.lua	Mon Feb 09 16:59:42 2026 +0100
+++ b/tools/migration/prosody-migrator.lua	Mon Feb 09 18:30:57 2026 +0100
@@ -15,7 +15,8 @@
 end
 
 -- Tell Lua where to find our libraries
-if CFG_SOURCEDIR then
+-- and ensure that resources in the current directory are not picked up by accident
+do
 	-- Installed instance
 	local function is_relative(path)
 		local path_sep = package.config:sub(1,1);
@@ -28,17 +29,14 @@
 	local function sanitise_paths(paths)
 		return (paths:gsub("[^;]+;?", filter_relative_paths):gsub(";;+", ";"));
 	end
-	package.path = sanitise_paths(CFG_SOURCEDIR.."/?.lua;"..package.path);
-	package.cpath = sanitise_paths(CFG_SOURCEDIR.."/?.so;"..package.cpath);
+	package.path = (CFG_SOURCEDIR or ".") .. "/?.lua;" .. sanitise_paths(package.path);
+	package.cpath = (CFG_SOURCEDIR or ".") .. "/?.so;" .. sanitise_paths(package.cpath);
 
-	if pcall(dofile, CFG_SOURCEDIR .. "/loader.lua") then
+	if pcall(dofile, (CFG_SOURCEDIR or ".") .. "/loader.lua") then
 		package.loaded["prosody.loader"] = true;
 	else
 		require "prosody.loader";
 	end
-else
-	-- Not installed, e.g. running from a source checkout
-	require "loader";
 end
 
 -- Substitute ~ with path to home directory in data path