NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.93k stars 13.95k forks source link

KiCad Error/Crash when saving Symbol or Footprint Libraries #347150

Open Bvngee opened 2 weeks ago

Bvngee commented 2 weeks ago

Describe the bug

Apologies if this is repeated/known/user-error. My issue is KiCad erroring OR crashing when attempting to save symbol libraries. This involves simply opening the Manage Symbol Libraries menu, not changing anything at all, and pressing Ok. The observed behavior when pressing Ok is a long pause with the gui frozen (a couple seconds) followed by one of two things (I can't figure out what causes which one): either a simple error dialog pops up saying "File Save Error - Error saving global library table - Permission denied", or the entire kicad gui closes but the process stays open, frozen, and in a loop of consuming cpu and doing nothing. The strace logs (before I kill -9'ed it) in this case are 600,000 lines long of just poll([{fd=3, events=POLLIN}], 1, -1) = 1 ([{fd=3, revents=POLLIN|POLLHUP}]) - not sure what that means. Happy to provide more strace info as well (its clear that during the Ok pause kicad is trying to obtain write access to files in the symbols dir in the nix store, all failing with EACCESS -1 ofc).

All I want to do is add symbols to my library. I don't even care if I have to add them project-local exclusively (like this user did), as I know the symbols are downloaded into the nix store and therefor read-only - but I can't do anything at all if the window crashes before even changing! Note that this does NOT occur with the flatpak

Steps To Reproduce

Steps to reproduce the behavior:

  1. Install kicad-small (haven't tried non-small or unstable yet) for the first time
  2. Open Preferences->Manage Symbol Libraries
  3. Choose the default setting when asked about creating a new global symbol library table
  4. Press Ok, observe

Expected behavior

The program does not error or crash when pressing Ok on the Manage Symbol Libraries menu

Notify maintainers

@evils

Metadata

(tested on two laptops)

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.46-xanmod1, NixOS, 24.05 (Uakari), 24.05.20240828.ae2fc9e`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.5`
 - nixpkgs: `/nix/store/s6d8irfyp66lvy9kapbfp2ass36c8lfl-source`

Add a :+1: reaction to issues you find important.

hacscred commented 2 weeks ago

Did you also follow https://forum.kicad.info/t/creating-a-new-footprint-library/9088?

You sis not specify how you installed it. E.g. via environment.systemPackages?

I am not saying your issue is invalid. (Since, obviously it is valid.)

Bvngee commented 1 week ago

Did you also follow https://forum.kicad.info/t/creating-a-new-footprint-library/9088?

I believe so; I placed the symbol library I wanted to add in ~/dev/projects/my-symbols, and added that exact path to the global library table. I don't believe this is the issue though, since even without adding those symbols the menu still causes the error/crash when pressing Ok.

You sis not specify how you installed it. E.g. via environment.systemPackages?

Good point - the first time I used home manager's home.packages, and the second time I used nix profile install. Lmk if I should try something else!

hacscred commented 1 week ago

I don't recognize any of those installation methods as a valid installation method (other people certainly have different opinions), but you are in luck, since I had KiCad installed.

I can confirm that this is a bug, but I think the real problem is that the UI is basically unusable, because it doesn't say that it will write any file. So, perhaps their manual explains what should happen. I do get that it's applying the substitutions, but to what purpose, I don't know.

I am not that interested in KiCad, but I would imagine that KiCad uses environment variables too, which you might be able to set to control its behavior. I'd say that KiCad is not in fact maintained in nixpkgs, right now, because the basics don't even work...

I would suspect that whoever packaged this never actually used it in this version.

Bvngee commented 1 week ago

I would imagine that KiCad uses environment variables too, which you might be able to set to control its behavior.

That is in fact how the default symbol, footprint, and template libraries are packaged in nixpkgs; their respective repos are cloned to the nix store and kicad is wrapped with KICAD8_SYMBOL_DIR and the other vars set to those store paths respectively. I should probably be able to add to these vars or even .override kicad with the srcs parameter as explained here, but that's way overkill for what I want (quickly add some libraries without bothering with all that).

I would suspect that whoever packaged this never actually used it in this version.

We'll see what @evils says!

evils commented 1 week ago

hey, i've been ignoring a fair bunch of pings about KiCad lately including the one about the 8.0.5 update in part because others seem to respond faster than i could (and because i'm not feeling motivated to work on it lately)

i should note that while i've most likely used KiCad in a way that would have cause this bug, that was probably even before version 7 and my test routine (which i didn't perform on the most recent update(s?)) does not cover checking for this (though that routine does show a 2:1 cursor translation vs cursor movement here) (and i've been having graphics issues with KiCad long enough that i've mostly been waiting for stuff to catch up to wayland before actually putting effort into the package again)

KiCad not always playing well with a read-only path is a known issue (https://gitlab.com/kicad/code/kicad/-/issues/12941)

but i strongly recommend opening an issue with them about this (i don't think it's their intent to modify the library when not even adjusting the active/visible settings...)

hacscred commented 1 week ago

This is basically the problem, I'd say. Still, to actually know exactly what to do, one would either need to read documentation or just copy how their installers on supported operating systems work.

Template files keep their existing permissions. We set these to 644 on supported Linux systems but might be changed by a packager in a different system.

evils commented 1 week ago

the issue i linked is one of KiCad not taking the decision of what mode a file should be in, and in copying it, maintaining the mode that was set by whatever packager installed the file (which conflicts with Nix's read-only mode in the install site)

the issue here is that KiCad is trying to save app state in the footprint library (which with the stock libraries with Nix, are read-only) instead of in ~/.config/kicad or with the project being worked on, or anywhere more appropriate for such state