Torizon IDE Extension; Cannot read properties of undefined (reading 'replaceAll')

As of today trying to debug my project fails with the following error: Cannot read properties of undefined (reading ‘replaceAll’)

Running the “run-container-torizon-release-arm64” task works without any problems (so i presume it should not be a problem with the installed version of docker, like in similiar posts).

Debugging the project, still worked last week.
New projects with the CMake template also fail to debug.

Was there a change in one of the Torizon Extension updates that may have led to this problem?
Is there a debug output, with more information about this error? The only thing I am currently getting is a popup with the mentioned message.

best regards

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

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


Hello! Thank you for your detailed question.

The error message “Cannot read properties of undefined (reading ‘replaceAll’)” suggests there might be an issue within the Torizon extension’s internal scripting—possibly related to a recent update or a subtle misconfiguration.

Debugging Further

You can obtain more detailed debug output from VS Code’s Developer Tools:

  1. Open the Command Palette (Ctrl+Shift+P).
  2. Enter and select Developer: Toggle Developer Tools.
  3. In the new panel, open the Console tab and reproduce the error. Check for related error messages and stack traces, which might reveal more about the failure.
    See here for reference.

Potential Causes & Next Steps

  • Since you mentioned the “run-container-torizon-release-arm64” task works, Docker is likely not the root cause.
  • The issue affecting both existing and new projects suggests the extension or a related dependency (on the host or VS Code) might have changed recently.
    • Recent Extension Updates: There have been some reports where updates (VS Code or Torizon extension) introduce incompatibilities, especially if your VS Code is not the latest or unexpectedly updated.
  • Some versions of Node.js or VS Code ship without the replaceAll string method. Make sure your VS Code is up-to-date.

Actions to Try

  • Check for Extension Updates:
    • Go to Extensions in VS Code, search for “Torizon IDE Extension”, and ensure it’s the latest version.
  • Check Your VS Code Version:
    • Make sure VS Code is up-to-date. replaceAll became natively available in Node 15+ and VS Code 1.56+.
  • View the Debug Output:
    • Check both the Console in Developer Tools and the Terminal output for more logs during the start of the debug session.
  • If the Issue Persists:
    • You can also try uninstalling and reinstalling the Torizon extension, as sometimes stale extension state can cause issues.

Resources

If you gather logs from the Developer Tools Console, feel free to share snippets (without sensitive data) and I can help interpret them.

Best regards, Toradex AI Assistant.

It seems like there might be an incompatibility between the newest VS-Code Version and the Torizon IDE.

Torizon IDE: V3.0.4
VS-Code: V 1.100.1
Leads to the problem described above.

A downgrade of VS-Code to V1.99.1 now lets me debug my old Torizon OS6 template projects again.
VS-Code V1.99.3 still had some problems.

Debugging a completely new CMAKE C/C++ template (under code V1.99.1) fails with the following message:

*  Executing task: DOCKER_HOST= docker build --pull -f /home/aig/workspace/test/test/Dockerfile.sdk /home/aig/workspace/test/test -t cross-toolchain-arm64-test --build-arg IMAGE_ARCH=arm64 --build-arg GPU=-imx8 --build-arg APP_ROOT=/home/torizon/app 

[+] Building 20.5s (3/3) FINISHED                                                                                                               docker:default
 => [internal] load build definition from Dockerfile.sdk                                                                                                  0.0s
 => => transferring dockerfile: 1.07kB                                                                                                                    0.0s
 => WARN: InvalidDefaultArgInFrom: Default value for ARG torizon/cross-toolchain-${IMAGE_ARCH}:${CROSS_SDK_BASE_TAG} results in empty or invalid base im  0.0s
 => ERROR [internal] load metadata for docker.io/torizon/cross-toolchain-arm64:4                                                                         20.4s
 => [auth] torizon/cross-toolchain-arm64:pull token for registry-1.docker.io                                                                              0.0s
------
 > [internal] load metadata for docker.io/torizon/cross-toolchain-arm64:4:
