Why is eeschema deleting components from -cache.lib without being asked?

Hi

Wishing to migrate to KiCad, I’ve imported several boards from Altium (using altium2kicad) and it seems to have worked well enough. Trouble is, first time I make a save of any of the boards in KiCad, eeschema appears to delete two items from -cache.lib (named “Cap” and “Res2”) so that the next time I open the .sch these components are missing and do not render.

I’ve tried changing the names, it made no odds. I’ve tried using DRAW code from another component (that does not get deleted), it still got deleted. I’m happy to hack the files about to get these things imported, but I can’t see what I’m doing wrong, or perhaps what eesschema is doing wrong. Can anyone help, please?

I will look for an attach option, to offer the .pro/.sch/.lib full set, but in case I don’t find it, here is one of the components being deleted:

Cap

DEF Cap IC 0 40 Y Y 1 F N
F0 “C” 190 10 60 H V L BNN
F1 “XC6SLX9-2CSG324C_1” 0 0 60 H V C CNN
F2 “” 0 0 60 H V C CNN
F3 “” 0 0 60 H V C CNN
DRAW
X 1 1 -100 -100 100 R 1 1 0 1 P
X 2 2 200 -100 100 L 1 1 0 1 P
P 2 0 1 10 70 -20 70 -180
P 2 0 1 10 30 -180 30 -20
P 2 0 1 10 0 -100 30 -100 N
P 2 0 1 10 100 -100 70 -100 N
ENDDRAW

And here is an entry using it in the .sch:

$Comp
L Cap C15_2
U 1 1 5982030C
P 2600 5800
F 0 “C15_2” V 2610 5610 60 0000 R TNN
F 1 “” H 0 0 60 0001 C CNN
F 2 “” H 0 0 60 0001 C CNN
F 3 “” H 0 0 60 0001 C CNN
1 2600 5800
0 -1 -1 0
$EndComp

There are many such entries, and all fail to render (presumably not a surprise) after the Cap component has been deleted from the .lib.

Thanks for any help!

EDIT: New users cannot upload attachments, so I hope the above is enough info.

I hope you are not adding components to -cache.lib with library editor (or other means)?

If Cap is a component you created yourself, you should put it in a library, e.g. “user.lib”, but not cache lib. Then add user.lib to the library list.

Generally speaking, you should not touch -cache.lib. It has a use when you want to archive or export a project to another system, which might not have the original libraries.

1 Like

Thanks for the reply, bobc. No, -cache.lib was created at import by altium2kicad - clearly, I have no idea if it’s made a wise job of creating that file or not, but I’ve changed nothing, just opened the resulting .sch/.lib pair in eeschema, done a save, and seen the items disappear. Once I get the projects safely imported to KiCad, I’ll set about understanding how to normalise the components to use KiCad’s own libraries, I guess.

Any idea why they are being disappeared, then?

Cheers

Really?? That sounds like a bug, it should not be creating -cache.lib. I would rename -cache.lib to “project.lib” before opening the schematic, then add project.lib to the library list.

Yes, because they don’t exist in any library on the list. You should regard -cache.lib as a write-only file for private use of KiCad.

edit; I looked at https://github.com/thesourcerer8/altium2kicad, it’s definitely a bug now, but it’s quite possible it worked 3 years ago when that code was written. KiCad changed quite a lot since then.

2 Likes

Library management is one of the biggest sore legs of KiCad.
(I’m not sure) but I think that the “-cache.lib” was created as a temporary fix to at least be able to not lose half of your schematic components if the “official” lib’s happen to be updated / changed / etc.
I think (again, not sure) that there is better library manament coming in KiCad 5 but that seems to have been delayed by half a year or more.

The workaround suggested by bobc workst reasonably well for me also.
Rename …-cache.lib to project.lib and add that to the top of the list in EEschem.
EEschem -> Preference -> Component Libraries -> Insert => [Browse], Open.

The list with “component library files” is searched for components in the order that the libraries are listed. You want to put your own library on the top of the list.

If KiCad re-creates the -cache lib you can copy those components to your own lib with the library editor [Ctrl +e] or with a text editor and then delete the remains of the -cache lib again.

Thanks both - that’s very helpful. I’ll try moving the offending items to my own library, then.

Cheers