nodejs/node · error
errorCode
errorCode
Error message
icupkg: swapInvChars(output package name) failed - %s
What it means
icupkg appends a U_TREE_ENTRY_SEP_CHAR to the package prefix and swaps those invariant characters to the output charset via swapInvChars. If the swap reports a failure, the tool exits with the propagated error code. This catches prefixes containing characters that are not invariant across the target charset.
Source
Thrown at deps/icu-small/source/tools/toolutil/package.cpp:785
}
// prepare and swap the package name with a tree separator
// for prepending to item names
if(pkgPrefix[0]==0) {
prefixLength = static_cast<int32_t>(strlen(prefix));
} else {
prefixLength = static_cast<int32_t>(strlen(pkgPrefix));
memcpy(prefix, pkgPrefix, prefixLength);
if(prefixEndsWithType) {
prefix[prefixLength-1]=outType;
}
}
prefix[prefixLength++]=U_TREE_ENTRY_SEP_CHAR;
prefix[prefixLength]=0;
if(dsLocalToOut!=nullptr) {
dsLocalToOut->swapInvChars(dsLocalToOut, prefix, prefixLength, prefix, &errorCode);
if(U_FAILURE(errorCode)) {
fprintf(stderr, "icupkg: swapInvChars(output package name) failed - %s\n", u_errorName(errorCode));
exit(errorCode);
}
// swap and sort the item names (sorting needs to be done in the output charset)
dsLocalToOut->swapInvChars(dsLocalToOut, inStrings, inStringTop, inStrings, &errorCode);
if(U_FAILURE(errorCode)) {
fprintf(stderr, "icupkg: swapInvChars(item names) failed - %s\n", u_errorName(errorCode));
exit(errorCode);
}
sortItems();
}
// create the output item names in sorted order, with the package name prepended to each
for(i=0; i<itemCount; ++i) {
length = static_cast<int32_t>(strlen(items[i].name));
name=allocString(false, length+prefixLength);
memcpy(name, prefix, prefixLength);
memcpy(name+prefixLength, items[i].name, length+1);View on GitHub (pinned to 1b2de5e052)
Solutions
- Ensure the package name/prefix uses only ICU invariant characters (printable ASCII alphanumerics, '.', '_').
- Use the canonical package basename derived by extractPackageName rather than a custom prefix.
- Switch the output type to one matching the source charset family to avoid the invariant-char swap.
Example fix
# before - prefix with non-invariant chars icupkg -p "my-pkg_v2" -te out.dat # after - use ASCII-only canonical prefix icupkg -p "mypkg" -te out.dat
Defensive patterns
Strategy: validation
Validate before calling
# Validate that the package prefix contains only ICU invariant characters # (ASCII letters, digits, '.', '_') before swapping. case "$PKG" in *[!A-Za-z0-9._]*) echo "prefix '$PKG' has non-invariant chars" >&2; exit 1 ;; esac icupkg -p "$PKG" -te out.dat
Prevention
- Use only ASCII alphanumeric characters, '.', and '_' in package names.
- Prefer the canonical basename produced by extractPackageName.
- Avoid EBCDIC output unless the prefix is ASCII-invariant.
When it happens
Trigger: In writePackage, 'dsLocalToOut->swapInvChars(...prefix...) returns U_FAILURE(errorCode). Triggered when the package prefix contains bytes that are not valid invariant characters for the output charset family (e.g. non-ASCII in a prefix being swapped to EBCDIC).
Common situations: A package name with non-ASCII or unusual punctuation; an output charset family that does not cover the prefix's characters; a hand-set pkgPrefix from a non-canonical source.
Related errors
AI-assisted analysis of nodejs/node@1b2de5e052 (2026-08-13).
Data as JSON: /api/errors/b9b4b4c2398bfba2.
Report an issue: GitHub.