Crud: Getting Symfony\Component\Process\Exception\ProcessFailedException : The command "mkdir -p public/uploads" failed. error

Created on 24 Mar 2018  路  7Comments  路  Source: Laravel-Backpack/CRUD

Bug report

What I did:

i ran the following command on windows 10.
php artisan backpack:crud:install

What I expected to happen:

What happened:

Exception trace:

1 BackpackBaseappConsoleCommandsInstall::executeProcess("mkdir -p public/uploads")
C:xampp7.2.1htdocsdecentblocks-sitevendorbackpackcrudsrcappConsoleCommandsInstall.php : 51

2 BackpackCRUDappConsoleCommandsInstall::handle()
C:xampp7.2.1htdocsdecentblocks-sitevendorlaravelframeworksrcIlluminateContainerBoundMethod.php : 29

Please use the argument -v to see more details.

What I've already tried to fix it:

Backpack, Laravel, PHP, DB version:

1.1, 5.6, 7.2.2, mysql 5.7

pending

Most helpful comment

mkdir in windows has different syntax. I tried to change line 50 in file vendor/backpack/crud/src/app/Console/Commands/Install.php

from this:

$this->line(' Creating uploads directory');
$this->executeProcess('mkdir -p public/uploads');

to:

if (DIRECTORY_SEPARATOR == '/') {
    // linux or unix like OS
    $this->executeProcess('mkdir -p public/uploads');
}

if (DIRECTORY_SEPARATOR == '\\') {
   // windows
   if(!file_exists('public\uploads')) {
       $this->executeProcess('mkdir public\uploads');
   }
}

and it works.

All 7 comments

Hello there! Thanks for opening your first issue on this repo!

Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps _a lot_ in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.

Backpack communication mediums:

  • Bug Reports, Feature Requests - Github Issues (here);
  • Quick help (_How do I do X_) - Gitter Chatroom;
  • Long questions (_I have done X and Y and it won't do Z wtf_) - Stackoverflow, using the backpack-for-laravel tag;

Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome _awesome_ community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.

Thank you!

--
Justin Case
The Backpack Robot

Hi @harishdurga ,

Backpack assumes you're running a UNIX command line - just mentioning it because it looks like you're on Windows. Hope you're running this through Vagrant/Homestead/something.

You can increase the timeout with the following php artisan backpack:crud:install --timeout=600. It's worth trying, but I don't think it will fix the issue for you. It seems like installation is failing at mkdir -p public/uploads which is a very simple command, it shouldn't take much time at all.

What I recommend you do is manually install CRUD. So that when that command fails, you can manually create that folder in Explorer, then run the next commands yourself.

Hope it helps. Please let me know if you discover why the mkdir command failed for you - it's an odd one.

Cheers!

mkdir in windows has different syntax. I tried to change line 50 in file vendor/backpack/crud/src/app/Console/Commands/Install.php

from this:

$this->line(' Creating uploads directory');
$this->executeProcess('mkdir -p public/uploads');

to:

if (DIRECTORY_SEPARATOR == '/') {
    // linux or unix like OS
    $this->executeProcess('mkdir -p public/uploads');
}

if (DIRECTORY_SEPARATOR == '\\') {
   // windows
   if(!file_exists('public\uploads')) {
       $this->executeProcess('mkdir public\uploads');
   }
}

and it works.

Try using gitbash if you're on windows. It acts like a unix console. Since most laravel installations live on a linux based os in the cloud this is not really an issue.

@indra1 i tried using gitbash but the problem still persists on my machine.

Running WIN 7 PRO x64

Besides the mkdir command, the 5th command, php artisan backpack:base:add-sidebar-content ... is also creating an issue in windows.

I solved both with the code bellow, @tabacitu, @indra1, do you think this is handful for backpack? To support both unix like and windows OS? I can create a PR with this changes.

switch (DIRECTORY_SEPARATOR) {
    case '/': // unix
        $this->executeProcess('mkdir -p public/uploads');
        break;
    case '\\': // windows
        if(!file_exists('public\uploads')) {
            $this->executeProcess('mkdir public\uploads');
        }
        break;
}

and

switch (DIRECTORY_SEPARATOR) {
    case '/': // unix
        $this->executeProcess("php artisan backpack:base:add-sidebar-content '<li><a href=\"{{ backpack_url(\"elfinder\") }}\"><i class=\"fa fa-files-o\"></i> <span>File manager</span></a></li>'");
        break;
    case '\\': // windows
        $this->executeProcess('php artisan backpack:base:add-sidebar-content "<li><a href=""{{ backpack_url(\'elfinder\') }}""><i class=""fa fa-files-o""></i> <span>File manager</span></a></li>"');
        break;
}

Thanks a lot @promatik - I just applied your corrections and tagged it, a composer update should fix it for everyone.

Cheers!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

voidstate picture voidstate  路  3Comments

jorgepires picture jorgepires  路  3Comments

packytagliaferro picture packytagliaferro  路  3Comments

deepaksp picture deepaksp  路  3Comments

abewartech picture abewartech  路  3Comments