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

--output-format=display has no effect (linux) #27

Open
lrkwz opened this issue Jan 17, 2018 · 8 comments
Open

--output-format=display has no effect (linux) #27

lrkwz opened this issue Jan 17, 2018 · 8 comments

Comments

@lrkwz
Copy link

lrkwz commented Jan 17, 2018

I'm using ubuntu.
The output to display option has no effect.

My default image viewer is eog (gnome image viewer)

$ uname -a
Linux lrkwz-Precision-SSD-M4500 4.13.0-26-generic #29~16.04.2-Ubuntu SMP Tue Jan 9 22:00:44 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.3 LTS
Release:	16.04
Codename:	xenial
$ gnome-shell --version
GNOME Shell 3.18.5
$ eog --version
GNOME Image Viewer 3.18.2
@jubianchi
Copy link
Member

To make the display format work, you have to ensure the xdg-command is available on your machine.

This command is used by the underlying library to display the graph : https://github.com/graphp/graphviz/blob/master/src/GraphViz.php#L126

@lrkwz
Copy link
Author

lrkwz commented Jan 20, 2018

Ther'e must be something wrong in graphwiz then because the xdg-command is available in $PATH.

$ which xdg-open
/usr/bin/xdg-open

I see no way to trace the error though :-( both stderr and stdout are redirected to null.

@lrkwz
Copy link
Author

lrkwz commented Jan 22, 2018

Close to catching the error

docker run --rm \
    -it \
    -v $(pwd):/input/ \
    -u 0 \
    pmsipilot/docker-compose-viz \
    php -r 'exec("xdg-open docker-compose.png >/dev/null>/dev/null");'
sh: xdg-open: not found

adding apk add xdg-utils in Dockerfile is not enough, there must be a way to pass the command to the host.

@jubianchi jubianchi reopened this Jan 30, 2018
@jubianchi
Copy link
Member

@lrkwz As you mention there are some missing packages inside the Docker image.

After adding them and running some tests it appears there are some other issues:

  • using the display format through Docker will require you to bind the display: this is done by sharing the X11 socket. It's quite easy on Linux but a bit more tricky on Linux...and don't ask me to support Windows :D
  • The graphp/graphviz library runs xdg-open as a background job (using & on the command line). When running inside Docker (with --rm) xdg-open is immediately killed and has no chance to run the image viewer. I'll have to find a workaround here.

@clue
Copy link

clue commented Jan 30, 2018

@jubianchi Thank you for your analysis. I don't have the capacity to actively participate here right now, but if you feel anything is missing/unclear in graphp/graphviz, make sure to let me know and I'll try to look into this 👍

@jubianchi
Copy link
Member

@clue I don't really think graphp/graphviz is missing anything. We are in some kind of edge-case here (using xdg-open in an asynchronous way when the parent process has a short lifetime).

I think I'll extend the class and override the display method to get the expected behavior when running in Docker.

If you ever want to integrate this change in the library I'll be happy to open a PR on your side. But for now, I don't want to bother you with such "specific" changes. If you ever get a feature request for this kind of use-case, I'll be happy to contribute to your (really useful) library ;)

@clue
Copy link

clue commented Jan 30, 2018

I'm always happy to hear if any of my libraries is useful! 👍 That being said, I don't consider this to be perfect, so if you feel this is useful, go ahead, I'm happy about PRs :shipit:

@jubianchi
Copy link
Member

@wixyvir would you mind taking a look at this issue and see if #32 is something we should build upon?

Thanks 🙏

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

Successfully merging a pull request may close this issue.

3 participants