Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodeChecker cannot execute if there isn't a clang binary on the system #3141

Closed
whisperity opened this issue Jan 13, 2021 · 1 comment · Fixed by #3194
Closed

CodeChecker cannot execute if there isn't a clang binary on the system #3141

whisperity opened this issue Jan 13, 2021 · 1 comment · Fixed by #3194
Labels
analyzer 📈 Related to the analyze commands (analysis driver) bug 🐛

Comments

@whisperity
Copy link
Contributor

Describe the bug
If clang is not found in PATH anywhere at all, the analyze and check commands fail to go because they try to always read a Clang version.

CodeChecker version

(Note that even running something as simple and completely orthogonal as a package version check wants to access Clang!!!)

╰─ ~/CodeChecker/build/CodeChecker/bin/CodeChecker version
CodeChecker analyzer version:
[WARNING 2021-01-13 17:56] - 'clang' binary can not be found in your PATH!
---------------------------------------------------------------
Kind                 | Version
---------------------------------------------------------------
Base package version | 6.16.0
Package build date   | 2021-01-13T17:50
Git commit ID (hash) | 9d23b7ba6d4c149a6fabf21579f08fc60ef4df1d
Git tag information  | 6.16
---------------------------------------------------------------

CodeChecker web version:
------------------------------------------------------------------------
Kind                          | Version
------------------------------------------------------------------------
Base package version          | 6.16.0
Package build date            | 2021-01-13T17:50
Git commit ID (hash)          | 9d23b7ba6d4c149a6fabf21579f08fc60ef4df1d
Git tag information           | 6.16
Server supported API (Thrift) | 6.37
Client API (Thrift)           | 6.37
------------------------------------------------------------------------

To Reproduce
Steps to reproduce the behaviour:

  1. Download and build CodeChecker.
  2. Install clang-tidy from the package manager, or have a binary release of Clang-Tidy, or compile it locally. Either way, do not have clang in the PATH, only clang-tidy.
  3. Try to run an check --analyzers clang-tidy ... or analyze --analyzers clang-tidy.
  4. Observe error:
╰─ which clang
clang not found

╰─ which clang-tidy
~/LLVM/Build/bin/clang-tidy

╰─ ~/CodeChecker/build/CodeChecker/bin/CodeChecker check -l compile_commands.json --analyzers clang-tidy
'clang' binary can not be found in your PATH!
'clang' binary can not be found in your PATH!
[WARNING 2021-01-13 17:56] - 'clang' binary can not be found in your PATH!
[ERROR 2021-01-13 17:56] - Running check failed.
Traceback (most recent call last):
  File "~/CodeChecker/build/CodeChecker/cc_bin/../lib/python3/codechecker_analyzer/cmd/check.py", line 819, in main
    analysis_exit_status = analyze_module.main(analyze_args)
  File "~/CodeChecker/build/CodeChecker/lib/python3/codechecker_analyzer/cmd/analyze.py", line 937, in main
    analyzer_env)
  File "~/CodeChecker/build/CodeChecker/lib/python3/codechecker_analyzer/analyzers/clangsa/version.py", line 73, in get
    errors="ignore")
  File "/usr/lib/python3.6/subprocess.py", line 356, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.6/subprocess.py", line 423, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1278, in _execute_child
    executable = os.fsencode(executable)
  File "/usr/lib/python3.6/os.py", line 800, in fsencode
    filename = fspath(filename)  # Does type-checking of `filename`.
TypeError: expected str, bytes or os.PathLike object, not NoneType
Traceback (most recent call last):
  File "~/CodeChecker/build/CodeChecker/cc_bin/../lib/python3/codechecker_analyzer/cmd/check.py", line 819, in main
    analysis_exit_status = analyze_module.main(analyze_args)
  File "~/CodeChecker/build/CodeChecker/lib/python3/codechecker_analyzer/cmd/analyze.py", line 937, in main
    analyzer_env)
  File "~/CodeChecker/build/CodeChecker/lib/python3/codechecker_analyzer/analyzers/clangsa/version.py", line 73, in get
    errors="ignore")
  File "/usr/lib/python3.6/subprocess.py", line 356, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.6/subprocess.py", line 423, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.6/subprocess.py", line 1278, in _execute_child
    executable = os.fsencode(executable)
  File "/usr/lib/python3.6/os.py", line 800, in fsencode
    filename = fspath(filename)  # Does type-checking of `filename`.
TypeError: expected str, bytes or os.PathLike object, not NoneType
Traceback (most recent call last):
  File "~/CodeChecker/build/CodeChecker/cc_bin/CodeChecker.py", line 141, in main
    sys.exit(args.func(args))
  File "~/CodeChecker/build/CodeChecker/cc_bin/../lib/python3/codechecker_analyzer/cmd/check.py", line 850, in main
    return analysis_exit_status
UnboundLocalError: local variable 'analysis_exit_status' referenced before assignment

Expected behaviour
CodeChecker acknowledges the fact that Clang does not exist on the system and goes on with only running Clang-Tidy.

Desktop (please complete the following information)

  • OS: Ubuntu 18.04.5 LTS

Additional context
This issue, together with #2670 makes it really hard to use CodeChecker for actively testing Tidy (and Tidy-only) contributions. I do not wish to have Clang SA built on the system because it's a lot of effort to always rebuild features that are not being used.

The culprit in the source code is here:

analyzer_clang_binary = \
context.analyzer_binaries.get(
clangsa.analyzer.ClangSA.ANALYZER_NAME)
analyzer_clang_version = clangsa.version.get(analyzer_clang_binary,
analyzer_env)

@whisperity whisperity added bug 🐛 analyzer 📈 Related to the analyze commands (analysis driver) labels Jan 13, 2021
@whisperity
Copy link
Contributor Author

Note that even removing the "name" for the clangsa analyzer from the package_layout.json file, i.e. deleting this line:

"clangsa": "clang",

does not solve the issue. The 'clang' binary can not be found in your PATH! prints (both the non-WARING and the [WARNING] ones) go away, but the three exception traces (and the fact that no analysis is run) remains the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer 📈 Related to the analyze commands (analysis driver) bug 🐛
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants