!include not working when running from a python program (latest version and Beta, too)

0 votes
asked Oct 14, 2018 in Bug by ashley (140 points)

When running PlantUML from a python program , the !include directive cannot find files.  (The python program is sphinx-contrib/plantuml (https://github.com/sphinx-contrib/plantuml)

I've seen the question "Latest PlantUML (Version 1.2018.11) cannot !include with pipe"  and downloaded the beta .jar.  But am still having the same problem:

Preprocessor Error: Cannot include plantuml-includes/simple-plantuml-styles.iuml

It fails if the !include is within the .puml file, and it fails if the -I option is used in the command line 

I put in some print statements to do some debugging and what I notice is that in net.sourceforge.plantuml.preproc2.PreprocessorInclude3.manageFileInclude,  after this line: 
  final FileWithSuffix f2 = new FileWithSuffix(importedFiles, withEnvironmentVariable(fileName), suf);

idx == -1 and 

f2.file is null

Here's what the print statement reveals when I run it from the python program (I added a toString() method for FileWithSuffix so I could display info about it.):

PLANTUML: in PreprocessorInclude3.manageFileInclude: FileWithSuffix f2 = net.sourceforge.plantuml.preproc.FileWithSuffix suffix: null description: plantuml-includes/simple-plantuml-styles.iuml entry: (null) file: NULL!
 

Preprocessor Error: Cannot include plantuml-includes/simple-plantuml-styles.iuml


Just in case it's helpful, the python code used to run PlantUML is:

subprocess.Popen( plantuml_cmd,
                      stdout=f,
                      stdin=subprocess.PIPE,
                      stderr=subprocess.PIPE,
                      cwd=absincdir )

where:

   plantuml_cmd is the command line used:
      java -jar plantuml.jar -Djava.awt.headless=true -pipe -charset UTF-8' -filename seq-with-include.puml 

  f is a File

absincdir is the directory where the .puml file is.  In this case the file to be included is in the subdirectory in this directory, too.  IOW:

  / <absincdir>
    seq-with-include.puml
    /plantuml-includes
      simple-plantuml-styles.ipuml

And the file seq-with-includes.puml  has this line in it:

!include plantuml-includes/simple-plantuml-styles.ipuml

3 Answers

0 votes
answered Oct 14, 2018 by plantuml (294,960 points)

Just to test, could you try if it's work using

!include simple-plantuml-styles.ipuml

Thanks

commented Oct 14, 2018 by ashley (140 points)
Didn't work.  Same errors (except of course the include is in the same directory as the .puml).
commented Oct 15, 2018 by ashley (140 points)
Yet another update:

It *works* if I use the absolute path to the include file.

So perhaps somewhere in PreprocessorInclude3, the current directory is not being set/used properly?
0 votes
answered Oct 15, 2018 by plantuml (294,960 points)
We've build a new beta ( 1.2018.12beta12 ) with more traces http://beta.plantuml.net/plantuml.jar

We've also upload a test http://beta.plantuml.net/testPipe.zip with our test case, result and trace. This one is working for us.

Could you test it on your side, and tell us if it's different from your case.

Thanks!
commented Oct 17, 2018 by ashley (140 points)
Still not working.

I'm going to see if I can come up with some simple python code to examine this more.  Seems that the problem is when *python calls the program.*
commented Oct 17, 2018 by plantuml (294,960 points)
It seems that something have been broken in V1.2018.11
(see https://github.com/hallvard/plantuml/issues/73 )
Note that you can use:
@startuml
path
@enduml
that prints current folder path.
Maybe it will help to understand what's going on.
commented Oct 17, 2018 by ashley (140 points)
The current directory (where the .puml file is located) is correct.  I used your suggestion above (putting it into a simple .puml file) and it's reported correctly.
It is definitely a problem accessing the 'include'-ed files with any kind of relative path name.
commented Oct 17, 2018 by plantuml (294,960 points)
Ok, could you build a simple .zip file that shows the issue ?
I'm not sure to understand it. Thanks !
+1 vote
answered Oct 17, 2018 by plantuml (294,960 points)
We've built a new beta http://beta.plantuml.net/plantuml.jar (V1.2018.12beta14) that fixes issue https://github.com/hallvard/plantuml/issues/73

Maybe it also fixes your issue.
commented Oct 18, 2018 by ashley (140 points)
Yes!  It's all working correctly now! :-D
...