Relative imports fail if the script is started through symlink
System information
What is your operating system and version? Fedora 39
What is your version of GJS? gjs-1.78.0-2.fc39
Bug information
Steps to reproduce
# cat main.js
#!/usr/bin/env -S gjs -m
import { main } from './aux.js'
main()
# cat aux.js
export function main() {
printerr('Success!');
}
# chmod +x main.js
# mkdir subdir
# cd subdir
# ln -s ../main.js
Current behaviour
# ./main.js
(gjs:105): Gjs-WARNING **: 10:48:56.506: JS ERROR: ImportError: Unable to load file from: file:///home/amezin/symlink-fail/subdir/aux.js (Error opening file /home/amezin/symlink-fail/subdir/aux.js: No such file or directory)
loadURI@resource:///org/gnome/gjs/modules/internal/loader.js:88:21
loadURI@resource:///org/gnome/gjs/modules/internal/loader.js:290:30
resolveModule@resource:///org/gnome/gjs/modules/internal/loader.js:179:33
moduleResolveHook@resource:///org/gnome/gjs/modules/internal/loader.js:339:29
(gjs:105): Gjs-CRITICAL **: 10:48:56.506: Failed to resolve imports for module: 'file:///home/amezin/symlink-fail/subdir/main.js'
Expected behaviour
# ../main.js
Success!