Skip to content

Commit a693d4e

Browse files
authored
Improve pnpm install errors (#1078)
* Improve pnpm install errors This PR adds detailed and consistent error messages for the pnpm install buildpack + includes snapshot testing for the output. * Update CHANGELOG.md Signed-off-by: Colin Casey <[email protected]> --------- Signed-off-by: Colin Casey <[email protected]>
1 parent 1e11454 commit a693d4e

18 files changed

+467
-107
lines changed

Diff for: Cargo.lock

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: buildpacks/nodejs-pnpm-install/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- Updated error messages and formatting. ([#1078](https://github.com/heroku/buildpacks-nodejs/pull/1078))
13+
1014
## [3.6.0] - 2025-04-09
1115

1216
- No changes.

Diff for: buildpacks/nodejs-pnpm-install/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ serde = "1"
1616
toml = "0.8"
1717

1818
[dev-dependencies]
19+
insta = "1"
1920
libcnb-test = "=0.28.1"
21+
serde_json = "1"
2022
test_support.workspace = true

Diff for: buildpacks/nodejs-pnpm-install/buildpack.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ api = "0.10"
33
[buildpack]
44
id = "heroku/nodejs-pnpm-install"
55
version = "3.6.0"
6-
name = "Heroku Node.js pnpm install"
6+
name = "Heroku Node.js pnpm Install"
77
homepage = "https://github.com/heroku/buildpacks-nodejs"
88
description = "Heroku's Node.js pnpm install buildpack. A component of the 'heroku/nodejs' buildpack."
99
keywords = ["pnpm", "heroku"]

Diff for: buildpacks/nodejs-pnpm-install/src/configure_pnpm_store_directory.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub(crate) fn configure_pnpm_store_directory(
5050
}
5151

5252
cmd::pnpm_set_store_dir(env, &addressable_layer.path())
53-
.map_err(PnpmInstallBuildpackError::PnpmDir)?;
53+
.map_err(PnpmInstallBuildpackError::PnpmSetStoreDir)?;
5454

5555
Ok(log)
5656
}

Diff for: buildpacks/nodejs-pnpm-install/src/configure_pnpm_virtual_store_directory.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,23 @@ pub(crate) fn configure_pnpm_virtual_store_directory(
2626
log = log.sub_bullet("Creating pnpm virtual store");
2727
let virtual_store_dir = virtual_layer.path().join("store");
2828
// Create a directory for dependencies in the virtual store.
29-
create_dir(&virtual_store_dir).map_err(PnpmInstallBuildpackError::VirtualLayer)?;
29+
create_dir(&virtual_store_dir)
30+
.map_err(|e| PnpmInstallBuildpackError::CreateDirectory(virtual_store_dir.clone(), e))?;
31+
3032
cmd::pnpm_set_virtual_dir(env, &virtual_store_dir)
31-
.map_err(PnpmInstallBuildpackError::PnpmDir)?;
33+
.map_err(PnpmInstallBuildpackError::PnpmSetVirtualStoreDir)?;
3234

3335
// Install a symlink from {virtual_layer}/node_modules to
3436
// {app_dir}/node_modules, so that dependencies in
3537
// {virtual_layer}/store/ can find their dependencies via the Node
3638
// module loader's ancestor directory traversal.
37-
symlink(
38-
context.app_dir.join("node_modules"),
39-
virtual_layer.path().join("node_modules"),
40-
)
41-
.map_err(PnpmInstallBuildpackError::VirtualLayer)?;
39+
let from = context.app_dir.join("node_modules");
40+
let to = virtual_layer.path().join("node_modules");
41+
symlink(&from, &to).map_err(|source| PnpmInstallBuildpackError::CreateSymlink {
42+
from,
43+
to,
44+
source,
45+
})?;
4246

4347
Ok(log)
4448
}

0 commit comments

Comments
 (0)