CDS extractor: Windows compatibility adjustments#375
Open
mihai-herda-SAP wants to merge 10 commits into
Open
Conversation
Transitive deps occasionally pin obsolete Node ranges (e.g. engines.node ^18) that would otherwise abort the entire cache install on newer Node runtimes. npm's default is non-strict, but a project's .npmrc copied into the cache directory can flip it on. Make the non-strict default explicit on the install args so the cache install is robust to user .npmrc settings.
The retry path's full project install was aborting with EBADENGINE on transitive deps that pin obsolete Node ranges (observed: networkcalculation@2302.0.0 requiring node ^18.16.0 on a Node 24 host). This took out the entire retry attempt even though the cds compiler itself runs fine on the host Node version. Match the cache install: pass --engine-strict=false explicitly so the project's .npmrc cannot force strict mode and break the retry.
The cds CLI's plugin loader does require('@cap-js/...') for
each entry in the project's cds.plugins / cds-plugin config.
Node's resolver walks up node_modules from the cds-dk install
location — when cds-dk lives in our cache directory outside
the project, that walk never reaches the project's
node_modules, so any plugin the project installed becomes
invisible. Result: 'Cannot find module @cap-js/telemetry'
even after a successful project npm install.
Always append <projectBaseDir>/node_modules to NODE_PATH in
createSpawnOptions, for both branches:
- cache + npx-style command: append after cache nodePath so
the cache still wins for @sap/cds-dk resolution but project
plugins remain resolvable as a fallback.
- direct binary execution: previously deleted NODE_PATH
entirely; now sets it to the project node_modules so cds
plugins from the project install can be loaded.
This mirrors the pattern already used in cds/indexer.ts when
spawning @sap/cds-indexer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR changes
Spawn-layer adjustments — Windows shim execution
On Windows,
npm,npx, and locally-installed binaries undernode_modules/.bin/are.cmdshims. Since Node 20.12.2 (CVE-2024-27980 hardening), Node refuses to spawn.cmd/.batfiles viaspawnSync/execFileSyncunlessshell: trueis set. The extractor's spawn sites needed updating to match this requirement.shell: getPlatformInfo().isWindowsacross all fivespawnSync/execFileSyncsites the extractor controls: cache install, project install, cds-indexer, cds-command test, and cds compile. Previously these used a mix ofshell: true,shell: isWindows(), or noshelloption at all — the unified pattern makes the Windows requirement explicit and avoids enabling a shell on platforms that don't need one.localCdsBinName()helper incds/compiler/command.tsso cache-directory binary discovery picks upcds.cmdon Windows andcdson Unix, rather than hardcoding the Unix name.useShellrule incompile.tsso direct-binary execution opts into a shell on Windows (required for thecds.cmdshim undernode_modules/.bin/), while non-Windows continues to use a shell only for npx-style commands.Resilience adjustments — slow registries and stale engine declarations
npm viewtimeout from 30 s to 120 s inversionResolver.tsto accommodate slower corporate npm registries.--engine-strict=falseexplicitly on both the cache install and the project install, so a project's.npmrcsettingengine-strict=truedoesn't causenpm installto abort on transitive deps that pin obsolete Node ranges (e.g. a dep declaringengines.node: ^18on a Node 24 host).Plugin-resolution adjustment — project plugins for the spawned cds
createSpawnOptionsnow always appends<projectBaseDir>/node_modulestoNODE_PATH, in both the cache+npx branch and the direct-binary branch. When cds-dk runs from the cache directory, Node's plugin resolver walks upnode_modulesfrom the cds-dk install location and doesn't reach the project's ownnode_modules— so cds plugins the project installed (e.g.@cap-js/telemetrydeclared viacds-plugin) need an explicit fallback path to remain resolvable. The direct-binary branch previously clearedNODE_PATH; it now sets it to the project'snode_modules. This mirrors the pattern already used incds/indexer.ts.