-- Leo's gemini proxy

-- Connecting to gemini.hitchhiker-linux.org:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini;lang=en-US

Some things I found while resurrecting a Void installation

2024-02-04

My more powerful laptop is a 2017 Dell gaming rig with an i5 and Nvidia graphics. I got the thing used when my daughter, who at the time was attending a posh private school on scholarship, snagged it from being thrown in the trash by a friend because it was too old and beat up. I've since added ram, bringing it up from 8 to 32GB, making it my goto device when I need to compile something beefy or want to do some gaming (rare, but sometimes). I set up this machine as a dual boot, with Void Linux (musl libc edition) and FreeBSD.


Well I did mention the thing is old, and pretty beat up. A few months back the battery completely died. It will run off wall power, so to me it's not completely clapped out yet, and not having much money to go around I haven't replaced the battery. Besides, if I can avoid buying another battery that's a small win for the environment anyway (I tell myself to help justify being cheap). Well it turns out that on this machine, bad things happen when power is lost. One of those bad things is that the bios loses all of its uefi entries and you have to boot up a rescue usb stick to fix it with something like `efibootmgr` or the like. After the third time, I got lazy and only fixed the FreeBSD installation, leaving Void to rot for a while. A couple days ago, I resurrected the Void installation.


No real surprise, but Void being a rolling release there were a -lot- of updates. So that took a hot minute. While that was going I took some time to pull in changes on some of my software projects and see how they fare with musl libc, which is part of the reason I like keeping this installation around. I found a few bugs this way actually. Some fun little libc quirks and gotchas that hadn't shown up previously on either FreeBSD or Linux with Glibc. One of the obscure ones revolved around determining whether a file exists. A lazy method is to use `access` from `unistd.h`, and this works fine, until you encounter a symlink. In this case, the symlink is dereferenced to it's target. The bug this caused had to do with why I was checking for the link's existence. I needed to know if it was there so that if it was I could remove it before re-creating it with the correct target. As it turns out, Musl libc is the only libc that cares whether a symlink already exists before you try to create it, so I only got the error on Void.


The fix, in this case, is using `lstat` instead of `access` and just checking the return code.

struct stat st;
char *path = "some/path";

if (lstat(path, &st) == 0)
    unlink(path);

The dark side of Lua

A while back, sometime after my Void install stopped booting, I had tried out the Helix editor and found that I really liked it. In comparison with NeoVim, it did almost all of the same things but it did them without a bunch of extra configuration and/or plugins. About the only thing I had NeoVim configured to do that I can't do with Helix is run Git operations directly in the editor, and it's easy enough to do that in a terminal anyway. Well, I still had `nvim` set as `EDITOR` in my environment on Void, and as it turns out there was a lot of churn in the plugins I was using. I probably would have been fine if I hadn't tried to update them, but without really thinking about it I di the whole `:PackerUpdate` and watched as error messages began appearing. Sure enough, after restarting the editor I got a bunch of errors while it tried in vain to parse my carefully crafted init.lua, and some things I have really gotten used to no longer worked. One of the most frustrating broken parts was the Telescope plugin, which I've come to rely on as a file chooser.


Well it wasn't terribly hard to fix. They did follow proper semver and all, so I can't be too mad about it, but I don't really think a configuration file for my editor is a good place for me to have to worry about such things. It's definitely soured my opinion on the entire Lua plugin system. When I fire up my editor I expect it to work. I don't want to even think about it, I just want to get work done. So even though it's working again I might switch over to Helix on Void as well.


Tags for this page

Void

editors

Linux

libc

programming


Home

All posts


All content for this site is licensed as CC BY-SA.

© 2024 by JeanG3nie

Finger

Contact

-- Response ended

-- Page fetched on Mon May 20 10:17:09 2024