grafana/k6 · error
local or remote path required
Error message
local or remote path required
What it means
loader.Resolve maps a module specifier to a filesystem path or remote https URL. It refuses an empty specifier up front with 'local or remote path required' because there is nothing to resolve. This is the entry point used for resolving imports and open() file paths, so the error means an empty string was passed where a path was expected.
Solutions
- Validate the specifier is non-empty before calling open()/importing
- Fix the variable that produced the empty string (check __ENV values, loop data, defaulting logic)
- Pass a literal relative or absolute path, or an https URL
Example fix
// before
const data = open(__ENV.DATA_FILE); // DATA_FILE unset -> ""
// after
const file = __ENV.DATA_FILE;
if (!file) throw new Error('DATA_FILE must point to a data file');
const data = open(file); Defensive patterns
Strategy: validation
Validate before calling
// k6 script (JS)
function requirePath(p, name) {
if (typeof p !== 'string' || p.trim() === '') {
throw new Error(`${name} must be a non-empty file path`);
}
return p;
}
const data = open(requirePath(__ENV.DATA_FILE, 'DATA_FILE')); Type guard
function isNonEmptySpecifier(s) {
return typeof s === 'string' && s.length > 0;
} Prevention
- Never pass __ENV values straight into open() — default and validate them first
- Fail fast on empty computed paths before the loader sees them
- Log the resolved specifier in debug output so empty strings are obvious
When it happens
Trigger: Calling open('') in a k6 script; import of a specifier that a template string or variable built to be empty; programmatic use of loader.Resolve(pwd, "") in Go.
Common situations: A filename variable that is undefined/empty (e.g., from __ENV or a data-driven loop) is passed to open(); path templates like `${base}/${file}` collapsing when all parts are empty.
Related errors
- failed to get absolute path for template
- failed to read template file
- k6/experimental/browser has been graduated, please use…
- k6/experimental/grpc has been graduated, please use…
- k6/experimental/redis has been removed. Please migrate to…
AI-assisted analysis of grafana/k6@8d06114777 (2026-08-18).
Data as JSON: /api/errors/7128dba5cdd29209.
Report an issue: GitHub.
Appendix: source
Thrown at internal/loader/loader.go:50
`local disk. Make sure that you've specified the right path to the file. If you're ` +
`running k6 using the Docker image make sure you have mounted the ` +
`local directory (-v /local/path/:/inside/docker/path) containing ` +
`your script and modules so that they're accessible by k6 from ` +
`inside of the container, see ` +
`https://grafana.com/docs/k6/latest/using-k6/modules/#use-modules-with-docker.`
)
type unresolvableURLError string
func (u unresolvableURLError) Error() string {
// TODO potentially add more things about what k6 supports if users report being confused.
return fmt.Sprintf(`The moduleSpecifier %q couldn't be recognised as something k6 supports.`, string(u))
}
// Resolve a relative path to an absolute one.
func Resolve(pwd *url.URL, moduleSpecifier string) (*url.URL, error) {
if moduleSpecifier == "" {
return nil, errors.New("local or remote path required")
}
if moduleSpecifier[0] == '.' || moduleSpecifier[0] == '/' || filepath.IsAbs(moduleSpecifier) {
return resolveFilePath(pwd, moduleSpecifier)
}
if strings.Contains(moduleSpecifier, "://") {
u, err := url.Parse(moduleSpecifier)
if err != nil {
return nil, err
}
if u.Scheme != "file" && u.Scheme != "https" {
return nil,
fmt.Errorf("only supported schemes for imports are file and https, %s has `%s`",
moduleSpecifier, u.Scheme)
}
if u.Scheme == "file" && pwd.Scheme == "https" {
return nil, fmt.Errorf("origin (%s) not allowed to load local file: %s", pwd, moduleSpecifier)View on GitHub (pinned to 8d06114777)