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

make:<object> seems to not work in version 1.1.0 on windows environment #124

Closed
Antonello-Oliveri opened this issue Feb 21, 2018 · 9 comments

Comments

@Antonello-Oliveri
Copy link

Hi to everybody.
The new 1.1.0 makerbundle return error during object creation ( entity, form, controller etc ).
The version 1.0 work correclty
I'm working under Window 7 and Windows 10 environments
This is the verbose output:

2018-02-21T10:21:45+00:00 [debug] Warning: mkdir(): No such file or directory
2018-02-21T10:21:45+00:00 [error] Error thrown while running command "make:entity -vvv prova". Message: "Failed to create "C:\PHPDevelopment\mrc//C:\PHPDevelopment\mrc\vendor\composer/../../src/Entity""
2018-02-21T10:21:45+00:00 [debug] Command "make:entity -vvv prova" exited with code "1"

In Filesystem.php line 106:

[Symfony\Component\Filesystem\Exception\IOException]
Failed to create "C:\PHPDevelopment\mrc//C:\PHPDevelopment\mrc\vendor\composer/../../src/Entity"

Exception trace:
Symfony\Component\Filesystem\Filesystem->mkdir() at C:\PHPDevelopment\mrc\vendor\symfony\filesystem\Filesystem.php:682
Symfony\Component\Filesystem\Filesystem->dumpFile() at C:\PHPDevelopment\mrc\vendor\symfony\maker-bundle\src\FileManager.php:55
Symfony\Bundle\MakerBundle\FileManager->dumpFile() at C:\PHPDevelopment\mrc\vendor\symfony\maker-bundle\src\Generator.php:162
Symfony\Bundle\MakerBundle\Generator->writeChanges() at C:\PHPDevelopment\mrc\vendor\symfony\maker-bundle\src\Maker\MakeEntity.php:77
Symfony\Bundle\MakerBundle\Maker\MakeEntity->generate() at C:\PHPDevelopment\mrc\vendor\symfony\maker-bundle\src\Command\MakerCommand.php:93
Symfony\Bundle\MakerBundle\Command\MakerCommand->execute() at C:\PHPDevelopment\mrc\vendor\symfony\console\Command\Command.php:252
Symfony\Component\Console\Command\Command->run() at C:\PHPDevelopment\mrc\vendor\symfony\console\Application.php:883
Symfony\Component\Console\Application->doRunCommand() at C:\PHPDevelopment\mrc\vendor\symfony\framework-bundle\Console\Application.php:84
Symfony\Bundle\FrameworkBundle\Console\Application->doRunCommand() at C:\PHPDevelopment\mrc\vendor\symfony\console\Application.php:241
Symfony\Component\Console\Application->doRun() at C:\PHPDevelopment\mrc\vendor\symfony\framework-bundle\Console\Application.php:72
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at C:\PHPDevelopment\mrc\vendor\symfony\console\Application.php:143
Symfony\Component\Console\Application->run() at C:\PHPDevelopment\mrc\bin\console:39

make:entity [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] []

@Pierstoval
Copy link

I also have this kind of issue on Windows with MakerBundle v1.1.0:

$ php bin/console make:controller

 Choose a name for your controller class (e.g. BraveChefController):
 > DefaultController

2018-02-21T11:35:57+01:00 [error] Error thrown while running command "make:controller". Message: "Failed to create "E:\dev\www\flex_tests\tests//E:\dev\www\flex_tests\tests\vendor\composer/../../src/Controller""

In Filesystem.php line 106:

  Failed to create "E:\dev\www\flex_tests\tests//E:\dev\www\flex_tests\tests\vendor\composer/../../src/Controller"


make:controller [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> [<controller-class>]

@weaverryan
Copy link
Member

Thanks guys! Definitely a bug - probably something in FileManager or maybe Generator when we’re trying to figure out the final path. I don’t have a Windows computer, but I’ll check into it. If you guys can do any debugging and see where this bad path is created, that would be awesome :)

@sadikoff
Copy link
Contributor

sadikoff commented Feb 21, 2018

@weaverryan It's in FileManager
after calling getPathForFutureClass we have relative path:

D:\test\sf-flex-4\vendor\composer/../../src/Controller/TestController.php

than while dumping file we call absolutizePath which generates:

D:\test\sf-flex-4//D:\test\sf-flex-4\vendor\composer/../../src/Controller/TestController.php

@sadikoff
Copy link
Contributor

sadikoff commented Feb 21, 2018

Fast fix

class FileManager
{
#....
    public function relativizePath($absolutePath): string
    {
       # fix for windows directory separator
        $absolutePath = str_replace('\\', '/', $absolutePath);
#....
    private function realPath($absolutePath): string
    {
        $finalParts = [];
        $currentIndex = -1;
        # fix for windows directory separator
        $absolutePath = str_replace('\\', '/', $absolutePath);
#....
}

@weaverryan
Copy link
Member

Thank you @sadikoff! Very helpful :). I'm working on it in #125 :)

weaverryan added a commit that referenced this issue Feb 21, 2018
…verryan)

This PR was squashed before being merged into the 1.0-dev branch (closes #125).

Discussion
----------

Initial attempt for appveyor support & Windows path fix

See #124 - let's get tests running on Windows :)

Commits
-------

7a04e9b Fixing Windows path problem
b7222ba Adding appveyor CI support
@weaverryan
Copy link
Member

Hey guys!

Can you verify that the bug is fixed in 1.1.1? We now have AppVeyor running, so hopefully we won't have any future Windows-only surprises like this :).

Cheers!

@Antonello-Oliveri
Copy link
Author

Antonello-Oliveri commented Feb 21, 2018 via email

@Antonello-Oliveri
Copy link
Author

Hi, it worked for me.
Great work folks!!!

@weaverryan
Copy link
Member

Beautiful! Thanks for checking :)

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

4 participants