{"record":{"id":"e0d8c53e6e0073c8","repo":"grafana/k6","slug":"error-while-parsing-use-directives-in-q-w","errorCode":null,"errorMessage":"error while parsing use directives in %q: %w","messagePattern":"error while parsing use directives in %q: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/launcher.go","lineNumber":411,"sourceCode":"\t\tdirective = strings.TrimSpace(strings.TrimPrefix(directive, \"use k6\"))\n\t\tdep := \"k6\"\n\t\tconstraint := directive\n\t\tif strings.HasPrefix(directive, \"with k6/x/\") {\n\t\t\tdirective = strings.TrimSpace(strings.TrimPrefix(directive, \"with \"))\n\t\t\tdep, constraint, _ = strings.Cut(directive, \" \")\n\t\t}\n\t\tvar con *semver.Constraints\n\t\tvar err error\n\t\tif len(constraint) > 0 {\n\t\t\tcon, err = semver.NewConstraint(constraint)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error while parsing use directives constraint %q for %q in %q: %w\", constraint, dep, name, err)\n\t\t\t}\n\t\t}\n\n\t\terr = deps.update(dep, con)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"error while parsing use directives in %q: %w\", name, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc findDirectives(text []byte) []string {\n\t// parse #! at beginning of file\n\tif bytes.HasPrefix(text, []byte(\"#!\")) {\n\t\t_, text, _ = bytes.Cut(text, []byte(\"\\n\"))\n\t}\n\n\tvar result []string\n\n\tfor i := 0; i < len(text); {\n\t\tr, width := utf8.DecodeRune(text[i:])\n\t\tswitch {\n\t\tcase unicode.IsSpace(r) || r == rune(';'): // skip all spaces and ;","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/grafana/k6/blob/8d06114777191d21ef885d05c5f8aa9e1ed838ae/internal/cmd/launcher.go#L393-L429","documentation":"Wrapped error from processUseDirectives: applying a 'use k6 ...' dependency constraint to the collected dependencies map failed — e.g. conflicting or unsatisfiable version constraints across directives and the dependencies manifest for the same dependency.","triggerScenarios":"Thrown at internal/cmd/launcher.go:412 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped error for which dependency/constraint conflicts","Make 'use k6' directives and the manifest constraints consistent","Remove duplicate or contradictory version constraints for the same dependency"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8d06114777191d21ef885d05c5f8aa9e1ed838ae","analyzedAt":"2026-08-18T03:05:52.393Z","contentChangedAt":"2026-08-18T03:05:52.393Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}