0

I'm using Symfony/Process to run a test from Laravel Dusk in a route of web.php in Laravel. This is the code that I'm using:

Route::get('/scraping', function () {

    $process = new Process('cd pathtoartisan && C:\xampp\php\php.exe artisan dusk -v');
    $process->setPTY(true);
    $process->run();

    if (!$process->isSuccessful()) {
        throw new ProcessFailedException($process);
    }

    echo '<pre>'.$process->getOutput();
});

I think it would work fine, but I got this error:

Symfony\Component\Process\Exception\RuntimeException : A temporary file could not be opened to write the process output: fopen(C:\WINDOWS\sf_proc_00.out.lock): failed to open stream: Permission denied

at C:...\laravel-master\vendor\symfony\process\Pipes\WindowsPipes.php:60

> $file = sprintf('%s\\sf_proc_%02X.%s',$tmpDir, $i, $name);
>        if (!$h = fopen($file.'.lock', 'w')) {
>           restore_error_handler();
>           throw new RuntimeException(sprintf('A temporary file could not be opened to write the process output: %s', $lastError)); }

I have read in Symfony documentation that the following command should help me:

chmod -R 777 var/log/

But I'm using Windows and I don't know how to get that, also I don't know if it's correct that command, or if I should give permission to other file.

Mmelo
  • 31
  • 1
  • 6
  • 3
    For some reason `sys_get_temp_dir` on your machine returns `C:\WINDOWS\`. Check your OS settings an ensure it's set to something writeable. Also check the second argument of the `Process` constructor: you need to use that instead of `cd`. – zerkms Sep 02 '19 at 23:01
  • Can't reproduce on linux, must be OS problem – Salim Djerbouh Sep 02 '19 at 23:05

0 Answers0