Environment user-defined variables: how to use them?

Hi,

I am having a problem with Kicad v4.0.1 (also 4.0.0) for both Mac and Windows.
I created some libraries of mine in order to work on a project together with different people, each of them working on they own computer with a git repository.

The structure of the library I created is like this:
/myFolder/Schematic/library_1/…
/myFolder/Schematic/library_2/…

/myFolder/Modules/module_1/…
/myFolder/Modules/module_2/…

and so on.

Then I asked to each person having my libraries to go to Kicad–>Preferences–>Path Configuration and add a new user defined variable named “ERIK_KICAD_LIBRARIES” setting its value to the first part of the path where they have the library (e.g. ERIK_KICAD_LIBRARIES = /myFolder).

I thought that by doing so I would have been able to edit the .pro file this way:

[eeschema]
version=1
LibDir=${ERIK_KICAD_LIBRARIES}
[eeschema/libraries]
LibName1=${ERIK_KICAD_LIBRARIES}/Schematic_symbols/Devices/Devices
LibName2=${ERIK_KICAD_LIBRARIES}/Schematic_symbols/Opamps/Opamps
LibName3=${ERIK_KICAD_LIBRARIES}/Schematic_symbols/Diodes/Diodes
LibName4=${ERIK_KICAD_LIBRARIES}/Schematic_symbols/Power/Power

and having the complete path fully resolved in EESchema.

But apparently this does not work: if I do so, when I load the project in any computer then Kicad says it does not find the paths I have specified.
To me it sounds Kicad cannot understand how to translate the variable I defined in a valid path, as like as it is not able to parse the “${ERIK_KICAD_LIBRARIES}” string.

I really would like to be able to work with Kicad this way, because if I set my local path in the .pro file when I work on the project, everybody else later have to fix it according to the place where they put the libraries on they computer after they pull the project from the git repository.

Am I doing something wrong, or this is a bug?
How can I do in order to use this feature the way I would like?

Thanks,

Erik

I believe that the env var substitution only works in pcbnew related files, not yet in eeschema files. Maybe a future version?

I think the only way is to tell your users to add the explicit path in the project paths for eeschema.

How can I contribute in making this modification happening in a future version of Kicad?
Is there anything I can do?

Best regards,

Erik

Have a look here:
https://kicad.org/contribute/developers/#_getting_started

I would recommend registering to the developper mailing list, then starting by contributing to the documentation repository:

I have just experimented with this since I have a few computers with different configurations that I use for KiCad. At least with version 4.07 it is possible to use environment variables as the OP intended.

Application: kicad
Version: 4.0.7 release build
wxWidgets: Version 3.0.3 (debug,wchar_t,compiler with C++ ABI 1011,GCC 7.1.0,wx containers,compatible with 2.8)
Platform: Windows 7 (build 7601, Service Pack 1), 64-bit edition, 64 bit, Little endian, wxMSW
Boost version: 1.60.0

LibDir is a similar to the PATH variable in that it specifies which folders, semicolon separated, to search for the libraries. What is working for me is configuring the .pro-file like this where KISYSLIB and KIOENGLIB are user-defined variables:

LibDir=${KISYSLIB};${KIOENGLIB}
[eeschema/libraries]
LibName1=power
LibName2=device
LibName3=transistors
LibName4=engineering

So I guess what the OP did wrong was to prefix the libraries with the environment variable.

Terje

Hi, would you give an example of what those variables contain? I am attempting the same, but find

LibDir=${SYSENGLIB}
LibName1=EMP_SYSENG_SYMBOLS
fails when SYSENGLIB has value C:\Users\mgarbutt\Desktop\demo\base_library_clone\symbols

but what does work is
LibName1=C:/Users/mgarbutt/Desktop/demo/base_library_clone/symbols/EMP_SYSENG_SYMBOLS
I have tried substituting / for \ and \ to no avail.

Version: 4.0.7 release build
Platform: Windows 7 Professional Service Pack 1, 64bit

UPDATE:
I CAN get it to work when saying LibDir=${KIPRJMOD}/base_library_clone/symbols, so it appears the SYSENGLIB variable is causing issues. Anyhow, this is a good enough workaround for me.

If you have problems please remember to always add your kicad version information. (Different versions might behave differently)

1 Like

How do you have SYSENGLIB defined?

If you open command line and enter set you should get a list of all defined environment variables

In Preferences -> Configure Paths. I added it as a variable as shown below. I have also tried giving it a full absolute path, so ${KIPRJMOD} is not in its given value, but this didn’t work either. Don’t think that’s an issue though, as the KICAD_PTEMPLATES variable works fine.

I am not certain but I don’t think whole Kicad has been changed to support only variables defined within Kicad. I think that you need to define variables used by eeschema as a true environment variables (Control Panel\System and Security\System\Advanced system settings\Enviroment Variables

Interesting, so it seems a true environment variable takes priority unless the variable is later changed in KiCAD, at which point it has the changed value for that project only. Does that sound right?