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

Add windows compatibility #193

Open
4 tasks
theofidry opened this issue May 3, 2018 · 30 comments
Open
4 tasks

Add windows compatibility #193

theofidry opened this issue May 3, 2018 · 30 comments

Comments

@theofidry
Copy link
Member

theofidry commented May 3, 2018

/cc @c33s

  • Make the tests pass
  • Add AppVeyor
  • Check the compatibility with emojis
  • Check the compatibility with the parallel & restart mode
@theofidry
Copy link
Member Author

To whoever is willing to help out with this issue as I can't get my hands on a Windows machine: running bin/phpunit and check out the failures would be the easiest way to find most of the issues IMO.

@c33s
Copy link

c33s commented Oct 22, 2018

tried the current version 3.1.2

box --version
Fatal error: Uncaught Error: Call to undefined function _HumbugBox1ee257d4ea88\Symfony\Component\Console\Output\sapi_windows_vt100_support() in phar://C:/bin/box.phar/vendor/symfony/console/Output/StreamOutput.php:55
Stack trace:
#0 phar://C:/bin/box.phar/vendor/symfony/console/Output/StreamOutput.php(28): _HumbugBox1ee257d4ea88\Symfony\Component\Console\Output\StreamOutput->hasColorSupport()
#1 phar://C:/bin/box.phar/vendor/symfony/console/Output/ConsoleOutput.php(20): _HumbugBox1ee257d4ea88\Symfony\Component\Console\Output\StreamOutput->__construct(Resource id #159, 32, NULL, NULL)
#2 phar://C:/bin/box.phar/vendor/symfony/console/Application.php(89): _HumbugBox1ee257d4ea88\Symfony\Component\Console\Output\ConsoleOutput->__construct()
#3 phar://C:/bin/box.phar/bin/box(39): _HumbugBox1ee257d4ea88\Symfony\Component\Console\Application->run()
#4 C:\bin\box.phar(18): require('phar://C:/bin...')
#5 {main}
  thrown in phar://C:/bin/box.phar/vendor/symfony/console/Output/StreamOutput.php on line 55

@c33s
Copy link

c33s commented Oct 22, 2018

what about using https://www.appveyor.com/

Free for open-source projects

https://www.appveyor.com/pricing/

example config: https://github.com/puli/cli/blob/master/appveyor.yml

@theofidry
Copy link
Member Author

I'm all up for it, it's just the trouble of setting it up and doing the PR to fix the windows incompatibilities I'm not really willing to do. If a PR provides the fixes with a working AppVeyor config, I'll gladly accept it though

@c33s
Copy link

c33s commented Oct 22, 2018

got it up und running on window. i compiled box with itself from master with .\bin\box.bat compile --no-parallel but i had to replace all sapi_windows_vt100_support() calls with \sapi_windows_vt100_support()
looks like this is a symfony console error with php7.1 or can it be some of your replace code?

the wrong namespace is used on this function call Call to undefined function _HumbugBoxb3c5af21fff1\Composer\XdebugHandler\sapi_windows_vt100_support() this error is gone if i prefix all the sapi_windows_vt100_support() with \ then i was able to get a self compiled version of box and use it to compile my code.

@theofidry
Copy link
Member Author

Woa nice! I'll check this sapi_windows_vt100_support issue ASAP

@c33s
Copy link

c33s commented Oct 23, 2018

hmm, i think i was too fast. the build is created but the build file does not work :(

@theofidry
Copy link
Member Author

This required some tweaking, but done in humbug/php-scoper#269. Will do a release soonish

@theofidry
Copy link
Member Author

Shipped in 3.1.3 :)

@c33s
Copy link

c33s commented Feb 19, 2019

finally some time for testing. all in all it works quite well. i compiled https://gitlab.com/c33s-group/yaml-convert and got a working yaml-convert.phar

