Skip to content

Commit 36111b5

Browse files
authored
fix(dev): fix issues when using container tools and cargo is not installed locally (#18112)
* fix(dev): fix error in `make` when `cargo` is not installed Fixes the following error when using `make environment`: make: cargo: No such file or directory Signed-off-by: Hugo Hromic <[email protected]> * fix(dev): fix `build` make target when `cargo` is not installed Fixes the following error when using `make build ENVIRONMENT=true`: Makefile:212: *** "Please install Rust: https://www.rust-lang.org/tools/install". Stop. Also switch to using `command` (POSIX compatible) instead of `which` for detecting `cargo`. Details in <https://mywiki.wooledge.org/BashFAQ/081>. Signed-off-by: Hugo Hromic <[email protected]> * fix(dev): fix detection of container tool in `make` Fixes the following error when `ENVIRONMENT=true` and neither Docker or Podman are available: make: podman: No such file or directory make: *** [Makefile:174: build] Error 127 Podman was being used as fallback even if also not available. A descriptive error is now reported instead in this situation. Signed-off-by: Hugo Hromic <[email protected]> * chore: add `ifneq` Makefile keyword to spell checker allow-list Signed-off-by: Hugo Hromic <[email protected]> --------- Signed-off-by: Hugo Hromic <[email protected]>
1 parent e6f2ccc commit 36111b5

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

.github/actions/spelling/allow.txt

+1
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ https
319319
humungus
320320
icecream
321321
ifeq
322+
ifneq
322323
imobile
323324
influxd
324325
ionik

Makefile

+17-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ export VERBOSE ?= false
3434
# Override the container tool. Tries docker first and then tries podman.
3535
export CONTAINER_TOOL ?= auto
3636
ifeq ($(CONTAINER_TOOL),auto)
37-
override CONTAINER_TOOL = $(shell docker version >/dev/null 2>&1 && echo docker || echo podman)
37+
ifeq ($(shell docker version >/dev/null 2>&1 && echo docker), docker)
38+
override CONTAINER_TOOL = docker
39+
else ifeq ($(shell podman version >/dev/null 2>&1 && echo podman), podman)
40+
override CONTAINER_TOOL = podman
41+
else
42+
override CONTAINER_TOOL = unknown
43+
endif
3844
endif
3945
# If we're using podman create pods else if we're using docker create networks.
4046
export CURRENT_DIR = $(shell pwd)
@@ -54,7 +60,7 @@ export AWS_ACCESS_KEY_ID ?= "dummy"
5460
export AWS_SECRET_ACCESS_KEY ?= "dummy"
5561

5662
# Set version
57-
export VERSION ?= $(shell cargo vdev version)
63+
export VERSION ?= $(shell command -v cargo >/dev/null && cargo vdev version || echo unknown)
5864

5965
# Set if you are on the CI and actually want the things to happen. (Non-CI users should never set this.)
6066
export CI ?= false
@@ -128,6 +134,7 @@ define ENVIRONMENT_EXEC
128134
endef
129135

130136

137+
ifneq ($(CONTAINER_TOOL), unknown)
131138
ifeq ($(ENVIRONMENT_AUTOBUILD), true)
132139
define ENVIRONMENT_PREPARE
133140
@echo "Building the environment. (ENVIRONMENT_AUTOBUILD=true) This may take a few minutes..."
@@ -142,6 +149,11 @@ define ENVIRONMENT_PREPARE
142149
$(CONTAINER_TOOL) pull $(ENVIRONMENT_UPSTREAM)
143150
endef
144151
endif
152+
else
153+
define ENVIRONMENT_PREPARE
154+
$(error "Please install a container tool such as Docker or Podman")
155+
endef
156+
endif
145157

146158
.PHONY: check-container-tool
147159
check-container-tool: ## Checks what container tool is installed
@@ -208,9 +220,11 @@ build-graphql-schema: ## Generate the `schema.json` for Vector's GraphQL API
208220

209221
.PHONY: check-build-tools
210222
check-build-tools:
211-
ifeq (, $(shell which cargo))
223+
ifneq ($(ENVIRONMENT), true)
224+
ifeq (, $(shell command -v cargo))
212225
$(error "Please install Rust: https://www.rust-lang.org/tools/install")
213226
endif
227+
endif
214228

215229
##@ Cross Compiling
216230
.PHONY: cross-enable

0 commit comments

Comments
 (0)