------

 1 warning found (use docker --debug to expand):
 - InvalidDefaultArgInFrom: Default value for ARG torizon/cross-toolchain-${IMAGE_ARCH}:${CROSS_SDK_BASE_TAG} results in empty or invalid base image name (line 16)
Dockerfile.sdk:16
--------------------
  14 |     
  15 |     # BUILD ------------------------------------------------------------------------
  16 | >>> FROM torizon/cross-toolchain-${IMAGE_ARCH}:${CROSS_SDK_BASE_TAG}
  17 |     
  18 |     ARG APP_ROOT
--------------------
ERROR: failed to solve: torizon/cross-toolchain-arm64:4: failed to resolve source metadata for docker.io/torizon/cross-toolchain-arm64:4: failed to do request: Head "https://registry-1.docker.io/v2/torizon/cross-toolchain-arm64/manifests/4": dial tcp: lookup registry-1.docker.io on 127.0.0.53:53: read udp 127.0.0.1:33698->127.0.0.53:53: i/o timeout

Hey @aigF

I’m sorry that you are facing this issues. This was already reported to Microsoft on the VS Code repo. It was fixed but not planning for a release yet :frowning:.

Meanwhile, a workaround is to change in your project .vscode/launch.json from the following:

           "sourceFileMap": {
                "${config:torizon_app_root}": "${workspaceFolder}"
            },

with:

           "sourceFileMap": {
                "/home/torizon/app": "${workspaceFolder}"
            },

Or /root/app if you need to run the app with superuser privileges.

BR,

Hi @matheus.tx,

it seems close to working now, but for some reason the a debug attempt ends up asking for the password of the verdin, which wouldn’t be a problem, but it seems the default password (which is already defined in the settings.json) doesnt work.

See the error below:

Executing task: DOCKER_HOST=172.16.60.33:2375 LOCAL_REGISTRY=172.16.122.210 TAG=arm64 GPU=-imx8 DEBUG_SSH_PORT=2230 DEBUG_PORT1= DEBUG_PORT2= DEBUG_PORT3= docker compose -p torizon up -d pm2-test-software-debug 

