Specify version of custom library in dependencies of another library's json manifest

I should start off by saying that I am new to using PlatformIO.

Problem Definition
I have developed several custom “libraries” for a ESP solution. These libraries are on GitHub. There is a dependency of one on another - the “Switch” library uses the “Timer” library (and others).

|-----> Timer#~v1.0.0

I would like to be able to specify the version of the Timer library used by “Switch” in the library json manifest under “dependencies”.

I have been able to make it work without version specifications, but can’t quite get the syntax to work with version.

What I have done to-date

I have setup 3 releases of library “Timer” in GitHub (which I’m new to too!) with tags v1.0.0, v1.0.1 & v1.0.2.

What works
But does not specify version.
Switch library manifest:

  "dependencies": {      
    "MQTTClient": "https://github.com/*myUsername*/MQTTClient.git",
    "Timer": "https://github.com/*myUsername*/Timer.git",
    "MUX_TCA9539": "https://github.com/*myUsername*/MUX_TCA9539.git"

I’ve tried several options to specify the version with no success - example follows.

What doesn’t

  "dependencies": {      
    "MQTTClient": "https://github.com/*myUsername*/MQTTClient.git",
    "Timer": "https://github.com/*myUsername*/Timer.git#~1.0.0",
    "MUX_TCA9539": "https://github.com/*myUsername*/MUX_TCA9539.git"

I get the following error.

Library Manager: Switch@1.0.0+sha.0d62ac4 has been installed!
Library Manager: Resolving dependencies...
Library Manager: Installing git+https://github.com/*myUsername*/Timer.git#~1.0.0
git version 2.45.2.windows.1
Cloning into 'C:\Users\user\.platformio\.cache\tmp\pkg-installing-8c8fozly'...
warning: Could not find remote branch ~1.0.0 to clone.
fatal: Remote branch ~1.0.0 not found in upstream origin
VCSBaseException: VCS: Could not process command ['git', 'clone', '--recursive', '--depth', '1', '--branch', '~1.0.0', 'https://github.com/*myUsername*/Timer.git', 'C:\\Users\\user\\.platformio\\.cache\\tmp\\pkg-installing-8c8fozly']

 *  The terminal process "C:\Users\user\.platformio\penv\Scripts\platformio.exe 'run', '--environment', 'nodemcuv2OTA'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it.

I’m hoping that it is a simple syntax error on my part or I haven’t setup the versions correctly in GitHub.

Any assistance will be much appreciated.

The tag must not contain the “v” in front of the version number!
See “Semantic Versioning” in version — PlatformIO latest documentation

1 Like

Many thanks for that @sivar2311 - changing the Tag names to exclude the “v” partially worked (I feel a bit silly not to have tried it). It was the GitHub release creation page that recommended the format (ie. inclusion of “v”) and so I didn’t doubt the suggested good practice!

By removing the “v”, I was able to specify a particular release (say version 1.0.3), however, the “~” and “^” symbols didn’t work. Have I missed something in setting up the releases in GitHub - this is probably a vague question as I guess there could be many reasons this is occurring.

A very big thank-you to you, once again, for assisting me with the solution.