[8.3.2] bin/elasticsearch-users throws StringIndexOutOfBoundsException

elasticsearch@esmaster:~/bin$ . elasticsearch-users useradd su -p password -r superuser
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: Range [13, 4) out of bounds for length 4
        at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:55)
        at java.base/jdk.internal.util.Preconditions$1.apply(Preconditions.java:52)
        at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213)
        at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210)
        at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98)
        at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromToIndex(Preconditions.java:112)
        at java.base/jdk.internal.util.Preconditions.checkFromToIndex(Preconditions.java:349)
        at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4589)
        at java.base/java.lang.String.substring(String.java:2703)
        at java.base/java.lang.String.substring(String.java:2676)
        at org.elasticsearch.launcher.CliToolLauncher.getToolName(CliToolLauncher.java:77)
        at org.elasticsearch.launcher.CliToolLauncher.main(CliToolLauncher.java:57)

Is that the actual command you are running? Why is there a . at the start?

It is the actual command.

elasticsearch-users is a Bash script: source or dot operator Man Page - Linux - SS64.com and I've seen right now that it doesn't pass any argument to elasticsearch-cli:

#!/bin/bash

# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.

CLI_LIBS="modules/x-pack-core,modules/x-pack-security"
source "`dirname "$0"`"/elasticsearch-cli

You should run elasticsearch-users as an executable script, it is not intended to be sourced (via .)

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.