# Should the vendor/ directory of the C++ client be optional?

**URL:** <https://hub.mender.io/t/should-the-vendor-directory-of-the-c-client-be-optional/6451>\
**Category:** General Discussions\
**Created:** [January 9, 2024, 7:59pm UTC](https://hub.mender.io/t/should-the-vendor-directory-of-the-c-client-be-optional/6451 "2024-01-09T19:59:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aduskett](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@aduskett](https://hub.mender.io/u/aduskett)\
**Post date:** [January 9, 2024, 7:59pm UTC](https://hub.mender.io/t/should-the-vendor-directory-of-the-c-client-be-optional/6451/1 "2024-01-09T19:59:02Z")

</div>

Currently, [there is a vendor/](https://github.com/mendersoftware/mender/tree/master/vendor) directory in the mender C++ client source code, and building them is required.

However, it may be best to make those dependencies optional, as both Buildroot and Yocto provide their own

[expected](https://github.com/TartanLlama/expected):

- Buildroot: [tl-expected](https://gitlab.com/buildroot.org/buildroot/-/tree/master/package/tl-expected)
- Yocto package: I couldn’t find one, but it would be trivial to make a .bb file.

[json for modern c++](https://github.com/nlohmann/json):

- Buildroot: [json-for-modern-cpp](https://gitlab.com/buildroot.org/buildroot/-/tree/master/package/json-for-modern-cpp)
- Yocto: [nlohmann-json](https://git.openembedded.org/meta-openembedded/plain/meta-oe/recipes-devtools/nlohmann-json/)

[lmdbxx](https://github.com/hoytech/lmdbxx/):

- Requires the [lmdb](https://github.com/LMDB/lmdb/tree/mdb.master/libraries/liblmdb) package.
- Buldroot: No package lmbd or lmdbxx package, but both are trivial to add.
- Yocto: No lmdbxx package, but there is a [lmdb package](https://git.openembedded.org/meta-openembedded/plain/meta-oe/recipes-dbs/lmdb/) trivial to add as a recipe to the meta-mender project.

[optional-lite](https://github.com/martinmoene/optional-lite):

- Buildroot: No package, trivial to add.
- Yocto: No package, trivial to add as a recipe to the meta-mender project.

[tiny-process-library](https://gitlab.com/eidheim/tiny-process-library):

- Buildroot: No package, trivian to add.
- Yocto: No package, trivial to add as a recipe to the meta-mender project.

In fact, I have already ported all the packages in vendor/ to buildroot found [here](https://github.com/aduskett/buildroot/tree/mender-cpp)

There are many pros and cons to removing the vendored directory, most of which boil down to the maintenance of keeping the packages up to date, the extra size of the vendor packages, and the complexity of compiling them instead of simply depending on them.

---

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [January 9, 2024, 9:13pm UTC](https://hub.mender.io/t/should-the-vendor-directory-of-the-c-client-be-optional/6451/2 "2024-01-09T21:13:06Z")

</div>

Hi @aduskett,

Thanks so much for sharing the idea and even creating an PoC already. As you already pointed out, I can also see pros and cons. Looping in @kacf, who leads the C++ client effort.

Greets,  
Josef

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [January 10, 2024, 3:10pm UTC](https://hub.mender.io/t/should-the-vendor-directory-of-the-c-client-be-optional/6451/3 "2024-01-10T15:10:28Z")

</div>

Thanks @aduskett!

> [@aduskett](#):
>
> Currently, [there is a vendor/](https://github.com/mendersoftware/mender/tree/master/vendor) directory in the mender C++ client source code, and building them is required.
> 
> However, it may be best to make those dependencies optional, as both Buildroot and Yocto provide their own
> 
> [expected](https://github.com/TartanLlama/expected):
> 
> - Buildroot: [tl-expected](https://gitlab.com/buildroot.org/buildroot/-/tree/master/package/tl-expected)
> - Yocto package: I couldn’t find one, but it would be trivial to make a .bb file.

`expected` is in C++23. I don’t think it’s worth making this optional because support for it essentially ended in 2023, and C++23 “takes over” afterwards, which comes with recent g++ versions. We do need changes to actually use the C++23 version though, but this is mostly at the code level, and should be dependent on which C++ standard you use, not on system libraries. See `optional` also.

> [@aduskett](#):
>
> [json for modern c++](https://github.com/nlohmann/json):
> 
> - Buildroot: [json-for-modern-cpp](https://gitlab.com/buildroot.org/buildroot/-/tree/master/package/json-for-modern-cpp)
> - Yocto: [nlohmann-json](https://git.openembedded.org/meta-openembedded/plain/meta-oe/recipes-devtools/nlohmann-json/)

Yep!

> [@aduskett](#):
>
> [lmdbxx](https://github.com/hoytech/lmdbxx/):
> 
> - Requires the [lmdb](https://github.com/LMDB/lmdb/tree/mdb.master/libraries/liblmdb) package.
> - Buldroot: No package lmbd or lmdbxx package, but both are trivial to add.
> - Yocto: No lmdbxx package, but there is a [lmdb package](https://git.openembedded.org/meta-openembedded/plain/meta-oe/recipes-dbs/lmdb/) trivial to add as a recipe to the meta-mender project.

There actually is an `liblmdb++-dev` package in Ubuntu, but it doesn’t work. We already depend on the `lmdb` package in Yocto.

> [@aduskett](#):
>
> [optional-lite](https://github.com/martinmoene/optional-lite):
> 
> - Buildroot: No package, trivial to add.
> - Yocto: No package, trivial to add as a recipe to the meta-mender project.

This is actually optional already, it just isn’t very obvious. If you compile with C++17 or later, then this dependency isn’t used. See [this commit](https://github.com/mendersoftware/mender/commit/87c8fda482082723a3ca2fcf8c9ccc02f515819b).

> [@aduskett](#):
>
> [tiny-process-library](https://gitlab.com/eidheim/tiny-process-library):
> 
> - Buildroot: No package, trivian to add.
> - Yocto: No package, trivial to add as a recipe to the meta-mender project.

Yep!

> [@aduskett](#):
>
> In fact, I have already ported all the packages in vendor/ to buildroot found [here](https://github.com/aduskett/buildroot/tree/mender-cpp)
> 
> There are many pros and cons to removing the vendored directory, most of which boil down to the maintenance of keeping the packages up to date, the extra size of the vendor packages, and the complexity of compiling them instead of simply depending on them.

In general I agree that the dependencies should be optional, for exactly the reasons you mention. But all of them were added as vendored dependencies exactly because they are not easily available everywhere. So it’s not a priority for us to change it, since this approach is what we chose to be maximally compatible. That being said, I certainly don’t think we should stand in the way if others want to put in the work to make them optional.

---

<div class="post-metadata">

**Author:** ![aduskett](https://avatars.discourse-cdn.com/v4/letter/a/7ab992/32.png) [@aduskett](https://hub.mender.io/u/aduskett)\
**Post date:** [January 10, 2024, 3:23pm UTC](https://hub.mender.io/t/should-the-vendor-directory-of-the-c-client-be-optional/6451/4 "2024-01-10T15:23:07Z")

</div>

Thanks for the detailed reply! Making them optional seems like a pretty easy strategy. I can run with that today and tomorrow and make a PR!
