Problems with local libraries in workbench / particle-cli


#1

I’m having trouble organizing projects with my local libraries. I keep my libraries in one directory and then like to refer to them from my various projects. It seems that’s not currently possible unless I’m missing a trick (quite likely).

I do not want a copy of each library in each project because that creates a maintenance nightmare. I also do not want to publish my private libraries to the particle library system, it’s not appropriate.

What I’d like to have is all libraries in one libraries directory and then symlinks from each project to the libraries it uses. Here is an example of how this would look like:

root/
+- libraries/
|    +- Library1/
|    |   +- lib1.cpp
|    |   \- lib1.h
|    +- Library2/
|    |   \- src/
|    |       +- lib2.cpp
|    |       \- lib2.h
|    \- ...
+- project1/
|    +- project.properties
|    +- src/
|    |   +- proj1.ino
|    +- lib/
|    |   +- Library1 -> ../../libraries/Library1
|    |   +- Library2 -> ../../libraries/Library2
+- project2/
|    +- project.properties
|    +- src/
|    |   +- proj2.ino
|    +- lib/
|    |   +- Library1 -> ../../libraries/Library1

I dug around in the code and the reason this is not possible (specifically if the library has a src directory as shown for library2) is that the node.js glob used by globList in utilities.js does not recurse into symlinked directories (globList is called by _processDirIncludes). It’s actually very confusing because it does pick up source files in the top-level of the library directory but not ones further down, so library1 in my example works but library2 doesn’t.

Is there some trick to get around this issue, e.g. something I can stick into the project.properties file to point to the libraries?


#2

What OS?
Would hard links or junctions be an option?

I don’t know whether the multi-workspace feature would help - maybe @m_m can help.


#3

OS: Linux
I could perhaps use loop mounts, but that just doesn’t seem like the right solution…


#4

Hardlinks are almost never a good idea. Just don’t.


#5

… the node.js glob used by globList in utilities.js does not recurse into symlinked directories ( globList is called by _processDirIncludes ). It’s actually very confusing…

Node, in general, has issues recursing into directory symlinks. I’ve run into this issue before with WebPack / Babel / Grunt. The more I learn about how particle manages libraries, the less keen I am on this whole system.