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

Windows Support : Exit Code: 2(Misuse of shell builtins) #101

Closed
incoming-th opened this issue Dec 2, 2018 · 7 comments
Closed

Windows Support : Exit Code: 2(Misuse of shell builtins) #101

incoming-th opened this issue Dec 2, 2018 · 7 comments

Comments

@incoming-th
Copy link
Contributor

Hi @mnapoli ,

Just saw video of you on YT explaining about serverless and found this Bref project interesting, so I give it a try.

I know that you are not working on Windows but maybe someone faced this issue and has a solution:

PS C:\Users\xxxxx\Desktop\test> vendor/bin/bref deploy

 0/8 [>---------------------------] < 1 sec

 1/8 [===>------------------------] < 1 sec
Building the project in the `.bref/output` directory
 1/8 [===>------------------------] < 1 sec
Building the project in the `.bref/output` directory
 2/8 [=======>--------------------] < 1 sec
Downloading PHP in the `.bref/bin/` directory
 2/8 [=======>--------------------] < 1 sec
Downloading PHP in the `.bref/bin/` directory
 3/8 [==========>-----------------] < 1 sec
Installing the PHP binary
 3/8 [==========>-----------------] < 1 sec
In Process.php line 256:

  The command "tar -xzf .bref/bin/php/php-7.2.5.tar.gz -C .bref/output/.bref/bin" failed.

  Exit Code: 2(Misuse of shell builtins)

  Working directory: C:\Users\xxxxx\Desktop\test

  Output:
  ================


  Error Output:
  ================

  gzip: stdin: unexpected end of file
  tar: Unexpected EOF in archive
  tar: Unexpected EOF in archive
  tar: Error is not recoverable: exiting now


deploy [--dry-run] [--stage STAGE]

Thanks

@mnapoli mnapoli changed the title Exit Code: 2(Misuse of shell builtins) Windows Support : Exit Code: 2(Misuse of shell builtins) Dec 2, 2018
@mnapoli
Copy link
Member

mnapoli commented Dec 2, 2018

Thanks for the report, indeed I cannot help a lot with Windows support.

However could you try running the command tar -xzf .bref/bin/php/php-7.2.5.tar.gz -C .bref/output/.bref/bin manually? Or any kind of command with tar -xzf if the file doesn't exist.

I'm suspecting this command doesn't work on windows.

@incoming-th
Copy link
Contributor Author

Alright, I tried to manually run the command and this is the output:

PS C:\Users\thxxxxxaip\Desktop\test\bref> tar -xzf .bref/bin/php/php-7.2.5.tar.gz -C .bref/output/.bref/bin
php: truncated gzip input
tar.exe: Error exit delayed from previous errors.

So I suspect the file was corrupted (maybe because it was bundled from a non windows machine) and I downloaded a new one from the source on https://secure.php.net/get/php-7.2.5.tar.gz/from/a/mirror and saved the file into .bref\bin\php

I re-ran the deploy command and got:

PS C:\Users\xxxxx\Desktop\test\bref> vendor/bin/bref deploy

 0/8 [>---------------------------] < 1 sec

 1/8 [===>------------------------] < 1 sec
Building the project in the `.bref/output` directory
 1/8 [===>------------------------] < 1 sec
Building the project in the `.bref/output` directory
 2/8 [=======>--------------------] < 1 sec
Downloading PHP in the `.bref/bin/` directory
 2/8 [=======>--------------------] < 1 sec
Downloading PHP in the `.bref/bin/` directory
 3/8 [==========>-----------------] < 1 sec
Installing the PHP binary
 3/8 [==========>-----------------] < 1 sec
In Process.php line 1236:

  The process "tar -xzf .bref/bin/php/php-7.2.5.tar.gz -C .bref/output/.bref/bin" exceeded the timeout of 60 seconds.


deploy [--dry-run] [--stage STAGE]

I re-ran the untar command manually and after 3-4 minutes it completed with no error, making the untar command not the cause.

But even if I change max_input_time, max_execution_time or default_socket_timeout I still get the timeout. Maybe this is not related to php.ini but PowerShell - which I doubt.

Also maybe an idea to add a parameter in the deploy command to skip the untar step if we already "untared" the php archive?

Thanks

@mnapoli
Copy link
Member

mnapoli commented Dec 2, 2018

OK so maybe there's a way to fix this:

https://github.com/mnapoli/bref/blob/c63892f0dc516ff5265d381885aa17369625b026/src/Console/Deployer.php#L163-L164

This is the line that runs the tar command. By default the Symfony Process class has a timeout of 60 seconds. We could remove that timeout? (or set it to 5 minutes?)

See an example here:

https://github.com/mnapoli/bref/blob/c63892f0dc516ff5265d381885aa17369625b026/src/Console/Deployer.php#L66

If you can try it on your machine and it works you could send a pull request?

@incoming-th
Copy link
Contributor Author

incoming-th commented Dec 2, 2018

I tried to run the deployment from the Ubuntu App on Windows 10 but still got the same error.

2018-12-02 003371

So I looked at the code and as you explained the default timeout is 60s. I have added this and it works:

2018-12-02 003372

FYI, it took me 14min to deploy the sample code. My machine is using SSD so I assume the bottleneck is the CPU (i7 - first gen?).

Uploading the lambda
 7/8 [========================>---] 14 mins
Deployment success
 8/8 [============================] 14 mins

@mnapoli
Copy link
Member

mnapoli commented Dec 2, 2018

Yes I have to agree that the tar process taking so long is really really surprising. On my machine (Mac) the whole deployment takes like 30 seconds…

If I were you I'd try investigating why tar takes so long on Windows. You have a good processor and a SSD so I see no reason for this to take so long…

@incoming-th
Copy link
Contributor Author

At least it allowed to discover this minor enhancement but I will investigate why, it may be related to Windows Defender.

Made a PR, all the processes finished but now facing the same issue #80

Closing this issue.

@staabm
Copy link
Contributor

staabm commented Dec 2, 2018

I would guess a antivirus software is slowing the tar process

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

No branches or pull requests

3 participants