WARN[0000] The "DOCKER_LOGIN" variable is not set. Defaulting to a blank string. 
WARN[0000] Found orphan containers ([torizon-mainmodule-debug-1]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up. 
[+] Running 2/2
 ✔ Container torizon-pm2-test-software-debug-1                                        Started                                                                  5.5s 
 ! pm2-test-software-debug Published ports are discarded when using host network mode                                                                          0.0s 
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: rsync -P -av -e ssh -p 2230 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null /home/aig/95491/software/pm2TestSoftware/build-arm64/bin/ torizon@172.16.60.33:/home/torizon/app 

Warning: Permanently added '[172.16.60.33]:2230' (ED25519) to the list of known hosts.
torizon@172.16.60.33's password:
Permission denied, please try again.
torizon@172.16.60.33's password: 
Permission denied, please try again.
torizon@172.16.60.33's password: 
Connection closed by 172.16.60.33 port 2230
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(232) [sender=3.2.7]

 *  The terminal process "rsync '-P', '-av', '-e', 'ssh -p 2230 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null', '/home/aig/95491/software/pm2TestSoftware/build-arm64/bin/', 'torizon@172.16.60.33:/home/torizon/app'" terminated with exit code: 255. 

Best regards

Hi @matheus.tx ,

I have fixed the last mentioned problem and am now able to run the project on the device in debug mode.

The only problem I now seem to have is, that all Breakpoints are skipped without triggering (even those i am 100% sure are being reached)

This also happens with a completely new project, when I set the breakpoint on the “std::cout << “Hello Torizon!” << std::endl;”

best regards

Hi @aigF !

Thanks for the details.

I will need to try to reproduce it on my side. I will update you here as soon as I have some news.

Best regards,

Hi @aigF !

I just started a new C++ project on Torizon IDE and I managed to build it, push to the module and debug it with breakpoints working, so I couldn’t reproduce the issue on your side.

My setup:

  • Host PC: Ubuntu 22.04
  • VS Code: 1.100.0
  • Torizon IDE: 3.0.4
  • Toradex Module
    • Verdin iMX8MP Q 4GB WB IT V1.1A
    • Torizon OS 7.2.0-build.13

Could you please share more details of what is happening when you try to use breakpoints?

Maybe some message from DEBUG CONSOLE tab in VS Code? Or some message from the debug task’s terminal?

Best regards,

Hi @henrique.tx

The big difference to your test environment I am seeing is that my tests are currently running on a Verdin with Torizon OS 6.6.1+build.12.

Which does make sense that new there are problems with the new template if its for Torizon OS 7.
Is there a way to use the older template when generating a project?
Or is it generally adviced to upgrade to Torizon7?

best regards

Hi @aigF !

We do recommend following newer releases. Right now, the latest quarterly is Torizon OS 7.2.0 (Download Links | Toradex Developer Center, also directly available via Toradex Easy Installer).

Actually, Torizon OS 6.6.1 is deprecated, since it is already an old quarterly release (Torizon OS 6.6.1 Quarterly Release).

If you do not have a reason to be on Torizon OS 6, please upgrade to Torizon OS 7.

In general, we recommend keeping your module updated to the latest quarterly release.

Best regards,

Hi @henrique.tx ,

I seems like the OS version is indeed the reason for the debugging problem.
Thank you for the help.

But might I still suggest adding the possibility to select older templates in the IDE, since their might be reasons to still create projects on a maintenance release, like the OS 6.8.

best regards

Hi @aigF !

Great that this is solved! :slight_smile:

It is actually possible via the torizon.templatesTag property in settings.json, as documented in Workspace - Settings | Toradex Developer Center. But I agree that this is a bit hidden.

We are working on it to make this possibility clearer.

Best regards,

Hi @henrique.tx ,

that is good to know.
But it seems like a downgrade from OS7 to OS6, with the “try-update-template”-Task leads to the following error:

Executing task: echo echo 'Templates repo fetched!' 

echo Templates repo fetched!
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: xonsh /home/aig/95491/software/TestSoftware/pm2TestSoftware/.conf/project-updater.xsh /home/aig/95491/software/TestSoftware/pm2TestSoftware pm2TestSoftware False 

  File "/home/aig/95491/software/TestSoftware/pm2TestSoftware/.conf/project-updater.xsh", line 618
    cp -f @(f"{os.environ['HOME']}/.apollox/{_template_name}/{_update['source']}") .
         ^
SyntaxError: ('code: @(',)

 *  The terminal process "xonsh '/home/aig/95491/software/TestSoftware/pm2TestSoftware/.conf/project-updater.xsh', '/home/aig/95491/software/TestSoftware/pm2TestSoftware', 'pm2TestSoftware', 'False'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

With the following settings:

  "torizon.templatesBranch": "bookworm",
  "torizon.templatesTag": "v2.8.1"

Best regards

Hi @aigF !

This task was designed to help developers to update between minor releases (iow, within the same major version). So it is not expected to be used to update between major releases.

Could you please share details about your use case? Do you need to downgrade a project from Torizon OS 7 to Torizon OS 6?

Best regards,

Hi @henrique.tx ,

we have a project currently running on OS6, were we wish to add another application.
But new applications seem to automatically pull the newest template, which is for OS7.

As described before, debugging with the new template in OS6 only seems to work partially and does not support breakpoints.

best regards

Hi @aigF

Thanks for the details.

Sorry: before, I didn’t explicitly say you need to set torizon.templateTag in global settings.json (instead of the one from the project). After doing that, you can reload the window and create the Torizon project.

Also, please note that the latest v2.x.x tag in GitHub - torizon/vscode-torizon-templates: VS Code Torizon Integrated Development Environment Templates is currently v2.8.1.

I just tested on my side and it worked:

Best regards,

Hi @henrique.tx,

this seems to work for me.
Thank you for all the help