There are a few common situations that cause the G2 utilities to display errors concerning the inability to locate a required file or the default embedded database.
G2 Environment Unset
Caused when the setupEnv script to set the G2 environment variables hasn't be sourced under Linux.
This is resolved by sourcing the setupEnv script located in /opt/senzing/g2 (default deployment path):-
- source /opt/senzing/g2/setupEnv
To automate this step for your G2 user going forward, run the following command to amend your ~/.bashrc file. You will need to logout and login again or re-source your ~/.bashrc file for this change to be effective:-
- echo -e "\n #Source G2 environment \n source /opt/senzing/g2/setupEnv" >> ~/.bashrc
- source ~/.bashrc
G2 Deployed to Non-Default Path
By default G2 expects to be deployed to /opt/senzing/ . If you deploy G2 to a different path, the setupEnv, G2Module.ini and G2Project.ini files need to be modified to reflect the new path.
In the below you'll observe G2 has been deployed to the home directory of a user named g2 (hence the double /g2/g2/ !). In this instance the setupEnv file hasn't been modified to reflect this as seen in the value of the SENZING_ROOT environment variable.
To correct this you need to modify 3 files with the following commands to change the non-default deployment path to your desired path:-
- sed -i 's+/opt/senzing+/home/g2+g' *.ini
- sed -i 's+/opt/senzing+/home/g2+g' ../setupEnv
- source ../setupEnv
Note, these examples are run from the /home/g2/g2/python directory. Modify the /home/g2 component of the commands to reflect your deployment path.
Incorrect File or Directory Privileges
One example where incorrect directory and/or file privileges can occur is caused by extraction of the G2 package using the -C flag on the tar command. This can occur when requiring sudo privileges to extract directly to /opt/senzing and when /opt/senzing is owned by the root user.
Notice the user and group privileges for the g2 directory are set to 505. When trying to run G2 errors will be presented due to the privileges on the g2 files and directory structure.
The privileges for the /opt/senzing/g2 (or other deployment path) can be set to your g2 user and group with (assuming your user and group and both named g2):-
- sudo chown -R g2:g2 /opt/senzing/
If you are unsure about this step, don't have sudo privileges or a sys admin setup a user, directory or deployed G2 for you share these details with them, they will know how to remedy.