Torizon IDE extension: try-update-template fails

I’ve just installed a fresh Windows 11 PC and I set up Torizon IDE Extension (v 3.3.0) following these steps.

I did checkout of my torizoncore-builder project (that I use successfully on my old PC inside a ubuntu 22-04 WSL distro.

And I took the opportunity of new PC to updating everything.

So I run try-update-template task, but it fails with the following log:

Executing task: pwsh -nop /home/username/repo/tcb_project/.conf/projectUpdater.ps1 /home/username/repo/tcb_project tcb_project 0

⚠️  project updater updated, running it again
Your template is on Torizon OS version 6 and you are updating it to a template in Torizon OS version 7
Are you sure you want to proceed with the update? [y/n]: y
⚠️  On Torizon 7, the scripts are moved from powershell to a Python shell (https://xon.sh/). So, removing the powershell scripts…
🐚 SETUP XONSH
xonsh is already installed, updating torizon-templates-utils …
Collecting git+https://github.com/torizon/vscode-torizon-templates.git@main#subdirectory=scripts/utils/pip
Cloning 
 (to revision main) to /tmp/pip-req-build-k55_zblb
Running command git clone --filter=blob:none --quiet 
 /tmp/pip-req-build-k55_zblb
Did not find branch or tag ‘main’, assuming revision or ref.
Running command git checkout -q main
error: pathspec ‘main’ did not match any file(s) known to git
error: subprocess-exited-with-error

× git checkout -q main did not run successfully.
│ exit code: 1
╰─> No available output.

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed to build ‘git+https://github.com/torizon/vscode-torizon-templates.git@main#subdirectory=scripts/utils/pip’ when git checkout -q main
‘/home/username/.local/pipx/venvs/xonsh/bin/python -m pip install --force-reinstall git+https://github.com/torizon/vscode-torizon-templates.git@main#subdirectory=scripts/utils/pip’ failed
all ok ✅
The latest Torizon OS major version is 7
But your templates repository is using the major version 6.
Check the torizon.templatesBranch property in your settings.json
Your template is on Torizon OS major version 6 and you are updating it to a template in Torizon OS major version 7
Are you sure you want to proceed with the update? [y/n] y
✅ Latest scripts and documentation merged
xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE =
Traceback (most recent call last):
File “/home/username/repo/tcb_project/.conf/project-updater.xsh”, line 477, in
_update_table = _update_table.replace(“$projectName”, project_name)

TypeError: replace() argument 2 must be str, not None
❌ Error updating the project

The terminal process “pwsh ‘-nop’, ‘/home/username/repo/tcb_project/.conf/projectUpdater.ps1’, ‘/home/username/repo/tcb_project’, ‘tcb_project’, ‘0’” terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.


Hi, I’m the Toradex AI Assistant.

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


The issue you’re encountering appears to be related to the project update process when migrating from Torizon OS 6 to Torizon OS 7. The error TypeError: replace() argument 2 must be str, not None suggests that the project_name variable is None during the update process.

Root Cause Analysis

The error occurs in the project-updater.xsh script when it tries to replace $projectName with a None value(1). This script is used to update projects to the latest version of the template source(1).

Troubleshooting Steps

1. Check Project Metadata

First, verify your project’s metadata file contains the required information:

Check the .conf/metadata.json file in your project directory(1). This file should contain:

  • projectName: The name you input when creating the project
  • templateName: The name of the template source folder
  • containerName: The container name you input when creating the project
  • torizonOSMajor: The major version of Torizon OS(1)

2. Verify Project Structure

Ensure your project has the proper workspace structure with all required files in the .conf directory(1):

  • .conf/metadata.json
  • .conf/project-updater.xsh
  • .conf/update.json

3. Manual Metadata Fix

If the metadata.json file is missing or corrupted, you may need to recreate it with the proper structure:

{
    "projectName": "your-project-name",
    "templateName": "your-template-name", 
    "containerName": "your-container-name",
    "torizonOSMajor": "6"
}

(1)

4. Alternative Approach

Since you’re migrating from Torizon OS 6 to 7, consider creating a new project with the Torizon OS 7 template and manually migrating your application code, as the update process involves significant changes including the migration from PowerShell to Python shell (xonsh)(1).

The workspace structure documentation indicates that the project-updater.xsh script uses data from metadata.json to update projects(1), so ensuring this file is properly formatted is crucial for successful updates.

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.

Greetings @vix,

Could you share the initialization logs of our extension. We want to make sure everyone looks correct, and sane on startup.

Best Regards,
Jeremias

Hi @jeremias.tx

Here are the logs

[02-20 17:57:21.490] Activating Torizon IDE …
[02-20 17:57:21.490] Torizon IDE version :: 3.3.0
[02-20 17:57:22.818] Latest Torizon IDE published :: 3.3.113
[02-20 17:57:22.818] Telemetry is enabled
[02-20 17:57:22.818] Extension collects completely anonymous telemetry data about templates usage. Participation in this anonymous program is optional, and you may opt-out if you’d not like to share any information. Check: Settings - Data Collection | Toradex Developer Center
[02-20 17:57:22.818] Telemetry allows us to accurately gauge templates usage. This data will help us to focus better on the most used templates, adding new features and putting effort in the right place.
[02-20 17:57:22.818] Resolving host IP address …
[02-20 17:57:23.916] Host IP address OK
[02-20 17:57:23.916] Bash as default shell OK
[02-20 17:57:23.934] Docker installed OK
[02-20 17:57:24.050] Docker running OK
[02-20 17:57:24.201] Docker compose OK
[02-20 17:57:24.210] PowerShell OK
[02-20 17:57:24.218] git OK
[02-20 17:57:24.227] dig OK
[02-20 17:57:24.236] avahi-resolve OK
[02-20 17:57:24.247] nmap OK
[02-20 17:57:24.256] iputils-ping OK
[02-20 17:57:24.265] file OK
[02-20 17:57:24.274] sshpass OK
[02-20 17:57:24.338] iproute2 OK
[02-20 17:57:24.350] rsync OK
[02-20 17:57:24.379] python3 OK
[02-20 17:57:24.389] pipx OK
[02-20 17:57:24.390] Cloning project templates
[02-20 17:57:24.390] Templates repo: GitHub - torizon/vscode-torizon-templates: VS Code Torizon Integrated Development Environment Templates
[02-20 17:57:24.390] Templates branch: bookworm-7
[02-20 17:57:24.390] Templates tag/hash: tos7
[02-20 17:57:24.400] Project templates clone of branch bookworm-7 OK
[02-20 17:57:24.726] Project templates fetched OK
[02-20 17:57:24.742] Checkout templates repo to tag origin/bookworm-7 OK
[02-20 17:57:30.490] xonsh installation OK
[02-20 17:57:30.490] WARNING :: Project name not found in workspace metadata for single container workspace, or it matches the workspace name.
[02-20 17:57:30.491] Checking connected devices …
[02-20 17:57:30.491] Scanning Torizon devices …
[02-20 17:57:30.499] Debian bookworm packages list load OK
[02-20 17:57:30.499] Debug id_rsa OK
[02-20 17:57:30.895] Torizon IDE extension activated

After discussing with the team, we believe we know what the issue is here.

Your old project seems to have been created when our extension still used powershell scripting to facilitate it’s use. The current project templates that you are trying to update to, now use xonsh instead of powershell.

According to our team, because of this some aspects are not migrated perfectly and can cause issues like what you’re seeing here. The team will work to improve the migration behavior between the older powershell templates and the current xonsh templates.

For now though, the best solution would be to just create a new project, using the new templates. Then just copy your code/work over from your old project into the new project manually. Apologies for the inconvenience.

Best Regards,
Jeremias

Yes, I confirm this.

For now though, the best solution would be to just create a new project, using the new templates. Then just copy your code/work over from your old project into the new project manually.

I’ll do this and I let you know in case I need help (powershell is a known tool for me; I don’t have experience with xonsh).

  1. The first thing that I want to report is that the default settings.json file for torizoncore-builder project contains a “docker_tag” item. But I don’t think it’s necessary.

    Can this be removed?

  2. The second one:

    does a tcb-bundle task exists in the new template? If not, how can I write it?

  3. Why both the workspace name and tcb.packageName cannot contain _ and - chars for a tcb project? I can understand the packageName for a docker project, but I can’t see nay reason for tcb

The first thing that I want to report is that the default settings.json file for torizoncore-builder project contains a “docker_tag” item. But I don’t think it’s necessary.

This is just an extraneous setting that gets pulled into every project as a “common” setting. For TCB it can be ignored. Your feedback was passed to our VSCode IDE team.

does a tcb-bundle task exists in the new template? If not, how can I write it?

This task was removed as it’s expected that everything be done through the build command and it’s yaml file. Otherwise if you want to re-implement this for some reason, this commit is the one that removed the task: Add task tests for tcb template · torizon/vscode-torizon-templates@b47f52b · GitHub

Why both the workspace name and tcb.packageName cannot contain _ and - chars for a tcb project? I can understand the packageName for a docker project, but I can’t see nay reason for tcb

This is just a common rule enforced on all project types to avoid having to create special cases or exceptions on a per-project basis.

Best Regards,
Jeremias