Coverity and "Failed to initialize ICU, try using the --prevent-root option"

2.8k views Asked by At

I have the bin directory in the build directory of my project.

When I run the command ./bin/cov-build --dir cov-int make I get the following error -

[ERROR] Failed to initialize ICU, try using the --prevent-root option.

2

There are 2 answers

7
Caleb On

Coverity uses ICU to handle multibyte encodings. This requires the ICU data files, present in the Coverity installation. That error suggests those files are either missing or not present in the expected location, and suggests you try using --prevent-root to tell it where it can expect to find the files.

Did you only copy the bin directory to your project? This would likely explain the issue, and using --prevent-root to point to the actual Coverity installation should resolve it.

0
Marcello DeSales On

Dockerized version - Minimum packages

  • I have dockerized coverity. Considering the whole enterprise version install equates to 4.9GB, I could get away with coverity for python by trial-and-error by selecting the packages needed...
  • According to Docker's layers/caching rules, docker will write a layer after the execution of any instruction. For this reason, you can design the docker image with Multi-layers and select only the files needed.

After I copied the correct set of dirs, the error went away and I could execute cov-configure python...

Dockerfile

  • Incomplete source-code...
COPY --from=prepare-install /opt/coverity/analysis/bin /opt/coverity/analysis/bin
COPY --from=prepare-install /opt/coverity/analysis/bin/cov-* /opt/coverity/analysis/bin/
COPY --from=prepare-install /opt/coverity/analysis/config/parse_warnings.conf.sample /opt/coverity/analysis/config/parse_warnings.conf.sample
COPY --from=prepare-install /opt/coverity/analysis/config/user_nodefs.h /opt/coverity/analysis/config/user_nodefs.h
COPY --from=prepare-install /opt/coverity/analysis/config/wrapper_escape.conf /opt/coverity/analysis/config/wrapper_escape.conf

# ls /opt/coverity/analysis/config/templates/ | xargs -I {} echo "COPY --from=prepare-install /opt/coverity/analysis/config/templates/{} /opt/coverity/analysis/config/templates/{}"
COPY --from=prepare-install /opt/coverity/analysis/config/templates/python /opt/coverity/analysis/config/templates/python
# File doesn't exist: '/opt/coverity/analysis/config/templates/generic/generic_switches.dat'
COPY --from=prepare-install /opt/coverity/analysis/config/templates/generic /opt/coverity/analysis/config/templates/generic
COPY --from=prepare-install /opt/coverity/analysis/config/templates/generic_linker /opt/coverity/analysis/config/templates/generic_linker
COPY --from=prepare-install /opt/coverity/analysis/config/templates/xlc /opt/coverity/analysis/config/templates/xlc

# Addressing the error
#  > [coverity-python 6/6] RUN cov-configure --python: No valid XML DTD catalog found, try using the --prevent-root option.
COPY --from=prepare-install /opt/coverity/analysis/certs /opt/coverity/analysis/certs
COPY --from=prepare-install /opt/coverity/analysis/dtd /opt/coverity/analysis/dtd
COPY --from=prepare-install /opt/coverity/analysis/xsl /opt/coverity/analysis/xsl

# Was failing with https://stackoverflow.com/questions/65184937/fatal-python-error-init-fs-encoding-failed-to-get-the-python-codec-of-the-file
# As it is configured with python3.9, not python3.7 as it is packaged
COPY --from=prepare-install /opt/coverity/analysis/lib/python3.9 /opt/coverity/analysis/lib/python3.9
...
...

Docker Image

```console
$ docker images | more                                                                                                                                
REPOSITORY                                                                                                                    TAG                                                                          IMAGE ID             SIZE
dockerhub.company.com/coverity/python:2022.6.0    605MB