jqlang / jq

Command-line JSON processor
https://jqlang.github.io/jq/
Other
30.23k stars 1.57k forks source link

modulemeta failure when module location is found by "search" #3145

Open pkoppstein opened 3 months ago

pkoppstein commented 3 months ago

When a jq module location is specified by a "search" key, modulemeta can fail even when the module is successfully located.

To Reproduce

$ mkdir obscure

$ cat << EOF > obscure/amod.jq
module {"name": "amod", "foo": "bar"};
def a: "a";
EOF

# First verify our setup is valid:
$ jq -n -Lobscure 'import "amod" as amod; "amod" | modulemeta'
{
  "name": "amod",
  "foo": "bar",
  "deps": [],
  "defs": [
    "a/0"
  ]
}
# Now illustrate the problem:
$ jq -n 'import "amod" as amod {search: "obscure"}; "amod" | modulemeta'
jq: error (at <unknown>): module not found: amod

Context jq-1.7.1 and other versions as well