{
    "directories": ["vendor"],
    "main": "bin/yaml-convert",
    "output": "yaml-convert.phar",
    "compression": "GZ",
    "git-commit": "git_commit",
    "git-version": "git_version",
    "git-tag": "git_tag"
}

stumpled upon some problems:

  1. The filename, directory name, or volume label syntax is incorrect. The filename, directory name, or volume label syntax is incorrect. #353
λ php box.phar compile
The filename, directory name, or volume label syntax is incorrect.

wouldn't it be good to have a windows detection and simply add this flags --no-restart --no-parallel per default (--no-restart was enough for me on win7)?

  1. vendor/composer/installed.json Add warning about installed.json #337
    only a warning but still some kind annoying
A composer.lock file has been found but its related file vendor/composer/installed.json could not. This could be due to either dependencies incorrectly installed or an incorrect Box configuration which is not including the installed.json file. This will not break the build but will likely result in a broken Composer classmap.

the file exists in vendor/composer but is not added to the resulting phar file, maybe this is the problem. in my box.json i add the whole vendor dir. so it should be there. also tried "force-autodiscovery": true, with the same result.

  1. --debug -> Call to undefined function spl_object_id()
    as this function was shipped with php7.2 and i run php7.1 some kind of polyfill would be needed for this to work https://github.com/symfony/polyfill-php72
Fatal error: Uncaught Error: Call to undefined function spl_object_id() in phar://M:/composer-yaml/box.phar/vendor/symfony/var-dumper/Cloner/VarCloner.php:141
Stack trace:
#0 phar://M:/composer-yaml/box.phar/vendor/symfony/var-dumper/Cloner/AbstractCloner.php(58): _HumbugBoxfc75abf4ec5a\Symfony\Component\VarDumper\Cloner\VarCloner->doClone(Object(_HumbugBoxfc75abf4ec5a\KevinGH\Box\Configuration))
#1 phar://M:/composer-yaml/box.phar/src/Console/Command/Compile.php(179): _HumbugBoxfc75abf4ec5a\Symfony\Component\VarDumper\Cloner\AbstractCloner->cloneVar(Object(_HumbugBoxfc75abf4ec5a\KevinGH\Box\Configuration))
#2 phar://M:/composer-yaml/box.phar/src/Console/Command/Compile.php(131): _HumbugBoxfc75abf4ec5a\KevinGH\Box\Console\Command\Compile->removeExistingArtifacts(Object(_HumbugBoxfc7 in phar://M:/composer-yaml/box.phar/vendor/symfony/var-dumper/Cloner/VarCloner.php on line 141

@c33s
Copy link

c33s commented Feb 19, 2019

extra info about polyfill: https://github.com/symfony/polyfill#design

@theofidry
Copy link
Member Author

wouldn't it be good to have a windows detection and simply add this flags --no-restart --no-parallel per default (--no-restart was enough for me on win7)?

Isn't the issue because of your machine setup rather than just because it's the windows platform?

  1. only a warning but still some kind annoying

That's a legit one though: make sure all deps are installed properly before running Box.

the file exists in vendor/composer but is not added to the resulting phar file, maybe this is the problem. in my box.json i add the whole vendor dir. so it should be there. also tried "force-autodiscovery": true, with the same result

The installed.json is important to detect the dependencies, it is however excluded (by default) in the final PHAR. You shouldn't need to include vendor. That's said it's mostly for optimization and removing the dev deps

  1. --debug -> Call to undefined function spl_object_id()

Arg indeed, although I would rather upgrade to 7.2.

@c33s
Copy link

c33s commented Feb 20, 2019

Isn't the issue because of your machine setup rather than just because it's the windows platform?
thought it hits all/more windows instances because of #353

That's a legit one though: make sure all deps are installed properly before running Box.
i don't really understand, i installed everything fresh like this:

  • deleted vendor
  • composer update
  • box compile --no-restart (using the config from above)

