Showing posts with label patching. Show all posts
Showing posts with label patching. Show all posts

Saturday, October 3, 2026

Mudlet properly fixed

It has been a while since my attempted patch for Mudlet to successfully build and fully function for FreeBSD.  I have been waiting patiently and have checked back with Grok to see if other solutions would become apparant.  Unfortunately my efforts with Grok did not yield any further improvements.  However, I recently saw a comment on my proposed patch which could solve the issue.

Thanks for chasing this down on FreeBSD. The crash is real, but the cause is in packaging,
not in Geyser, and it isn't specific to FreeBSD.

The real cause

  1. Adjustable.Container loads its strings with loadTranslations("AdjustableContainer"). That looks for translations/lua/mudlet-lua.json first in the source tree, then under luaGlobalPath .. "/translations/" (Other.lua).
  2. The make install rules for UNIX AND NOT APPLE in src/CMakeLists.txt install mudlet-lua/lua, the tests and lcf, but never translations/lua/*.json. Only the macOS bundle copies them. This is still true on current development.
  3. An installed Mudlet loads Lua from ${PREFIX}/share/mudlet/lua (TLuaInterpreter.cpp), so neither path exists and loadTranslations() returns nil. Adjustable.Container:new then fails on self.Locale.lock.message.
The FreeBSD port just hits this first. A Linux distro package or a /usr/local make install fails the same way. The fix is one install rule matching the existing fallback path:
install(DIRECTORY "../translations/lua/"
        DESTINATION "share/mudlet/lua/translations"
        FILES_MATCHING PATTERN "*.json"
        PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
That also fixes the package and module install messages in Other.lua, which load translations the same way. Problems with the current patch (checked by running the patched code in lua5.1)
  • Breaks package installs. It sets mudlet.Locale = {}. Other.lua fills mudlet.Locale lazily (mudlet.Locale = mudlet.Locale or loadTranslations("Mudlet")), so once any adjustable container exists, that load never runs. verbosePackageInstall / verboseModuleInstall then fail with "attempt to index field 'packageInstallSuccess' (a nil value)", even when translations are present.
  • The fallback covers 7 of the 17 AdjustableContainer keys. Hovering "Attach" (onEnterAtt, top/bottom/left/right) and calling addConnectMenu() (connectTo/ disconnect) still throw. The English fallback strings also differ from the real ones ("Minimize" vs "Min/Restore", "Lock Style" vs "Lockstyle:", "Custom Items" vs "Custom:").
  • The getOS() == "freebsd" gate misses the other affected platforms. OpenBSD, NetBSD and Linux installs still crash.
  • Leftover guards. min_restore / max_restore are never read as fields. The second constructor block writes the class Locale, and only that write keeps line 1137 from crashing.
Would you be up for replacing the Lua changes with the install rule above? It would help if you could confirm share/mudlet/lua/translations/mudlet-lua.json exists after make install on FreeBSD.

Soon after I saw this, I was a bit uncertain how to continue, so I asked Grok.

Prompt 3 of 20 (17 remaining).

This is the breakthrough we needed.

Upstream’s analysis is correct

The long comment on your PR (the one that looks Claude-generated) correctly identifies the real root cause:
  • Adjustable.Container (and other code) calls loadTranslations("AdjustableContainer").
  • That function looks for JSON files under translations/lua/ (first relative to the source tree, then under luaGlobalPath .. "/translations/").
  • On a normal make install for UNIX (including FreeBSD and Linux distro packages), those JSON files are never installed. Only the macOS bundle copies them.
  • Result: loadTranslations returns nil → self.Locale is nil → Geyser crashes.
The .qm / Qt resource embedding issues we spent so much time on are a separate (and still real) problem for the GUI language, but the Geyser crash is caused by the missing Lua JSON translation files.

The proper fix (recommended by upstream)

Add this install rule (in src/CMakeLists.txt or equivalent):
cmake
install(DIRECTORY "../translations/lua/"
        DESTINATION "share/mudlet/lua/translations"
        FILES_MATCHING PATTERN "*.json"
        PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
			
After install you should have:
  
/usr/local/share/mudlet/lua/translations/mudlet-lua.json
/usr/local/share/mudlet/lua/translations/translated/...
			

How to do this in the FreeBSD port (no CMake patch required)

The easiest and cleanest way for the port is a post-stage (or post-install) rule in the Makefile. Add something like this:
make
post-stage:
	@${ECHO_MSG} "==> Installing Lua translation JSON files"
	@${MKDIR} ${STAGEDIR}${PREFIX}/share/mudlet/lua/translations
	@${CP} -Rp ${WRKSRC}/translations/lua/* \
		${STAGEDIR}${PREFIX}/share/mudlet/lua/translations/ 2>/dev/null || true
			
(Adjust the source path if your work directory layout is different.) Then rebuild/reinstall and verify:
sh
ls -l /usr/local/share/mudlet/lua/translations/
ls -l /usr/local/share/mudlet/lua/translations/mudlet-lua.json
			
If those files exist, start Mudlet and the Geyser nil-Locale error should be gone without any Lua safety-net patches.

Next step

  1. Add the `post-stage` rule above (or the CMake install rule if you prefer a patch).
  2. Clean rebuild + install.
  3. Confirm the JSON files are present.
  4. Test Mudlet (especially the tutorial / any AdjustableContainer UI).
Would you like me to give you the exact Makefile snippet tailored to your current port layout, or a ready-to-apply `files/patch-src_CMakeLists.txt` instead? This is the clean, upstream-friendly solution.

I really only asked Grok for clarity or to give myself a moment to digest the information, the patching I needed to do was already provided, I simply had some uncertainty.  Since I already knew that this should be an upstream change and that it affects more than just FreeBSD, what I chose to do was simply edit the src/CMakeLists.txt file as mentioned in the comment to the commit.  I found the most appropriate location, directly inside of a conditional for Unix builds.  I copied and pasted it in, then created the patch.  I cleaned up and removed any other patches for the unofficial -dev port and set it to build.

After a while, and a few rebuilds to be sure the pkg-plist would be complete, it was finished.  I had made the adjustements and did the build in a clean jail that had only its necessary dependencies installed.  Once I created a fresh pkg-plist, I went outside of the jail to build and install on my system for testing.

The pkg-plist file I had generated already proved that the needed file to check for would be installed.  I built and installed a new mudlet on my system, then tested the client.  When I chose the mudlet tutorial, everything worked as it should, no complaint about locale and a broken UI.

Now mudlet upstream will soon correct the issue.  Technically I did do a pull request with the suggested fix but since I am a such a "great expert" with github and only somewhat better with git itself, it was closed and upstream will need to figure it out.  I am not going to add further noise by my git skills.  Git frustrates me with regard to backing out of commits, merging the whole mess I have on my end to upstream without my desire, and how I don't truly understand much of git or github.

We can now truly celebrate.  Before games/mudlet has even been added to the FreeBSD ports tree, it will be able to succeed with building, installing, and functioning for its GUI.  Right now my unofficial -dev port has a patch for the src/CMakeLists.txt file, but when upstream updates I can eliminate it.  As many have said, as I have repeated myself a number of times, it is best to contribute a FreeBSD patch to upstream so that it will be fixed properly by them and we can do away with our maintaining of patches.

Friday, May 7, 2021

Interim patches

Patches should be interim fixes only.  How can FreeBSD ever be a recognized full member of the UNIX world if it always hides in the shadows, repairing for itself the linuxisms or other broken upstream code instead of communicating?  Even without making our presence known, telling upstream of our difficulties due to our distinct methods and organization, we can use the same mechanisms which upstream uses to adjust our build without need of patches.  One example is cmake, it is possible to discover the options provided by upstream to modify the build in various ways, to provide paths for dependencies, to enable or disable options.  We force the issue by reminding upstream that we are a consumer and by them providing flexibility which we can use to adapt their build without patches, or by their inclusion of our patches, if those developers listen and are open to such changes.

Aside from my personal distaste for patches because of what I just mentioned, I also strongly favor our own options framework within the ports system to expose all or most build options.  I am okay with our public FreeBSD repo providing packages which are built using the most universally compatible defaults and among them the most used options as defaults.  However, we should not remove choice from our users.  There may be reasons to build with bundled software even if it may not be the best choice generally.  There are sometimes incompatibilities between ports which if installed together conflict due to dependencies in unique ways.  Choosing the less pleasant or potentially dangerous bundled software dependency can be the work-around in that situation.

FreeBSD should have within its ports system, as many of the non-bundled versions of any necessary dependencies as possible, but they and all the other ports should also be able to be configured in ways that conflicts do not force the need of any bundled dependency.  Maintaining ports may be a bit of effort and adding additional options exposure for their users may increase the work involved, but it should not be the reason to avoid it.  We cannot know for certain that any group of ports must conflict among themselves or their dependencies if we limit build options.  Beyond the flexibility which may be offered by exposing more options, this exploration and investigation may determine that build options which upstream provides might not affect the actual build except to force dependency attachments.  We need to take care that minimal builds can be configured, that dependencies are known and our own dependency system handles them exclusively or in concert with those caused by any upstream build option.

We have a rather extensive make system for our ports which is reasonably documented.  This collection of shortcuts in /usr/ports/Mk helps streamline many things, formalizes standards in a sort of macro form.  When and where it is possible it should be a choice for ports users whether to suffer the bulk of a dependency collection or be able to limit them.  Simply because KDE or GNOME or any other desktop provides a rather tightly integrated group of desktop environment with applications does not necessarily mean that it all must be installed in bulk.  If it is possible to pick and choose constituent parts, such as kate exclusive of KDE or some other utility exclusive of GNOME, this should be made as a separate port or port flavor.  For many possibilities we already have much of the mechanisms to handle situations or desires like this but for simplicity or assumed default user choices we might not provide them.  Any META port should not simply be a way for dependencies to be tied together for a one-step port install, especially something like KDE or Lumina, but also should provide options which permit the selection among those individual meta parts.

We recently extricated base from GPL code, this is a success long in coming but it also truly should not have ever been a necessity, the inclusion not the removal.  Why do we not have more BSD licensed ports?  Why do we wait for any various thing to be developed in or for Linux distros and then we adopt it as a port, not as upstream provider but as a consumer depending upon the whims of developers which are not required to ever acknowledge us?  We can do better.  We are not devoid of creativity or skill or developers who could accomplish the same things for FreeBSD or any other BSD as those coders do for the Linux consumers.  What is our limitation?  Yes, FreeBSD is slow to change and does not chase after the most recent shiny, but can we develop a new shiny object?  It does not need to be a part of base and must not be widely adopted in order to be useful.  Perhaps we need a focus on FreeBSD innovation, to point out and point at those new bits of code, those new applications we develop on FreeBSD as upstream, and not simply give up to hand it over to those who would enjoy maintaining it and improving it as an awesome GPL licensed hit.

Whether avoiding patches or creating new code, we in our BSD world need to make ourselves known.  We must communicate.  We must not simply be silent consumers feeding from the Linux engine.  We should be recognized, we should be present on operating system statistics distinct from Linux.  We can assist in maintaining the FreeBSD specific parts of any application that chooses to include us as a unique consumer.  We will never be supported if we hide in the shadows, pretending to be Windows or Linux because any mechanisms fail us when we claim our actual operating system designation.  It always begins as feedback to the developers, or resellers, providers; or we can remain a subsidiary of Linux development as a sort of leech on their continued successes.

Frequently viewed this week