jruby/jruby · error · MainExitException

Error opening script file: {}

Error message

Error opening script file: {}

What it means

Error "Error opening script file: {}" thrown in jruby/jruby.

Source

Thrown at core/src/main/java/org/jruby/RubyInstanceConfig.java:419

                if (resource != null && resource.exists()) {
                    if (resource.canRead() && !resource.isDirectory()) {
                        if (isXFlag()) {
                            // search for a shebang line and
                            // return the script between shebang and __END__ or CTRL-Z (0x1A)
                            return findScript(resource.openInputStream());
                        }
                        return resource.openInputStream();
                    }
                    else {
                        throw new FileNotFoundException(script + " (Not a file)");
                    }
                }
                else {
                    throw new FileNotFoundException(script + " (No such file or directory)");
                }
            }
        } catch (IOException e) {
            throw new MainExitException(1, "Error opening script file: " + e.getMessage());
        }
    }

    private static InputStream findScript(InputStream is) throws IOException {
        StringBuilder buf = new StringBuilder(64);
        BufferedReader br = new BufferedReader(new InputStreamReader(is));

        boolean foundRubyShebang = false;
        String currentLine;
        while ((currentLine = br.readLine()) != null) {
            if (isRubyShebangLine(currentLine)) {
                foundRubyShebang = true;
                break;
            }
        }

        if (!foundRubyShebang) {
            throw new MainExitException(1, "jruby: no Ruby script found in input (LoadError)");

View on GitHub (pinned to fb650c13e0)

Solutions

  1. 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.

When it happens

Trigger: Thrown at core/src/main/java/org/jruby/RubyInstanceConfig.java:419 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of jruby/jruby@fb650c13e0 (2026-08-23). Data as JSON: /api/errors/5f6f836bbc83eebd. Report an issue: GitHub.