{"record":{"id":"5f6f836bbc83eebd","repo":"jruby/jruby","slug":"error-opening-script-file","errorCode":null,"errorMessage":"Error opening script file: {}","messagePattern":"Error opening script file: (.+?)","errorType":"exception","errorClass":"MainExitException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/jruby/RubyInstanceConfig.java","lineNumber":419,"sourceCode":"                if (resource != null && resource.exists()) {\n                    if (resource.canRead() && !resource.isDirectory()) {\n                        if (isXFlag()) {\n                            // search for a shebang line and\n                            // return the script between shebang and __END__ or CTRL-Z (0x1A)\n                            return findScript(resource.openInputStream());\n                        }\n                        return resource.openInputStream();\n                    }\n                    else {\n                        throw new FileNotFoundException(script + \" (Not a file)\");\n                    }\n                }\n                else {\n                    throw new FileNotFoundException(script + \" (No such file or directory)\");\n                }\n            }\n        } catch (IOException e) {\n            throw new MainExitException(1, \"Error opening script file: \" + e.getMessage());\n        }\n    }\n\n    private static InputStream findScript(InputStream is) throws IOException {\n        StringBuilder buf = new StringBuilder(64);\n        BufferedReader br = new BufferedReader(new InputStreamReader(is));\n\n        boolean foundRubyShebang = false;\n        String currentLine;\n        while ((currentLine = br.readLine()) != null) {\n            if (isRubyShebangLine(currentLine)) {\n                foundRubyShebang = true;\n                break;\n            }\n        }\n\n        if (!foundRubyShebang) {\n            throw new MainExitException(1, \"jruby: no Ruby script found in input (LoadError)\");","sourceCodeStart":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/jruby/jruby/blob/fb650c13e02b5a600fa66384655069d5ec30c362/core/src/main/java/org/jruby/RubyInstanceConfig.java#L401-L437","documentation":"Error \"Error opening script file: {}\" thrown in jruby/jruby.","triggerScenarios":"Thrown at core/src/main/java/org/jruby/RubyInstanceConfig.java:419 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["JRuby could not open the script file given on the command line. Verify the path exists and is readable, check for typos and quoting problems in the command line, and confirm the file is not a directory."],"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"}