Skip to content

[Bug]: Path adds a backslash (\) in front of the Path #1733

@spresnac-ltb

Description

@spresnac-ltb

What happened?

Trying to execute to_csv on windows.
When giving a path to the csv, an error showed up:

ErrorException

  mkdir(): No such file or directory

  at vendor\flow-php\filesystem\src\Flow\Filesystem\Local\NativeLocalFilesystem.php:171
    167▕             throw new InvalidArgumentException("Pattern paths can't be written: " . $path->uri());
    168▕         }
    169▕
    170▕         if (!$this->status($path->parentDirectory())) {
  ➜ 171▕             if (!\mkdir($concurrentDirectory = $path->parentDirectory()->path(), recursive: true) && !\is_dir($concurrentDirectory)) {
    172▕                 throw new RuntimeException(\sprintf('Directory "%s" was not created', $concurrentDirectory));
    173▕             }
    174▕         }
    175▕

  1   vendor\flow-php\filesystem\src\Flow\Filesystem\Local\NativeLocalFilesystem.php:171

  2   vendor\flow-php\etl\src\Flow\ETL\Filesystem\FilesystemStreams.php:241
      Flow\Filesystem\Local\NativeLocalFilesystem::writeTo(Object(Flow\Filesystem\Path))

So, i reduced it this test lines:

        $path_string = storage_path() . DIRECTORY_SEPARATOR . 'output.csv';
        $path = new Path($path_string);

(yes, it runs in a laravel environment)
Output is:

"C:\projekte\flowphpdemo\storage\output.csv" // app\Console\Commands\FlowTestCommand.php:40
"\C:\projekte\flowphpdemo\storage\output.csv" // app\Console\Commands\FlowTestCommand.php:40

You see, the string itself is ok, the path-object magically adds a \ in front and therefor, mkdir cannot work.

Plase fix

How to reproduce?

On Windows, to something with to_csv

Data required to reproduce bug locally

see above

Version

0.19.0

Relevant error output

ErrorException

  mkdir(): No such file or directory

  at vendor\flow-php\filesystem\src\Flow\Filesystem\Local\NativeLocalFilesystem.php:171
    167▕             throw new InvalidArgumentException("Pattern paths can't be written: " . $path->uri());
    168▕         }
    169▕
    170▕         if (!$this->status($path->parentDirectory())) {
  ➜ 171▕             if (!\mkdir($concurrentDirectory = $path->parentDirectory()->path(), recursive: true) && !\is_dir($concurrentDirectory)) {
    172▕                 throw new RuntimeException(\sprintf('Directory "%s" was not created', $concurrentDirectory));
    173▕             }
    174▕         }
    175▕

  1   vendor\flow-php\filesystem\src\Flow\Filesystem\Local\NativeLocalFilesystem.php:171

  2   vendor\flow-php\etl\src\Flow\ETL\Filesystem\FilesystemStreams.php:241
      Flow\Filesystem\Local\NativeLocalFilesystem::writeTo(Object(Flow\Filesystem\Path))

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions