Simulation .include path with apostrophe?

New Kicad user here (but experienced with other PCB cad tools), sorry if this has been covered somewhere. I checked the FAQ but couldn’t find it.

Building a simple circuit with one Q that needs an external model. The generated spice netlist includes a .include in which the pathname includes spaces and an apostrophe, abstracted here:

.include “\xxxx\yyyy\zzzz’s Documents\Home Repair\PWB Tools\zzzz’s Kicad Projects\AMP_eg\BC546.lib”

Simulation gives: “Error: Could not find include file \xxxx\yyyy\zzzz”

Some googling suggests that the use of spaces in path names was a Kicad issue long ago but has been solved. Noting that my error message truncates just before the apostrophe, I’m asking if an apostrophe in the pathname is causing problems with the netlist parser.

Thanks for your help.

PS: I am an old Unix guy and understand that an apostrophe can cause these kinds of problems. But this pathname is fairly entrenched on my multi-user Win 10 system and will be hard to change.

The error message suggests that this is not a KiCad issue but caused by ngspice.

I will have a look.

1 Like

Persnonally I do not use file names and paths with spaces in them. Partly to prevent possible errors, and partly because such paths are harder to use from the commandline.

But if you suspect “weird” characters in a path name is an issue in a project, then simply make a copy of that project into a “simplified” location and test for differences.

Yes, I was thinking of doing that, I will post back my results. At least I know for now I am barking up the right tree.

Also, I believe that if I only have a few models, I can include those directly on the schematic with a .model directive, and so long as I invoke no libraries via the eeschema menus the spice netlist will avoid any “.include PATH” directives. Is that correct?

Yes, it is the apostrophe that is causing the problem.

Have you looked to see if there is a way to escape the apostrophe (or any other confusing-to-the-parser character) in the input to Ngspice? I don’t know the answer, just checking to make sure you’ve thought of this as well.

Due to a bug in ngspice the parser did not distinguish between " and ’ quotes. The string started with a ". The parser began running along the string until the end quote, which he erroneously found in the first occurence of a '.

This bug has been fixed. After some further testing it will be pushed to the git pre-master branch, the ngspice development branch. The fix will be available with ngspice-34. Unfortunately it will take some time then until this fix will be available with KiCad. So I will make an ngspice for KiCad update available from our ngspice download web page. It may take a few days, I will give you a note here.

Many thanks for the report!


You are welcome for the report, and I am truly impressed by your response…

Now, back to work learning the nuances of building a layout in eeschema.


As long as your .model is a single line, it will work. There’s an Eeschema bug that won’t let you do multi-line .model and .subckt statements.

I think it’s good practice to put copies of each SPICE .lib used in your project into your KiCad project folder. Then when you set up your SPICE options for each schematic symbol, browsing for them will end up using a relative path, which will avoid your path problems. Also, if you send your project folder to someone else all the paths for the SPICE models will stay valid and they’ll have all the required files to run the simulation too.

1 Like

Copy that. I forget about this sometimes.

I assume the single line constraint is because of a parser. Seems like though, I should be able to have multiple .model directives on the schematic provided each one meets this constraint. After all, there might already be other directives on the schematic.

I guess that leads me to another question: what constitutes the boundaries of the schematic for purposes of including directives? Are directives outside of the drawing sheet boundaries pulled into the simulation? I wonder how this works for schematics with multiple sheets. I will probably be testing these cases as I continue to work with the software, but advanced info will keep me from going down the wrong path.

ngspice expects the .model … statement to be a single line. If you have a look at the BC546.lib, you will see that.

ngspice allows to spilt a line into several lines by beginning any consecutive line with a + in the first column. It may happen however that the Eeschema processor will not recognize this feature and thus does not transfer it into the Netlist. Yo may test this (I am not sure).

If you don not want to spoil your diagram area with lots of model lines, you may put all .model lines and also any subcircuit model (.subckt model name … .ends) into a single file mymodels.lib and include this with a single .include mymodels.lib statement.

1 Like

The (+) was what I was referring to, but looks like I was mistaken (my bad; thanks for questioning) and it just applies to .subckt (so heads up @Mediser). Which, by the way doesn’t matter since it looks like the bug fix is already in. I could’ve sworn it was waiting to be merged into 6.0, but looks like that changed or I simply don’t understand how software dev on this project works.

Yes, it was. See link above.

There are no boundaries for this as far as I know. You can put the directives outside the “sheet”. I don’t know enough about multiple sheets, so I cannot answer that.

There is a “update” for ngspice (Windows 10 only, sorry) available at .

It contains all bug fixes (including this one on " and ’ ) up to today. It is experimental code, but stable enough to give it a try. A howto ist included in the zip file.

1 Like