Command error. Return code 11 to generate BOM


I’m a newbie here. Right now, I tried to follow all the instructions from the tutorial in pdf file. However, I am facing some problem here to generate the BOM file. Below is the error that I’m facing right now. I tried to follow the suggestion from the other post about this error but still stuck at this problem. I don’t know what else to do.

Run command:
xsltproc -o “C:/Users/Muhamad Affiq Misran/Documents/KiCad/tutoriaal1” “C:/Program Files/KiCad/bin/scripting/plugins/bom2csv.xsl” “C:/Users/Muhamad Affiq Misran/Documents/KiCad/tutoriaal1.xml”

Command error. Return code 11

Error messages:
I/O error : Invalid argument
I/O error : Invalid argument

Thank you and sorry for the inconvenience.


first thing to check for is [space] in paths… I see your user name has two of these.
Any chance you can test this with a USB stick (in case all you got is C:) as a base drive for the input and output path, as you need write access?

1 Like

Hi Joan,

Thank you for your reply. So did you mean I need the bom2csv from the C to be saved in the USB stick and also the project I have done also?

For a test yes.
Have no other idea.
If no one else chimes in with more experience in that area…

Doesn’t windows use backslash “” in the path string instead of forward slash “/”?

I would put money on it being spaces in the paths. Ideally, put everything in places that don’t need spaces.

It’s little known but all paths in windows still have an 8.3 name, but I think the only way to see it is to use a DOS prompt and “dir /X”. The 8.3 name can be substituted for the parts containing spaces.

Another option is to install a different XML processor, e.g. Saxon BOM generation in "new" Kicad (Windows)

Or use a Python tool to generate the BOM KiBoM - Python BOM Generation tool

Or generate bom from pcbnew Fabrication Outputs->BOM File

The answer to that is “it depends”. If the path is in double quotes, most applications will handle / the same as “”. If the path is not in quotes, / may be confused with argument separator, again depends on application.

There are a few Unix applications ported to Windows that do not support , and need /.

LOL, my \ got swallowed. Computers, tsk.

Also, is your test project really called “tutoriaal1”?

He could use build in variables.
%P: path of the project
%I: xml file generated by bom tool
xsltproc -o “%Poutput_file_name” “C:/Program Files/KiCad/bin/scripting/plugins/bom2csv.xsl” “%I”

I think the tutoriaal1 could be the directory of the project. Not the output file (you can’t overwrite a directory with a file)

Yup…its tutoriaal1…hehehe

hi bobc,

I already go through “e.g. Saxon BOM generation in "new" Kicad (Windows)”…but there is still some error which i don’t understand. Maybe it is because the [space] that cause the error.

It seems that xsltproc is sensitive in the first (output file) parameter only, the second and third parameters it accepts \ or /, and embedded spaces. “error 11” is an error specific to the output file.

If you do not use a path, you can have spaces in the name e.g.

xsltproc.exe -o “my bom.csv” “C:\Program Files\KiCad\bin\scripting\plugins\bom_cvs.xsl” “c:/git_bobc/webradio/hardware/test_main/test main.xml”

If you use a path in the first parameter, it must use / and not contain spaces e.g

xsltproc.exe -o “c:/temp2/mybom.csv” “C:\Program Files\KiCad\bin\scripting\plugins\bom_cvs.xsl” “c:/git_bobc/webradio/hardware/test_main/test main.xml”

The following do not work

xsltproc.exe -o “c:\temp2\mybom.csv” “C:\Program Files\KiCad\bin\scripting\plugins\bom_cvs.xsl” “c:/git_bobc/webradio/hardware/test_main/test main.xml”
xsltproc.exe -o “c:\temp2\my bom.csv” “C:\Program Files\KiCad\bin\scripting\plugins\bom_cvs.xsl” “c:/git_bobc/webradio/hardware/test_main/test main.xml”
xsltproc.exe -o “c:/temp2/my bom.csv” “C:\Program Files\KiCad\bin\scripting\plugins\bom_cvs.xsl” “c:/git_bobc/webradio/hardware/test_main/test main.xml”

