Skip to content

Non-existent tmpfile while storing after analysis with bazel #4601

@Szelethus

Description

@Szelethus

Describe the bug

CodeChecker store crashes with this message:

Traceback (most recent call last):
  File "codechecker_client/cli/store.py", line 904, in main
    temp_dir = tempfile.mkdtemp(suffix="-store", dir=args.input[0])
  File "python3/lib/python3.10/tempfile.py", line 384, in mkdtemp
    _os.mkdir(file, 0o700)
PermissionError: [Errno 13] Permission denied: 'bazel-out/k8-fastbuild/bin/codechecker_test_flatc/codechecker-files/data/tmpf0ogqboy-store'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "codechecker_common/cli.py", line 230, in main
    sys.exit(args.func(args))
  File "codechecker_client/cli/store.py", line 908, in main
    f"permissions to create the {temp_dir} "
UnboundLocalError: local variable 'temp_dir' referenced before assignment

This file does not exist.

CodeChecker version

[INFO 2025-06-12 10:31] - CodeChecker analyzer version:
---------------------------------------------------------------
Kind                 | Version                                 
---------------------------------------------------------------
Base package version | 6.26.0                                  
Package build date   | 2025-06-10T18:03                        
Git commit ID (hash) | 0bbf351e870c7056cd9cc0dc44a795c0fe805dfa
Git tag information  | 6.26                                    
---------------------------------------------------------------

[INFO 2025-06-12 10:31] - CodeChecker web version:
------------------------------------------------------------------------------
Kind                                | Version                                 
------------------------------------------------------------------------------
Base package version                | 6.26.0                                  
Package build date                  | 2025-06-10T18:03                        
Git commit ID (hash)                | 0bbf351e870c7056cd9cc0dc44a795c0fe805dfa
Git tag information                 | 6.26                                    
Server supported Thrift API version | 6.65                                    
Client Thrift API version           | 6.65                                    
------------------------------------------------------------------------------

bazel version:

bazel 6.5.0

codechecker_bazel version:

289b9cefca68c6f23e8a87ca332a9231de9c24ab

To Reproduce
Steps to reproduce the behaviour:

Download a bazel 6 compatible codebase.

git clone https://github.com/google/flatbuffers
git checkout v22.10.26

Apply this patch to enable CodeChecker analysis through bazel

diff --git a/BUILD.bazel b/BUILD.bazel
index f2aac0ae..edb35ade 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -89,0 +90,17 @@ cc_binary(
+#-------------------------------------------------------
+
+# codechecker rules
+load(
+    "@bazel_codechecker//src:codechecker.bzl",
+    "codechecker_test",
+)
+
+codechecker_test(
+    name = "codechecker_test_flatc",
+    targets = [
+        "flatc",
+    ],
+)
+
+#-------------------------------------------------------
+
diff --git a/WORKSPACE b/WORKSPACE
index 5b364e09..5029f47d 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -2,0 +3,22 @@ workspace(name = "com_github_google_flatbuffers")
+#----------------------------------------------------
+
+load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
+
+git_repository(
+    name = "bazel_codechecker",
+    remote = "https://github.com/Ericsson/codechecker_bazel.git",
+    branch = "main",
+)
+
+load(
+    "@bazel_codechecker//src:tools.bzl",
+    "register_default_codechecker",
+    "register_default_python_toolchain",
+)
+
+register_default_python_toolchain()
+
+register_default_codechecker()
+
+#----------------------------------------------------
+

Run CodeChecker analysis, attempt to store

bazel build //:codechecker_test_flatc
CodeChecker store bazel-out/k8-fastbuild/bin/codechecker_test_flatc/codechecker-files/data --url 0.0.0.0:8002/Default --name "bazel"

Metadata

Metadata

Assignees

Labels

bazel 🧩Directly or inderectly related to bazel supportbug 🐛

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions