Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to run plantuml in an org-babel src block #165

Open
exaos opened this issue Jan 28, 2023 · 1 comment
Open

Failed to run plantuml in an org-babel src block #165

exaos opened this issue Jan 28, 2023 · 1 comment

Comments

@exaos
Copy link

exaos commented Jan 28, 2023

Summary

In an org-mode file, I want that the following plantuml source block can generate an inline image automatically which executing org-babel-execute-src-block (or press C-cC-c).

#+BEGIN_SRC plantuml :file test_uml.png  :cmdline -charset UTF-8
  title Example Sequence Diagram
  activate Client
  Client -> Server: Session Initiation
  note right: Client requests new session
  activate Server
  Client <-- Server: Authorization Request
  note left: Server requires authentication
  Client -> Server: Authorization Response
  note right: Client provides authentication details
  Server --> Client: Session Token
  note left: Session established
  deactivate Server
  Client -> Client: Saves token
  deactivate Client
#+END_SRC

But I failed with the following output image test_uml.png which is actually an ASCII file:

$ head test_uml.png 
Usage: java [options] <mainclass> [args...]
           (to execute a class)
   or  java [options] -jar <jarfile> [args...]
           (to execute a jar file)
   or  java [options] -m <module>[/<mainclass>] [args...]
       java [options] --module <module>[/<mainclass>] [args...]
           (to execute the main class in a module)
   or  java [options] <sourcefile> [args]
           (to execute a single source-file program)

Configurations

  • Emacs: 28.2 (aarch64-apple-darwin21.6.0, Carbon Version 165 AppKit 2113.6)
  • org-mode: 9.5.5
  • plantuml-mode-version: 20190905.838

The plantuml configuration clip is as the following:

(use-package plantuml-mode
  :config
  ;; setup plantuml-mode
  (setq plantuml-default-exec-mode 'executable)
  ;; (setq plantuml-default-exec-mode 'jar)
  (setq plantuml-executable-path
        (vl-util-find-1st-candidate
         `("/usr/bin/plantuml"
           "/usr/local/bin/plantuml"
           "/opt/homebrew/bin/plantuml"
           )))
  ;; setup plantuml for org-babel
  (add-to-list 'org-src-lang-modes '("plantuml" . plantuml))
  (setq org-plantuml-exec-mode 'executable)
  (setq org-plantuml-executable-path plantuml-executable-path)
  ;; (require 'ob-plantuml) ; OBSOLETED
  (setq org-plantuml-jar-path
        (vl-util-find-1st-candidate
         `("/usr/share/java/plantuml/plantuml.jar"
           "/opt/plantuml/plantuml.jar"
           "/usr/local/opt/plantuml/libexec/plantuml.jar"
           "/opt/homebrew/opt/plantuml/libexec/plantuml.jar"
           ,(expand-file-name "plantuml.jar" vl-prelude-utils-dir)
           )))
  (setq plantuml-jar-path org-plantuml-jar-path) ; OBSOLETED
  ;; (setq plantuml-jar-args '())
  ;; Enable puml-mode for PlantUML files
  (add-to-list 'auto-mode-alist '("\\.puml\\'" . plantuml-mode))
  (add-to-list 'auto-mode-alist '("\\.plantuml\\'" . plantuml-mode)))

I checked every variable (e.g., plantuml-jar-path, plantuml-default-exec-mode), and I confirm that they are correctly assigned.

@exaos exaos changed the title Failed to run plantuml in a org-babel src block Failed to run plantuml in an org-babel src block Jan 28, 2023
@zoechi
Copy link

zoechi commented Jan 14, 2024

I had to wrap the content with @startuml and @enduml and then just include the content from a standalone .puml file like

#+begin_src plantuml :file ./0003_files/layout_architecture.svg
@startuml
!include 0003_files/layout_architecture.puml
@enduml
#+end_src

The standalone .puml file is wrapped in @startuml and @enduml as well (otherwise it wouldn't work as standalone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants