Getting OPatch error code 255 and 1

I ran OPatch against my Oracle Access Manager (OAM) 12.2.1.4 installation, and I got the OPatch error code 255.

oracle@soadev:/u01/oracle/middleware/OPatch> ./opatch lsinventory

OPatch failed with error code 255

I guess I had to set the ORACLE_HOME first, which I then did. The OAM product is under the ~/idm subfolder, so that's what I set it to.

oracle@soadev:/u01/oracle/middleware/OPatch> export ORACLE_HOME=/u01/oracle/middleware/idm

oracle@soadev:/u01/oracle/middleware/OPatch> ./opatch lsinventory
The Oracle Home /u01/oracle/middleware/idm is not OUI based home. Please give proper Oracle Home.
OPatch returns with error code = 1

Still no good.

So now, I set the ORACLE_HOME to the same value of  MW_HOME, which is the top-level directory of my Oracle Fusion Middleware installation.

Success!

oracle@soadev:/u01/oracle/middleware/OPatch> export ORACLE_HOME=/u01/oracle/middleware

oracle@soadev:/u01/oracle/middleware/OPatch> ./opatch lsinventory
Oracle Interim Patch Installer version 13.9.4.2.1
Copyright (c) 2021, Oracle Corporation.  All rights reserved.


Oracle Home       : /u01/oracle/middleware
Central Inventory : /u01/oraInventoryAgent
   from           : /u01/oracle/middleware/oraInst.loc
OPatch version    : 13.9.4.2.1
OUI version       : 13.9.4.0.0
Log file location : /u01/oracle/middleware/cfgtoollogs/opatch/opatch2021-01-06_01-57-05AM_1.log


OPatch detects the Middleware Home as "/u01/oracle/middleware"

Lsinventory Output file location : /u01/oracle/middleware/cfgtoollogs/opatch/lsinv/lsinventory2021-01-06_01-57-05AM.txt

--------------------------------------------------------------------------------
Local Machine Information::
Hostname: soadev.raastech.com
ARU platform id: 226
ARU platform description:: Linux x86-64


Interim patches (1) :

Patch  31556630     : applied on Tue Sep 08 01:09:30 GMT 2020
Unique Patch ID:  23664288
Patch description:  "OAM BUNDLE PATCH 12.2.1.4.200629"
   Created on 30 Jun 2020, 01:44:15 hrs PST8PDT
   Bugs fixed:
     30355996, 30832165, 30882267, 30793308, 31000954, 30771422, 31110638
     30053037, 30748479, 30831364, 30669352, 28108712, 29883498, 30762860
     30120631, 29715441, 30628496, 30911495, 30406633, 31366419, 30622957
     30953737, 31419785, 31413189, 31465732, 31065568, 31510690, 31508059
     30468914, 21391069, 29717855, 30634571, 30069618, 30792754, 30571576
     29240849, 30213267, 29783271, 30426370, 30460435, 30169956, 30820170
     29885236, 30805164, 30805154, 30805180, 30134427, 31029076, 31042676
     31073659, 29771448, 29482858, 29837657, 30062772, 30180492, 29290091
     30363797, 30156607, 30243111, 30267123, 30156706, 30389257, 30176378
     29649734, 30144617, 26679791, 29541818, 30311080



--------------------------------------------------------------------------------

OPatch succeeded.