From 9a1b55bd004c033e5dd2a4e427caceac84ebe354 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 1 Jun 2026 14:05:40 +0000 Subject: [PATCH 1/2] nodejs plugin: guard corepack init_hook when corepack is absent The nodejs-slim package no longer ships corepack as a default output, so the plugin's init_hook failed with 'corepack: command not found' whenever DEVBOX_COREPACK_ENABLED was set (which the node templates set by default). Wrap the corepack invocation in a 'command -v corepack' check so the shell no longer breaks when corepack is unavailable, and print a helpful warning pointing users to the nodejs package or adding corepack explicitly. Fixes #2791 --- plugins/nodejs.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plugins/nodejs.json b/plugins/nodejs.json index 2d2ebc0b1e2..0debe403962 100644 --- a/plugins/nodejs.json +++ b/plugins/nodejs.json @@ -1,12 +1,11 @@ { "$schema": "https://raw.githubusercontent.com/jetify-com/devbox/main/.schema/devbox-plugin.schema.json", - "version": "0.0.2", + "version": "0.0.3", "name": "nodejs", "readme": "Devbox automatically configures Corepack for Nodejs when DEVBOX_COREPACK_ENABLED=1. You can install Yarn or Pnpm by adding them to your `package.json` file using `packageManager`\nCorepack binaries will be installed in your local `.devbox` directory", "shell": { "init_hook": [ - "test -z $DEVBOX_COREPACK_ENABLED || corepack enable --install-directory \"{{ .Virtenv }}/corepack-bin/\"", - "test -z $DEVBOX_COREPACK_ENABLED || export PATH=\"{{ .Virtenv }}/corepack-bin/:$PATH\"" + "if [ -n \"$DEVBOX_COREPACK_ENABLED\" ]; then if command -v corepack >/dev/null 2>&1; then corepack enable --install-directory \"{{ .Virtenv }}/corepack-bin/\" && export PATH=\"{{ .Virtenv }}/corepack-bin/:$PATH\"; else echo 'Warning: DEVBOX_COREPACK_ENABLED is set but corepack was not found. The nodejs-slim package no longer ships corepack; use the nodejs package instead, or add corepack to your packages.' >&2; fi; fi" ] }, "create_files": { From c0efd7b8bf6a68e60ccf91061be7b8f7c42db0b9 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 6 Jun 2026 00:39:50 +0000 Subject: [PATCH 2/2] nodejs plugin: split corepack init_hook across lines for readability Addresses review feedback: the init_hook entries are joined with newlines into a single script, so splitting the control flow across array entries keeps behavior identical while making the generated hooks file readable one statement per line. --- plugins/nodejs.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/plugins/nodejs.json b/plugins/nodejs.json index 0debe403962..6497ddabd07 100644 --- a/plugins/nodejs.json +++ b/plugins/nodejs.json @@ -5,7 +5,14 @@ "readme": "Devbox automatically configures Corepack for Nodejs when DEVBOX_COREPACK_ENABLED=1. You can install Yarn or Pnpm by adding them to your `package.json` file using `packageManager`\nCorepack binaries will be installed in your local `.devbox` directory", "shell": { "init_hook": [ - "if [ -n \"$DEVBOX_COREPACK_ENABLED\" ]; then if command -v corepack >/dev/null 2>&1; then corepack enable --install-directory \"{{ .Virtenv }}/corepack-bin/\" && export PATH=\"{{ .Virtenv }}/corepack-bin/:$PATH\"; else echo 'Warning: DEVBOX_COREPACK_ENABLED is set but corepack was not found. The nodejs-slim package no longer ships corepack; use the nodejs package instead, or add corepack to your packages.' >&2; fi; fi" + "if [ -n \"$DEVBOX_COREPACK_ENABLED\" ]; then", + " if command -v corepack >/dev/null 2>&1; then", + " corepack enable --install-directory \"{{ .Virtenv }}/corepack-bin/\"", + " export PATH=\"{{ .Virtenv }}/corepack-bin/:$PATH\"", + " else", + " echo 'Warning: DEVBOX_COREPACK_ENABLED is set but corepack was not found. The nodejs-slim package no longer ships corepack; use the nodejs package instead, or add corepack to your packages.' >&2", + " fi", + "fi" ] }, "create_files": {