Git based version not found in torizon ide 3.6.0

We use a git-based version numbering system for out embedded application (tag plus commit hash).

Having updated our configuration files to match the latest Torizon IDE extension template for the latest version (3.6.0) I found that the entries in CMakeLists.txt to extract the version string from git now no longer work.

find_package(Git REQUIRED)
execute_process(
    COMMAND ${GIT_EXECUTABLE} describe --long
    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
    OUTPUT_VARIABLE PROJECT_VERSION
    OUTPUT_STRIP_TRAILING_WHITESPACE
    )
set( OUTPUT_NAME ${PROJECT_NAME}_${PROJECT_VERSION} )

This is a Qt C++ widgets- based project.

The problem seems to be with git’s handling of the directory as it is mounted in the container. In the VSCode output window I see

fatal: detected dubious ownership in repository at '/home/torizon/app'
To add an exception for this directory, call:

        git config --global --add safe.directory /home/torizon/app

even though I have issued the command (and restarted the VSCode folder).

When git is run in the container from CMake, is it run as the “torizon” user ?

Or maybe I should add the mounted project directory to safe.directory ?

Hi, I’m the Toradex AI Assistant.

I might make mistakes or occasionally get you wrong. Our support team will step in if needed.


I’d be glad to help! Could you let me know which OS and version you are using? Also, which hardware platform are you running on (e.g., Verdin iMX8M Plus, Verdin AM62, Apalis iMX8QP)?

To get detailed information about your system, you can use the tdx-info command on your device: Getting Device Information with Tdx-Info | Toradex Developer Center

Common platforms to mention:

  • Hardware: Verdin iMX8M Plus, Verdin AM62, Aquila AM69, Apalis iMX8QP, Colibri iMX8X, Ivy Carrier Board, Ixora Carrier Board, Mallow Carrier Board, IMX95
  • OS: Yocto 7.2.0, Torizon 6.8.2, Torizon OS 6, BSP 7, BSP 6, Torizon OS 7.2.0-build.13
  • Implementation: Docker, Chromium, Qt, weston

The git ownership issue you’re experiencing is related to how the workspace directory is mounted in the container (1). The SDK container mounts the project workspace into the container using bind mounts (1). When containers run in an isolated environment, the SDK container requires mounting the workspace directory into it, and this container runs on the host machine (1).

Once you provide the platform details, I can give you specific guidance on resolving the git ownership issue in your CMake-based Qt C++ project.

Best regards, Toradex AI Assistant.


Did you like my answer? :+1: :-1:

If I answered your question, please tick the “Solution” checkbox.

For follow-up questions to me, please use @ToradexAI in your post.

  • Hardware: Colibri iMX8X, custom Carrier Board
  • OS: Torizon OS 7
  • Implementation: Docker, Qt, weston

Thank you for providing the platform details! The git ownership issue you’re experiencing is indeed related to how the workspace directory is mounted in the SDK container.

Understanding the Issue

The SDK container mounts the project workspace into the container, and since containers run in an isolated environment, the SDK container requires mounting the workspace directory into it(1). This container runs on the host machine, but the file ownership and permissions can cause git to reject the repository as “dubious”(1).

Solutions

Option 1: Configure Git in the SDK Container

You can modify your Dockerfile.sdk to add the git safe directory configuration. Add this line to your SDK container:

RUN git config --global --add safe.directory /home/torizon/app

(1)

Option 2: Set Git Configuration in CMake

Alternatively, you can handle this directly in your CMakeLists.txt before calling git commands:

find_package(Git REQUIRED)
execute_process(
    COMMAND ${GIT_EXECUTABLE} config --global --add safe.directory ${PROJECT_SOURCE_DIR}
    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
    OUTPUT_QUIET
    ERROR_QUIET
)
execute_process(
    COMMAND ${GIT_EXECUTABLE} describe --long
    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
    OUTPUT_VARIABLE PROJECT_VERSION
    OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(OUTPUT_NAME ${PROJECT_NAME}_${PROJECT_VERSION})

Option 3: Environment Variable Approach

You can also set the GIT_CONFIG_GLOBAL environment variable in your build task or container to point to a custom git config that includes the safe directory setting.

Why This Happens

The bind-mount operation (-v ${workspaceFolder}:${config:torizon_app_root}) shares the directory between the workspace and the SDK container(1). Since the directory is shared between the workspace and the SDK container, the ownership and permissions from the host system may not match what git expects inside the container environment(1).

The SDK container runs with specific user permissions, and when git detects that the repository directory has different ownership than expected, it treats it as potentially unsafe and refuses to operate on it.

Best regards, Toradex AI Assistant.


Did you like my answer? :+1: :-1:

If I answered your question, please tick the “Solution” checkbox.

For follow-up questions to me, please use @ToradexAI in your post.

This seems to be working :smiley: (although I preferred not to suppress the output, in case of failure).

I now just have to wait for close to an hour for the project to rebuild - but that’s another battle :wink: