{"record":{"id":"4ee031e9a69ff0d2","repo":"jruby/jruby","slug":"path-name-must-be-ascii-compatible-enc-str","errorCode":null,"errorMessage":"path name must be ASCII-compatible ({enc}): {str}","messagePattern":"path name must be ASCII-compatible \\((.+?)\\): (.+?)","errorType":"exception","errorClass":"Encoding::CompatibilityError","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/jruby/RubyFile.java","lineNumber":1455,"sourceCode":"        return getPathCheckConvert(context, getPathCheckToString(context, path));\n    }\n\n    // CRuby rb_get_path_check_convert\n    private static RubyString getPathCheckConvert(ThreadContext context, RubyString path) {\n        path = filePathConvert(context, path);\n\n        checkPathEncoding(context, path);\n\n        checkEmbeddedNulls(context, path);\n\n        return path.strDup(context.runtime);\n    }\n\n    // CRuby: check_path_encoding\n    private static Encoding checkPathEncoding(ThreadContext context, RubyString str) {\n        Encoding enc = str.getEncoding();\n        if (!enc.isAsciiCompatible()) {\n            throw Error.encodingCompatibilityError(context, \"path name must be ASCII-compatible (\" + enc + \"): \" + str);\n        }\n        return enc;\n    }\n\n    // CRuby: rb_get_path_check_to_string\n    private static RubyString getPathCheckToString(ThreadContext context, IRubyObject path) {\n        if (path instanceof RubyString) return (RubyString) path;\n\n        FileSites sites = sites(context);\n        if (sites.respond_to_to_path.respondsTo(context, path, path, true)) path = sites.to_path.call(context, path, path);\n\n        return path.convertToString();\n    }\n\n    // FIXME: MRI skips this logic on windows?  Does not make sense to me why so I left it in.\n    // mri: file_path_convert\n    protected static RubyString filePathConvert(ThreadContext context, RubyString path) {\n        checkEmbeddedNulls(context, path);","sourceCodeStart":1437,"sourceCodeEnd":1473,"githubUrl":"https://github.com/jruby/jruby/blob/fb650c13e02b5a600fa66384655069d5ec30c362/core/src/main/java/org/jruby/RubyFile.java#L1437-L1473","documentation":"Error \"path name must be ASCII-compatible ({enc}): {str}\" thrown in jruby/jruby.","triggerScenarios":"Thrown at core/src/main/java/org/jruby/RubyFile.java:1455 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["The file path string uses an encoding that is not ASCII-compatible (e.g. UTF-16/UTF-32). Convert the path to an ASCII-compatible encoding such as UTF-8 before passing it to the file API."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fb650c13e02b5a600fa66384655069d5ec30c362","analyzedAt":"2026-08-23T07:18:57.479Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}