bids-validator
bids-validator copied to clipboard
deno run on a built bids-validator.js: Attempted to load JSON module without specifying "type"
Trying to run out of deno-build branch using wrapper proposed in
- #1942
but getting
+ bids-validator 7t_trt --ignoreNiftiHeaders
TypeError: Attempted to load JSON module without specifying "type": "json" attribute in the import statement.
at async loadSchema (file:///tmp/bids-validator/bids-validator.js:8513:26)
at async validate (file:///tmp/bids-validator/bids-validator.js:9254:18)
at async main (file:///tmp/bids-validator/bids-validator.js:9458:24)
at async file:///tmp/bids-validator/bids-validator.js:9479:1 {
code: "ERR_MODULE_NOT_FOUND"
}
Warning, could not load schema from https://bids-specification.readthedocs.io/en/latest/schema.json, falling back to internal version
[WARNING] The 'Authors' field of 'dataset_description.json' should contain an array of values -
with one author per value.
This was triggered based on the presence of only one author field.
Please ignore if all contributors are already properly listed.
(TOO_FEW_AUTHORS)
./dataset_description.json
Evidence: schema.rules.checks.hints.TooFewAuthors
1 more files with the same issue
Please visit https://neurostars.org/search?q=TOO_FEW_AUTHORS for existing conversations about this issue.
[ERROR] Empty files not allowed. (EMPTY_FILE)
./sub-01/ses-1/anat/sub-01_ses-1_T1map.nii.gz
./sub-01/ses-1/anat/sub-01_ses-1_T1w.nii.gz
./sub-01/ses-1/fmap/sub-01_ses-1_run-1_magnitude1.nii.gz
that is with
❯ bids-validator -V
v1.14.6-dev.0-9-gdc61d0f3.deno
❯ cat `which bids-validator`
#!/usr/bin/env bash
deno run --allow-read --allow-write --allow-env --allow-net --allow-run "$(dirname "$0")"/bids-validator.js "$@"
so there is --allow-net if that is of importance.
So it seems to do use some internal copy of schema but not clear why it fails to get/use that one from a URL if it wants so (should it download it every time? sounds a bit too much)
Here's the relevant code:
https://github.com/bids-standard/bids-validator/blob/dc61d0f362ff138e2d3b5accf27f4f92fdd535cd/bids-validator/src/setup/loadSchema.ts#L21-L23
This is an issue with how the module is transpiled, it might be configuration or a bug in esbuild or the Deno module plugin.
https://github.com/bids-standard/bids-validator/blob/dc61d0f362ff138e2d3b5accf27f4f92fdd535cd/bids-validator/build.ts#L9
So it seems to do use some internal copy of schema but not clear why it fails to get/use that one from a URL if it wants so (should it download it every time? sounds a bit too much)
Imports are always cached in deno. You can refresh the cache with deno run --reload .... The idea here is to load both ways, as a static import that can be bundled and a dynamic import that can be modified at runtime by the tool.
FWIW, adding --reload didn't help
❯ deno run --reload --allow-read --allow-write --allow-env --allow-net --allow-run /tmp/bids-validator/bids-validator.js 7t_trt --ignoreNiftiHeaders
TypeError: Attempted to load JSON module without specifying "type": "json" attribute in the import statement.
at async loadSchema (file:///tmp/bids-validator/bids-validator.js:8513:26)
at async validate (file:///tmp/bids-validator/bids-validator.js:9254:18)
at async main (file:///tmp/bids-validator/bids-validator.js:9458:24)
at async file:///tmp/bids-validator/bids-validator.js:9479:1 {
code: "ERR_MODULE_NOT_FOUND"
}
Warning, could not load schema from https://bids-specification.readthedocs.io/en/latest/schema.json, falling back to internal version
...
note that this is on "compiled" (deno-build) version of bids-validator.js