Additionally, you must specify a filename for the output parameter, a directory is not enough

* Tested on Windows 7


Hello everyone,

I managed to solved it by transferring all the files from the project and also the bom2csv file into my USB stick as Joan’s recommendation. But for future project, do I need to do the same steps again?

As long as that particular bug/error exists in the code of whatever it is that you’re using, yes.
The ‘solution’ of putting the involved files onto a USB stick and having simple, short path’s points to what @bobc wrote about path handling.

It’s up to you (and others who have this problem) to try and chase that bug down (make it repeatable for certain conditions, like there is a [space] in the path somewhere) and write a bug report for the developers to work with.
If you don’t do that, it will never get fixed.

KiCad bugtracker

Personally I got an extra partition on my HDD which contains data only and have NOTHING in those windows/user folders at all… saves me a lot of headaches.

1 Like

Here is another workaround to solve this issue due to spaces into the path of the first argument with Windows 10.
Use a symbolic link to create another path without spaces:
in a command window to run as administrator type the following:

cd /d D:/
mklink /D DocumentsBertrand “Documents Bertrand”

Now you can use the commnd

xsltproc -o “E:/DocumentsBertrand/Kicad/Tutorial1” “F:\Program Files\KiCad\plugins\bom2csv.xsl” “%I”

A drawback is that’s not possible to use “%O” as first argument, but nowt the command works for me.

At the moment I’m working on my first design in KiCad. I’m quite new to the world of PCB design, though hardly new to electronics – I’ve lived and breathed electronics for the entirety of my existence. I am perplexed at how the rest of KiCad, while occasionally (okay, often) quirky, seems to be easy to pick up and generally “just works,” but the BOM generator tool resorts to the command line and doesn’t work out of the box! (But it’s free, so I’m not complaining, just pointing out an inconsistency/weakness which could use some attention.) :wink:

Anyways, I was contemplating symbolic links, but that seemed too complicated. I kept getting nothing but error 11, and out of desperation signed up to this forum! And then I figured out a solution by piecing together various answers above, and so I’ll share it. Giving back, you know?

xsltproc.exe -o “C:\Users\[username]\Desktop\[file_name].csv” “C:\Program Files\KiCad\bin\scripting\plugins\bom2csv.xsl” “%I”

The above worked for me. Note that I added “.exe” to the command, and neither my username nor my file output name had spaces. I am simply astonished that – in 2017 – Windows is incapable of handling spaces in file paths. Do any of you know if the BOM generator works out of the box on Linux/Mac, unlike the experience on Windows?

1 Like

Without looking at the code that handles this, Id bet $10 this has to do with how it parses paths and not that this program runs on windows.
This is a matter of someone with some programming skills to feel the need that this needs to be solved, finding some time to get accustomed to how KiCAD (or this script in particular) is programmed, change it, test it, publish the work on the dev mailing list as a pull request, add some more time as feedback comes in and regression bugs enter the scene and finally someone to merge it with the main trunk so it can be part of the nightly releases and undergo further testing till at some nice day it turns up in a stable release.

PS: welcome to KiCAD.

1 Like

The space in path only seems to be a problem with the first parameter, not on other parameters, so I think it is something about the port of xsltproc to windows, not Windows per se.

xsltproc is part of libxslt. Someone raised a bug about spaces and the command error 11. With a little digging I found the source code, the command error 11 is generated here
It appears that function xsltRunStylesheetUser() returns -1.

1 Like

Oookay, you lost me there … glad somebody knows what’s going on, though! :smile:

I am working on my second design in KiCad currently and was having this same problem. Your resolution fixed it for me. I used a specific path for the output file name and made sure that there were no spaces. I also added the “.exe” to the end of xsltproc…Success! Thank you!

1 Like