From 8ee6441fc524b6ffc65fe327485cb8500b7a63f9 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 2 Jul 2022 17:27:39 +0200 Subject: executables: Reject Lua 5.1 early Prevents attempting to load libraries that may no longer be found and crashing with a traceback. Platforms like Debian where multiple Lua versions can be installed at the same time and 'lua' pointing to one of the installed interpreters via symlinks, there's the possibility that prosody/prosodyctl may be invoked with Lua 5.1, which will no longer have any of the rest of Prosody libraries available to be require(), and thus would immediately fail with an unfriendly traceback. Checking and aborting early with a friendlier message and reference to more information is better. Part of #1600 --- prosody | 6 ++++++ prosodyctl | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/prosody b/prosody index ac623cef..eaac3dff 100755 --- a/prosody +++ b/prosody @@ -44,6 +44,12 @@ if CFG_DATADIR then end +-- Check before first require, to preempt the probable failure +if _VERSION < "Lua 5.2" then + io.stderr:write("Prosody is no longer compatible with Lua 5.1\n") + io.stderr:write("See https://prosody.im/doc/depends#lua for more information\n") + return os.exit(1); +end local startup = require "util.startup"; local async = require "util.async"; diff --git a/prosodyctl b/prosodyctl index 4e4099d5..e7bff982 100755 --- a/prosodyctl +++ b/prosodyctl @@ -44,6 +44,13 @@ end ----------- +-- Check before first require, to preempt the probable failure +if _VERSION < "Lua 5.2" then + io.stderr:write("Prosody is no longer compatible with Lua 5.1\n") + io.stderr:write("See https://prosody.im/doc/depends#lua for more information\n") + return os.exit(1); +end + local startup = require "util.startup"; startup.prosodyctl(); -- cgit v1.2.3