Fix ERROR: The home is not clean in Oracle RDBMS Installation

Encountering errors during the installation or upgrade of the Oracle Database can be frustrating, especially when faced with cryptic messages like “The home is not clean.” However, fear not! In this blog, let us go through a simple and effective solution to resolve this error swiftly.

ERROR: The home is not clean

“The home is not clean” error in Oracle installation typically indicates the presence of residual files or directories from a previous installation or upgrade attempt. These remnants cause conflicts during the installation, leading to the error message. Let’s look at a situation where we started an installation without setting CV_ASSUME_DISTID=OL8.

$cd $ORACLE_HOME
$./runInstaller -ignorePrereq -waitforcompletion -silent -applyRU /u01/stage/35643107 -responseFile /ora01/app/oracle/product/19c/install/response/db_install.rsp     
      
Preparing the home to patch...
Applying the patch /u01/stage/35643107...
Successfully applied the patch.
The log can be found at: /tmp/InstallActions2023-11-03_05-56-59PM/installerPatchActions_2023-11-03_05-56-59PM.log
Launching Oracle Database Setup Wizard...

[WARNING] [INS-08101] Unexpected error while executing the action at state: 'supportedOSCheck'
   CAUSE: No additional information available.
   ACTION: Contact Oracle Support Services or refer to the software manual.
   SUMMARY:
       - java.lang.NullPointerException
Moved the install session logs to:
 /ora01/app/oraInventory/logs/InstallActions2023-11-03_05-56-59PM


$ export CV_ASSUME_DISTID=OL8

$ ./runInstaller -ignorePrereq -waitforcompletion -silent   -responseFile /ora01/app/oracle/product/19c/install/response/db_install.rsp                   
ERROR: The home is not clean. This home cannot be used since there was a failed OPatch execution in this home. Use a different home to proceed.

Now as you can see above, the patch installation was completed, but the installer failed because the variable CV_ASSUME_DISTID was not set. Hence I restarted the installation without applyRU. But it failed with “ERROR: The home is not clean.”. The documented fix for this suggests to, cleanup the home, unzipping the software again, and restarting the software.

Debugging

I performed a bit of debugging and noticed that under the ORACLE_HOME/install directory, the process creates a lock file called patch.

$ cd /ora01/app/oracle/product/19c/install

$ ls -larth patch
-rw-r--r--.  1 oracle oinstall    0 Nov 15 17:55 patch

It looks like as long as the patch file exists, the installer will continue to complain that the Home is not clean and fail. Once i remove the patch lock file, I am able to override and continue with the software install. Again I wouldn’t do this on a production or a live system, since we don’t have Oracle’s blessings but on a sandbox or a test bed, go ahead and try it out !!


$ cd  $ORACLE_HOME/install/
$ rm patch

$ cd /ora01/app/oracle/product/19c
$ ./runInstaller -ignorePrereq -waitforcompletion -silent -responseFile /ora01/app/oracle/product/19c/install/response/db_install.rsp  
Launching Oracle Database Setup Wizard...

[WARNING] [INS-13014] Target environment does not meet some optional requirements.
   CAUSE: Some of the optional prerequisites are not met. See logs for details. installActions2023-11-03_06-22-48PM.log
   ACTION: Identify the list of failed prerequisite checks from the log: installActions2023-11-03_06-22-48PM.log. Then either from the log file or from the installation manual find the appropriate configuration to meet the prerequisites and fix it manually.
The response file for this session can be found at:
 /ora01/app/oracle/product/19c/install/response/db_2023-11-03_06-22-48PM.rsp

You can find the log of this install session at:
 /tmp/InstallActions2023-11-03_06-22-48PM/installActions2023-11-03_06-22-48PM.log


As a root user, execute the following script(s):
	1. /ora01/app/oraInventory/orainstRoot.sh
	2. /ora01/app/oracle/product/19c/root.sh

Execute /ora01/app/oraInventory/orainstRoot.sh on the following nodes:
[host901]
Execute /ora01/app/oracle/product/19c/root.sh on the following nodes:
[host901]

Again, software install, essentially in the example above, clearly the applyRU had succeeded in the first attempt, and the runInstaller had failed at the first OS pre-check. Hence it made sense to attempt software installation without redoing the cleanup and re-installation.

$ sqlplus

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Nov 15 18:30:41 2023
Version 19.21.0.0.0

Copyright (c) 1982, 2023, Oracle.  All rights reserved.

$ pwd
/ora01/app/oracle/product/19c/install

$ ls -l patch
ls: cannot access 'patch': No such file or directory

As we see we have a 19.21 home available for us. After the software installation completes, the patch file no longer exists. It appears the installer cleaned up the file post the software installation as expected. So now let’s attempt to create a database and see if everything is okay. Using these steps, let us create a db


$ echo $ORACLE_SID
cdb1
$ echo $PDB_NAME
pdb1
$ echo $DATA_DIR
/ora01/oradata
$ dbca -silent -createDatabase  .....
                                            
Prepare for db operation
8% complete
Copying database files
31% complete
....

100% complete
Database creation complete. For details check the logfiles at:
 /ora01/app/oracle/cfgtoollogs/dbca/cdb1.
Database Information:
Global Database Name:cdb1
System Identifier(SID):cdb1
Look at the log file "/ora01/app/oracle/cfgtoollogs/dbca/cdb1/cdb1.log" for 
oracle@host901 ~]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Nov 15 19:14:17 2023
Version 19.21.0.0.0

Copyright (c) 1982, 2023, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.21.0.0.0

SQL> show pdbs

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 PDB1 			  READ WRITE NO

As we can see, we are able to use the software to create databases and I couldn’t find any unintentonal consequences. That being said, while removing the patch folder has been observed to resolve the “The home is not clean” error in Oracle 19c installations, it’s important to note that this method is not officially documented by Oracle. Therefore, proceed with caution and at your own discretion. Also you can use the RPM method to install software and create a database, to avoid a lot of the hassle.