grafana/k6 · error

The moduleSpecifier "%s" couldn't be found on local disk. Ma

Error message

The moduleSpecifier "%s" couldn't be found on 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.

What it means

Error "The moduleSpecifier "%s" couldn't be found on 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." thrown in grafana/k6.

Source

Thrown at internal/loader/loader.go:141

	logger logrus.FieldLogger, filesystems map[string]fsext.Fs, moduleSpecifier *url.URL, originalModuleSpecifier string,
) (*SourceData, error) {
	logger.WithFields(
		logrus.Fields{
			"moduleSpecifier":         moduleSpecifier,
			"originalModuleSpecifier": originalModuleSpecifier,
		}).Debug("Loading...")

	var pathOnFs string
	switch moduleSpecifier.Scheme {
	case "":
		pathOnFs = path.Clean(moduleSpecifier.String())
	default:
		pathOnFs = path.Clean(moduleSpecifier.String()[len(moduleSpecifier.Scheme)+len(":/"):])
	}
	scheme := moduleSpecifier.Scheme
	if scheme == "" {
		if moduleSpecifier.Opaque == "" {
			return nil, fmt.Errorf(fileSchemeCouldntBeLoadedMsg, originalModuleSpecifier) //nolint:staticcheck
		}
		scheme = "https"
	}

	pathOnFs, err := url.PathUnescape(filepath.FromSlash(pathOnFs))
	if err != nil {
		return nil, err
	}

	data, err := fsext.ReadFile(filesystems[scheme], pathOnFs)

	if err == nil {
		return &SourceData{URL: moduleSpecifier, Data: data}, nil
	}
	if !errors.Is(err, fs.ErrNotExist) {
		return nil, err
	}
	if scheme != "https" {

View on GitHub (pinned to 01ffac6f24)

Solutions

  1. Verify the module specifier/path is spelled correctly and the file exists
  2. When running in Docker, mount the directory containing the script and modules (-v /local/path/:/inside/docker/path) and use /inside/docker/path paths
  3. Use an absolute path or file:// URL to disambiguate
  4. For remote modules, ensure the https URL is correct and reachable
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at internal/loader/loader.go:141 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of grafana/k6@01ffac6f24 (2026-08-18). Data as JSON: /api/errors/849daed043d2eb0e. Report an issue: GitHub.