From 7ba290dbdfc8019af353b2662f4474c7bcbc69e5 Mon Sep 17 00:00:00 2001 From: Bruno Dias Date: Fri, 28 Mar 2025 18:40:05 -0300 Subject: [PATCH] fix(clib-install): check if version was specified when installing. the names was used when writing the dependencies which causes this $ clib install package@0.1.0 is written on json as "package@0.1.0": "0.1.0" --- src/clib-install.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/clib-install.c b/src/clib-install.c index 451c3091..f62b7fb8 100644 --- a/src/clib-install.c +++ b/src/clib-install.c @@ -306,7 +306,15 @@ static int install_package(const char *slug) { } if (0 == pkg->repo || 0 != strcmp(slug, pkg->repo)) { - pkg->repo = strdup(slug); + char* version_char = NULL; + // NOTE: check if version was specified + if ((version_char = strchr(slug, '@')) != NULL) { + size_t length = version_char - slug; + pkg->repo = malloc(sizeof(char) * length); + memcpy(pkg->repo, slug, length); + } else { + pkg->repo = strdup(slug); + } } if (!opts.nosave) {