Unable to render template from CLI

I am doing some upgrading, and i am now having problems with rendering from the CLI. I have a cli command which pushes a notification to a user through websocket, and this notification is rendered with the ViewRenderer.
I am now getting this error: “PHP Fatal error: Uncaught Error: Call to a member function getRouteMatch() on null in /app/vendor/laminas/laminas-mvc/src/Service/ViewHelperManagerFactory.php:91”
Which kinda makes sense, as it’s CLI so there is no route-match. I guess it happens because i use $this->url(‘xxx’) in the template, to generate a link(this should still work in CLI though?)

Is there a config i need to change or is this a bug?