4

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.

jww
  • 97,681
  • 90
  • 411
  • 885
Sid Gairola
  • 101
  • 1
  • 6

2 Answers2

4

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.

Caleb
  • 1,143
  • 5
  • 13
  • I am following the instructions on this link https://scan.coverity.com/download?tab=cxx And yes i did only copy the bin folder to my project. – Sid Gairola Jan 05 '17 at 05:56
  • Also how much time does it take for my project to get verified ? – Sid Gairola Jan 05 '17 at 07:34
  • I can't really comment on how long it takes for your project to get verified - I don't work on the SCAN side of things, just the compiler integration side of things. Since you only copied the bin folder, that'd explain your problem. You'll either need to copy everything or use `--prevent-root`. It's possible that creating a `bin/` symlink to the Coverity installation's `bin/` may work for you, instead of outright copying the files. – Caleb Jan 05 '17 at 20:14
  • thanks it worked, gave the exact path of the bin folder in the Coverity installation's bin. – Sid Gairola Jan 06 '17 at 04:56
  • What is the name of the shared object that Coverity is looking for? (Adding Coverity root folder, the `lib/` folder and the `bin/` folder to `$PATH` did not help me. Neither did `--prevent-root`. Neither did setting `CLASSPATH` to the jre8 `lib/` folder). – jww Mar 26 '18 at 05:13
  • And `ldd /usr/local/bin/cov-analysis-linux64-2017.07/bin/cov-build` just says *`not a dynamic executable`*. – jww Mar 26 '18 at 05:18
  • I got the same problem in a CMake based project but I solved it just adding the `bin` to the `$PATH`. My steps was: 1. `export PATH=$PATH:/home/user/cov-analysis-linux64-2017.07/`; 2. `cov-build --dir cov-int make` (notice I removed the `./` from the command line, since `bin` was added to `$PATH`) – silvioprog Aug 15 '18 at 05:26
0

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
Marcello DeSales
  • 21,361
  • 14
  • 77
  • 80