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

Unable to invoke "dot" to create image file (code 127) #72

Closed
sardjn opened this issue Jun 28, 2023 · 6 comments
Closed

Unable to invoke "dot" to create image file (code 127) #72

sardjn opened this issue Jun 28, 2023 · 6 comments
Labels

Comments

@sardjn
Copy link

sardjn commented Jun 28, 2023

I get this error:

Unable to invoke "dot" to create image file (code 127)

I have installed the graphviz, I have tried to reinstall it again, but I still get the same error.

Using Yii2, controller action:

public function actionGraph()
{
    $dir = Yii::getAlias('@app') . '/vendor';
    $graphComposer = new \Clue\GraphComposer\Graph\GraphComposer($dir);
    $graph = $graphComposer->createGraph();

    $graphviz = new \Graphp\GraphViz\GraphViz();
    $graphviz->setFormat('svg');
    $svg = $graphviz->createImageFile($graph);
    return $this->render('graph', ['svg' => $svg]);
}

and view:

<?php

/**
 * @var $this yii\web\View
 * @var $svg string
 */

var_dump($svg);
use yii\helpers\Html;

$this->title = 'Dependency Graph';
$this->params['breadcrumbs'][] = $this->title;

?>

<div class="site-dependency-graph">
    <h1><?= Html::encode($this->title) ?></h1><br />

    <div id="graph-placeholder">
        <!-- place here the svg file -->
        <?= $svg ?>
    </div>
</div>
@SimonFrings
Copy link
Contributor

Hey @elementallos, thanks for bringing this up 👍

Like @clue described in graphp/graphviz#31, the Unable to invoke "dot" to create image file (code 127)... error message means you do not have GraphViz installed (the dot executable is part of the GraphViz package). On Debian/Ubuntu-based system you may simply install it like this:

$ sudo apt install graphviz

This has been answered in #4 as well and is also mentioned inside the documentation.
Ref: #43

I believe this should answer your question, so I will close this ticket for now. We can reopen this if you encounter the same issues again after trying out the solutions mentioned in here.

@sardjn
Copy link
Author

sardjn commented Jun 28, 2023

But is not working anyway for me...
As I said already, in the first message, I have already tried to do:

$ sudo apt install graphviz

but is still not working. It's like the installation is not successful, even though I have no errors.

@SimonFrings
Copy link
Contributor

As I said already, in the first message, I have already tried to do:

$ sudo apt install graphviz

You're right, so this would mean you can't even try dot -v to check the GraphViz version, right?

@sardjn
Copy link
Author

sardjn commented Jun 28, 2023

Yes, I can do dot -v, it is only on the PHP code, when I try to generate the .svg
The installation with sudo apt install is successful: I don't get any error messages. But when I try to use the command, it looks like this (var_dump):

'dot' -T 'svg' '/tmp/graphvizDEdKjJ' -o '/tmp/graphvizDEdKjJ.svg'

Edit: I have also tried to paste the command in the terminal to see what could possibly happen. This is the result:

gabriel@HP:~ dot -T 'svg' '/tmp/graphvizDEdKjJ' -o '/tmp/graphvizDEdKjJ.svg'
Error: dot: can't open /tmp/graphvizDEdKjJ

@sardjn
Copy link
Author

sardjn commented Jul 11, 2023

@SimonFrings any updates?

@SimonFrings
Copy link
Contributor

[…] But when I try to use the command, it looks like this (var_dump):

@sardjn You're trying to access some temporary files that are created and also removed by the project itself, this is why the message tells you that dot can't open /tmp/graphvizDEdKjJ (the file doesn't exist). It seems like you have graphviz successfully installed, otherwise the message would tell you that it doesn't know the dot command, you just can't access these unknown files.

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

No branches or pull requests

2 participants