empty %dirpath() from VSCode

0 votes
asked Apr 24, 2020 in Question / help by ncasaux

Hello,

The function %dirpath() returns an empty string when called from VSCode using the PlantUML Extension.

I'm aware that PlantUML does not provide this extension, but does it seem "normal" to you ?

Thanks in advance!

1 Answer

0 votes
answered Apr 24, 2020 by plantuml (298,440 points)
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 !
commented Apr 24, 2020 by ncasaux
I'm not very familiar with how this extension works, hence I don't know if VSCode starts its own server actually... They suggest to use a PlantUML server, but I'm not sure how the local rendering is done.

Currently I'm simply using VScode on Windows 10 and the PlantUML extension, I didn't setup any server.

Hope it helps...
commented Apr 24, 2020 by plantuml (298,440 points)
Yes it does help :-)

Actually, it probably means that you are currently using the online server hosted at http://www.plantuml.com/plantuml

One way to double-check this is to disable your internet connection: if diagram rendering do not work any more, it's probably because you cannot reach http://www.plantuml.com/plantuml

Anyway, that's why %dirpath() is not working for you : since your requests run on our server, we do not want people to be able to list files from there, nor to load file locally store on our server. Does it make sense to you ? I hope I did not loose you on that...
commented Apr 24, 2020 by ncasaux
Well, I did the test in "offline mode" (disconnected from my WIFI), and the rendering is working.properly. So it's not using the server you mentionned.

By the way, I should have mention that after the extension installation, graphviz had to be installed also on my laptop. I guess the image rendering is done through my local graphviz .exe file.
commented Apr 24, 2020 by plantuml (298,440 points)
Ok, so it's probably local though some local webserver.

Which extension are you using ? I found at least two of them :

https://marketplace.visualstudio.com/items?itemName=jebbs.plantuml#user-content-about-render

https://marketplace.visualstudio.com/items?itemName=Mebrahtom.plantumlpreviewer
commented Apr 24, 2020 by plantuml (298,440 points)
I suggest that you open an issue there https://github.com/qjebbs/vscode-plantuml/issues

Put a link to this current discussion on the issue you are going to open.

This way, Jebbs teams will come back to us to we can see how to fix it (it really depends on how they have implemented their server).

Please be very precise in the issue about your configuration (that is, which way you are using to integrate with PlantUML : there seems to have several ones)
commented Apr 25, 2020 by ncasaux

Issue raised here: https://github.com/qjebbs/vscode-plantuml/issues/312

Thanks for your help!

commented May 18, 2020 by ncasaux
I got an answer on the issue:

https://github.com/qjebbs/vscode-plantuml/issues/312#issuecomment-630046441

Does this "parameter" arg exist ?
...