diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 6b6cdca53..c5777c165 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -247,6 +247,18 @@ opencomputers { # capitalization, which is commonly the case on Windows, for example. # This only takes effect when bufferChanges is set to true. forceCaseInsensitiveFS: false + + # Logs the full error when a native library fails to load. This is + # disabled by default to avoid spamming the log, since libraries are + # iterated until one works, so it's very likely for some to fail. Use + # this in case all libraries fail to load even though you'd expect one + # to work. + logFullNativeLibLoadErrors: false + + # Force loading one specific library, to avoid trying to load any + # others. Use this if you get warnings in the log or are told to do + # so for debugging purposes ;-) + forceNativeLibWithName: "" } } diff --git a/src/main/resources/assets/opencomputers/loot/OpenOS/init.lua b/src/main/resources/assets/opencomputers/loot/OpenOS/init.lua index c53afbff5..afd65b961 100644 --- a/src/main/resources/assets/opencomputers/loot/OpenOS/init.lua +++ b/src/main/resources/assets/opencomputers/loot/OpenOS/init.lua @@ -143,6 +143,8 @@ do computer.pushSignal("init") -- so libs know components are initialized. status("Starting shell...") + require("term").clear() + os.sleep(0.1) -- Allow init processing. end local function motd() @@ -161,7 +163,6 @@ local function motd() end while true do - require("term").clear() motd() local result, reason = os.execute(os.getenv("SHELL")) if not result then @@ -170,4 +171,5 @@ while true do os.sleep(0.5) require("event").pull("key") end + require("term").clear() end diff --git a/src/main/scala/li/cil/oc/Settings.scala b/src/main/scala/li/cil/oc/Settings.scala index 865e02b76..c3ddc699f 100644 --- a/src/main/scala/li/cil/oc/Settings.scala +++ b/src/main/scala/li/cil/oc/Settings.scala @@ -75,6 +75,8 @@ class Settings(config: Config) { val allowPersistence = !config.getBoolean("computer.debug.disablePersistence") val limitMemory = !config.getBoolean("computer.debug.disableMemoryLimit") val forceCaseInsensitive = config.getBoolean("computer.debug.forceCaseInsensitiveFS") + val logFullLibLoadErrors = config.getBoolean("computer.debug.logFullNativeLibLoadErrors") + val forceNativeLib = config.getString("computer.debug.forceNativeLibWithName") // ----------------------------------------------------------------------- // // robot diff --git a/src/main/scala/li/cil/oc/util/LuaStateFactory.scala b/src/main/scala/li/cil/oc/util/LuaStateFactory.scala index 2ebdd669a..446506dc1 100644 --- a/src/main/scala/li/cil/oc/util/LuaStateFactory.scala +++ b/src/main/scala/li/cil/oc/util/LuaStateFactory.scala @@ -3,6 +3,7 @@ package li.cil.oc.util import java.io.{File, FileInputStream, FileOutputStream} import java.nio.channels.Channels +import com.google.common.base.Strings import com.naef.jnlua import com.naef.jnlua.LuaState import com.naef.jnlua.NativeSupport.Loader @@ -92,7 +93,7 @@ object LuaStateFactory { } // Try to find a working lib. - for (library <- libNames if !haveNativeLibrary) { + for (library <- libNames if !haveNativeLibrary && (Strings.isNullOrEmpty(Settings.get.forceNativeLib) || library == Settings.get.forceNativeLib)) { OpenComputers.log.trace(s"Trying native library '$library'...") val libraryUrl = classOf[Machine].getResource(libPath + library) if (libraryUrl != null) { @@ -178,8 +179,13 @@ object LuaStateFactory { haveNativeLibrary = true } catch { - case _: Throwable => - OpenComputers.log.trace(s"Could not load native library '${file.getName}'.") + case t: Throwable => + if (Settings.get.logFullLibLoadErrors) { + OpenComputers.log.info(s"Could not load native library '${file.getName}'.", t) + } + else { + OpenComputers.log.trace(s"Could not load native library '${file.getName}'.") + } file.delete() } }