this results in the warning A composer.lock file has been found but its related file vendor/composer/installed.json...
can it be that the detection for this warning is some kind of buggy or is my config wrong? is it required to remove vendor?

Arg indeed, although I would rather upgrade to 7.2.

sadly it is not possible to upgrade everywhere. sometimes i have situations where people demand php 5.6. so as version 7.1 is still supported until dec 2019 integrating the awesome symfony polyfills would be my suggestion. so it simply work for people who can't update.

@theofidry
Copy link
Member Author

An easy way to check that warning would be to do BOX_ALLOW_XDEBUG box compile --no-restart and put a breakpoint in Configuration::create() to see what's going on

@c33s
Copy link

c33s commented Feb 21, 2019

An easy way to check that warning would be to do BOX_ALLOW_XDEBUG box compile --no-restart and put a breakpoint in Configuration::create() to see what's going on

currently no configured xdebug on the windows system :(

another catch:

Output cmder (same for bash.exe): ![2019-02-21 17_14_06-cmder](https://user-images.githubusercontent.com/649209/53184652-b7e8dc00-35fd-11e9-9822-1910313f68d5.png)

cmd.exe:

Available commands:
  build     Builds a new PHAR (deprecated, use "compile" instead)
  compile   🔨  Compiles an application into a PHAR
  diff      🕵  Displays the differences between all of the files in two PHARs

  docker    🐳  Generates a Dockerfile for the given PHAR
  help      Displays help for a command
  info      🔍  Displays information about the PHAR extension or file
  list      Lists commands
  process   ΓÜí  Applies the registered compactors and replacement values on a f
ile
  validate  ΓÜÖ  Validates the configuration file
  verify    🔐️  Verifies the PHAR signature

@theofidry
Copy link
Member Author

Windows doesn't like emojis?

@c33s
Copy link

c33s commented Feb 21, 2019

Windows doesn't like emojis?

at least win7x64 without any special fonts installed.

@c33s
Copy link

c33s commented Feb 24, 2019

another one:

cannot run box if files are in the root dir

Output
O:\ (master)
λ box compile --no-restart
running convert with box
converting box.yaml to json
running convert with box-dist
both not existing

    ____
   / __ )____  _  __
  / __  / __ \| |/_/
 / /_/ / /_/ />  <
/_____/\____/_/|_|


Box version 3.4.0@4eeb285 2018-12-13 09:51:10 UTC
 // Loading the configuration file "O:\box.json".
 [ERROR] The configuration file is invalid.
In Assertion.php line 829:
  "files" must contain a list of existing files. Could not find "O:/O://composer.json".

@c33s
Copy link

c33s commented Feb 24, 2019

now i tried to compile https://github.com/composer/satis
no luck this time.

Output ``` λ box compile --no-restart running convert with box converting box.yaml to json running convert with box-dist both not existing
____

/ __ )____ _ __
/ __ / __ | |//
/ /
/ / // /> <
/__/_/
/|_|

Box version 3.4.0@4eeb285 2018-12-13 09:51:10 UTC

// Loading the configuration file "O:\satis\box.json".

🔨 Building the PHAR "O:/satis/satis.phar"

? Removing the existing PHAR "O:/satis/satis.phar"
? Registering compactors

  • KevinGH\Box\Compactor\Json
  • KevinGH\Box\Compactor\Php
    ? Adding main file: O:/satis/bin/satis
    ? Adding requirements checker
    ? Adding binary files

    No file found
    ? Auto-discover files? No
    ? Adding files
    2613 file(s)
    ? Generating new stub

  • Using shebang line: #!/usr/bin/env php
  • Using banner:

    Generated by Humbug Box 3.4.0@4eeb285.

    @link https://github.com/humbug/box
    ? Dumping the Composer autoloader
    ? Removing the Composer dump artefacts
    ? Compressing with the algorithm "GZ"
    Warning: the extension "zlib" will now be required to execute the PHAR
    ? Setting file permissions to 0755

  • Done.

💡 6 recommendations found:
- The "main" setting can be omitted since is set to its default value
- The "stub" setting can be omitted since is set to its default value
- The compactor "Herrera\Box\Compactor\Json" has been deprecated, use "KevinGH\Box\Compactor\Json" instead.
- The compactor "Herrera\Box\Compactor\Php" has been deprecated, use "KevinGH\Box\Compactor\Php" instead.
- The "chmod" setting can be omitted since is set to its default value
- The "algorithm" setting can be omitted since is set to its default value
⚠️ 1 warning found:
- A composer.lock file has been found but its related file vendor/composer/installed.json could not. This could be due to either dependencies incorrectly installed or an incorrect Box configuration which is not including the installed.json file. This will not break the build but will likely result in a broken Composer classmap.

// PHAR: 2643 files (1.92MB)
// You can inspect the generated PHAR with the "info" command.

// Memory usage: 26.73MB (peak: 28.60MB), time: 48.64s

O:\satis (master)
λ php satis.phar

Fatal error: Class 'Symfony\Component\Console\Application' not found in phar://O:/satis/satis.phar/src/Console/Application.php on line 30

</details>


resulting phar: [satis.zip](https://github.com/humbug/box/files/2898241/satis.zip)

@c33s
Copy link

c33s commented Mar 1, 2019

the last reported error is not windows specific. i have the same error for the satis.phar created on the debian build server (gitlab).

PHP Fatal error:  Class 'Symfony\Component\Console\Application' not found in phar:///usr/local/bin/satis/src/Console                                                                               /Application.php on line 30

should i open a new ticket for this?

@theofidry
Copy link
Member Author

theofidry commented Mar 2, 2019 via email

@theofidry
Copy link
Member Author

--debug -> Call to undefined function spl_object_id()

Note that this was an issue from symfony/var-dumper which hopefully has now been solved (it seems to be shipping the polyfill as expected)

@c33s
Copy link

c33s commented Mar 5, 2019

--debug -> Call to undefined function spl_object_id()

Note that this was an issue from symfony/var-dumper which hopefully has now been solved (it seems to be shipping the polyfill as expected)

still broken

λ box compile --debug
[debug] Checking BOX_ALLOW_XDEBUG
[debug] The xdebug extension is not loaded

    ____
   / __ )____  _  __
  / __  / __ \| |/_/
 / /_/ / /_/ />  <
/_____/\____/_/|_|


Box version 3.5.0@cfc7c11 2019-03-05 00:51:30 UTC


 // Loading the configuration file
 // "C:\satis\box.json".

🔨  Building the PHAR "C:/satis/satis.phar"


Fatal error: Uncaught Error: Call to undefined function spl_object_id() in phar://C:/bin/box.phar/vendor/symfony/var-dumper/Cloner/VarCloner.php:142
Stack trace:
#0 phar://C:/bin/box.phar/vendor/symfony/var-dumper/Cloner/AbstractCloner.php(58): _HumbugBox9257ad6c1a66\Symfony\Component\VarDumper\Cloner\VarCloner->doClone(Object(_HumbugBox9257ad6c1a66\KevinGH\Box\Configuration))
#1 phar://C:/bin/box.phar/src/Console/Command/Compile.php(179): _HumbugBox9257ad6c1a66\Symfony\Component\VarDumper\Cloner\AbstractCloner->cloneVar(Object(_HumbugBox9257ad6c1a66\KevinGH\Box\Configuration))
#2 phar://C:/bin/box.phar/src/Console/Command/Compile.php(131): _HumbugBox9257ad6c1a66\KevinGH\Box\Console\Command\Compile->removeExistingArtifacts(Object(_HumbugBox9257ad6c1a66\KevinGH\Box\Configuration), Object(_HumbugBox9257ad6c1a66\KevinGH\Box\Console\Logger\CompileLogger), true)
#3 phar://C:/bin/box.phar/vendor/symfony/console/Command/Command.php(127): _HumbugBox9257ad6c1a66\KevinGH\Box\Console\Command\Compil in phar://C:/bin/box.phar/vendor/symfony/var-dumper/Cloner/VarCloner.php on line 142

@c33s
Copy link

c33s commented Mar 5, 2019

wouldn't it be better to create an issue for each problem/bug and add a "windows" label to it? this issue is getting bigger and bigger which makes it unclear.

of course you have the tasks in the description but this ticket is quite an epic

@c33s
Copy link

c33s commented Mar 5, 2019

by the way why "Check the compatibility with emojis"? it looks like that it is not compatible. simply remove them or add don't show them on windows or add a flag & an environment variable for it.

@theofidry
Copy link
Member Author

appveyor

Added to the top description of this issue.

The filename, directory name, or volume label syntax is incorrect. #353

I'm not sure there is a specific issue there to be honest. I suspect making sure all tests works on Windows would actually solve the problem. If anything though, there was a feature request about including dot files (cf. this comment) but so far no one has been willing to work on it.

vendor/composer/installed.json #337

It is actually not windows specific. Opened #368 for it.

--debug -> Call to undefined function spl_object_id()

Actually not windows specific, opened #367 for it. It's actually a scoping issue.

emojis

Included in the top list of the issue. "Check the compatibility with emojis" is voluntary vague: if there is possible support it's about checking how feasible it is, otherwise it's about removing them on Windows.

cannot run box if files are in the root dir

What is that?

@c33s
Copy link

c33s commented Mar 5, 2019

cannot run box if files are in the root dir

What is that?

#193 (comment)

@theofidry
Copy link
Member Author

Can you open a new issue for that one with the details about what exists in the root? (e.g. in the current output it complains about /composer.json not being found)

@c33s
Copy link

c33s commented Apr 25, 2019

tried to compile a symfony project with box 3.7.0

#!/usr/bin/env php

Fatal error: Uncaught Symfony\Component\Config\Exception\FileLocatorFileNotFoundException: The file "./config" does not exist (in: ). in phar://<redacted>/puppet-enc/build/puppet-enc.phar/vendor/symfony/config/FileLocator.php:71
Stack trace:
#0 phar://<redacted>/puppet-enc/build/puppet-enc.phar/vendor/symfony/http-kernel/Config/FileLocator.php(52): Symfony\Component\Config\FileLocator->locate('./config', NULL, true)
#1 phar://<redacted>/puppet-enc/build/puppet-enc.phar/vendor/symfony/config/Loader/FileLoader.php(110): Symfony\Component\HttpKernel\Config\FileLocator->locate('./config', NULL, true)
#2 phar://<redacted>/puppet-enc/build/puppet-enc.phar/vendor/symfony/dependency-injection/Loader/GlobFileLoader.php(26): Symfony\Component\Config\Loader\FileLoader->glob('/{packages}/*.{...', false, NULL)
#3 phar://<redacted>/pu in phar://<redacted>/puppet-enc/build/puppet-enc.phar/vendor/symfony/config/FileLocator.php on line 71

box.yaml

files:
    - composer.json
directories:
    - bin
    - config
    - src
    - lib
finder:
    -
      name: '*.*'
      in: vendor
      exclude:
        - .gitignore
        - .md
        - phpunit
        - Tester
        - Tests
        - tests
compactors:
    - Herrera\Box\Compactor\Json
    - Herrera\Box\Compactor\Php
compression: GZ
main: bin/puppet-enc
output: build/puppet-enc.phar
stub: true
git-commit: git_commit
git-version: git_version
git-tag: git_tag
chmod: '0755'

@theofidry
Copy link
Member Author

theofidry commented Apr 25, 2019 via email

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

Successfully merging a pull request may close this issue.

2 participants