Skip to content

fix(mcpack): check manifest include value before resolving#1446

Open
HipsterBrown wants to merge 2 commits intoModdable-OpenSource:publicfrom
HipsterBrown:hipsterbrown/mcpack-fix-include-manifest
Open

fix(mcpack): check manifest include value before resolving#1446
HipsterBrown wants to merge 2 commits intoModdable-OpenSource:publicfrom
HipsterBrown:hipsterbrown/mcpack-fix-include-manifest

Conversation

@HipsterBrown
Copy link
Copy Markdown
Contributor

While trying to build a project targeting the Raspberry Pi Pico with mcpack, I ran into an error:

### TypeError: call: not a function

All other platform targets were working, so I started exploring the cause.

After digging around the source code for mcpack, I narrowed down the issue to how the tool resolves modules from included manifest.json files. This led to the arducam module for the ECMA-419 image/in implementation, which uses a git include for the Pico.

When comparing mcpack with the mcmanifest tool, I noticed the latter has support for git sources that is missing from mcpack.

This PR fixes the current error by checking the type of the include field's value before attempting to resolve the expected string path to the included module.


I'm not sure if git support should be added to mcpack if the evaluated manifest from mcpack still goes through mcconfig (a subclass of mcmanifest).

@phoddie
Copy link
Copy Markdown
Collaborator

phoddie commented Jan 2, 2025

Interesting find. The problem is very real. mcpack isn't expecting to find a Git repository in the includes. I'm not 100% sure what it should do here. I think the right approach is to make sure that the include gets passed through to mcconfig to handle. Will take a look.

@HipsterBrown HipsterBrown force-pushed the hipsterbrown/mcpack-fix-include-manifest branch from 7e94774 to 17e939e Compare April 14, 2026 03:43
@HipsterBrown
Copy link
Copy Markdown
Contributor Author

Bumping this PR since I'm running into the issue again while working on some new starting guides for the xs-dev docs and testing the example projects on the Raspberry Pi Pico.

I also ran into an issue related to the PICO_EXTRAS_DIR and PICO_EXAMPLES_DIR paths being set in the pico's device manifest.json, which throws an error when trying to build with mcpack but not mcconfig; this behavior is due to the resolveSource in mcpack.js catching and reporting thrown errors while the same method in mcconfig seems to silently swallow them. I resolved this by allowing environment variables to take precedence over variables defined in the manifest's build config. The other solution would be to just remove those build vars from the pico's manifest.json and use the environment variables defined by developer / xs-dev only.

@phoddie
Copy link
Copy Markdown
Collaborator

phoddie commented Apr 17, 2026

Thanks for putting this back on the active list and the additional fixes.

mcpack exists to allow you to work in the npm way. The git support is kind of a parallel world. But, they can collide. mcpack eventually outputs a manifest that mcconfig runs (at least that's my memory at the moment...) but obviously the contents of any git repos are going to be opaque to mcpack. Maybe that's ok though.

@HipsterBrown
Copy link
Copy Markdown
Contributor Author

Yes, this patch basically passes through the include config for that resource to mcconfig since it is unlikely to be a package.json based dependency that would need to be scanned by mcpack. It's also the only include defined that way AFAICT, so it's not worth pursuing full git support in mcpack at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants