Bug #108839 The 'util' global object is not available via Shell command line integration
Submitted: 20 Oct 2022 20:43 Modified: 29 Nov 2022 9:43
Reporter: David Gamble Email Updates:
Status: Closed Impact on me:
None 
Category:Shell General / Core Client Severity:S3 (Non-critical)
Version:8.0.31 OS:Any
Assigned to: CPU Architecture:Any

[20 Oct 2022 20:43] David Gamble
Description:
The 'util' global object is not available via command line integration in MySQL Shell 8.0.31.

How to repeat:
mysqlsh -- --help
    does not list the util object

Attempting to reference the 'util' object on the command line (e.g. mysqlsh -- util checkForServerUpgrade ...) produces an error ("There is no object registered under name 'util')
[25 Oct 2022 15:16] MySQL Verification Team
Thank you for report

all best
[10 Nov 2022 11:39] Pawel Andruszkiewicz
Posted by developer:
 
Looks like this option is caused by the persisted 'defaultMode' option set to 'sql':

$ ./mysqlsh -VVV
./mysqlsh   Ver 8.0.31 for Linux on x86_64 - for MySQL 8.0.31 (MySQL Community Server (GPL)) - build 8480665 - commit_id 9c7270719869963d960ec459cc887ca7d0cb22d3

$ ./mysqlsh -- --help
The following objects provide command line operations:

   cluster
      Represents an InnoDB Cluster.

   clusterset
      Represents an InnoDB ClusterSet.

   dba
      InnoDB Cluster, ReplicaSet, and ClusterSet management functions.

   rs
      Represents an InnoDB ReplicaSet.

   shell
      Gives access to general purpose functions and properties.

   util
      Global object that groups miscellaneous tools like upgrade checker and
      JSON import.

$ ./mysqlsh --interactive -e "\option --persist defaultMode sql"

$ ./mysqlsh -- --help
The following objects provide command line operations:

   cluster
      Represents an InnoDB Cluster.

   clusterset
      Represents an InnoDB ClusterSet.

   dba
      InnoDB Cluster, ReplicaSet, and ClusterSet management functions.

   rs
      Represents an InnoDB ReplicaSet.

   shell
      Gives access to general purpose functions and properties.

Workaround is to specify a different mode:

$ ./mysqlsh --js -- --help
The following objects provide command line operations:

   cluster
      Represents an InnoDB Cluster.

   clusterset
      Represents an InnoDB ClusterSet.

   dba
      InnoDB Cluster, ReplicaSet, and ClusterSet management functions.

   rs
      Represents an InnoDB ReplicaSet.

   shell
      Gives access to general purpose functions and properties.

   util
      Global object that groups miscellaneous tools like upgrade checker and
      JSON import.

or remove the persisted value (\option --unset --persist defaultMode).
[29 Nov 2022 9:43] Edward Gilmore
Posted by developer:
 
Added the following note to the MySQL Shell 8.0.32 release notes:

	   The util global object was not available from the command line
       if the persisted default mode was set to SQL.