I guess that you are using PlantUML through some web server (not 100% sure, but I think this is the way VSCode integrate with PlantUML).
Now, there are some security issue regarding file access to local filesystem from web server. So by default, the PlantUML library disable file reading from local filesystem (and in that case %dirpath() returns an empty String in that case).
Fortunately, there are ways to enable this feature (although you must understand that it may have some security issues). It depends which server you run and how you launch it locally. Could you tell us more about this ? Thanks !