First, some background. I have 6 Magento 2.2.x sites on a development server. 4 of the 6 upgraded just fine. I used the same standard composer upgrade process on all of them. They're on a single apache/php environment via virtualhosts so they all have the same resources.

On 2 of them, I get this error when trying to compile (edited to remove the domain):

Warning: stream_wrapper_unregister(): Unable to unregister protocol phar:// in [DOCUMENT ROOT PATH]/html/app/bootstrap.php on line 11

I can't seem to get any further information about where the issue actually is. I've reset the files & database to pre-upgrade state and it compiles fine (one is 2.2.7, the other is 2.2.5) -- but if I repeat the upgrade, then it errors again.

Any information about how to troubleshoot further would be greatly appreciated.

  • 1
    A little further digging so far - running compile with the '-vvv' verbose output option I can get the module name on each where it dies. In both cases those are custom modules that make use of bootstrap.php via n include/require. The sites that did't have an issue don't have anything making a reference to bootstrap.php anywhere in /app/code/* -- so it would seem something changed between 2.2.7 and 2.2.8 as relates to how that bootstrap.php is used/handled. – Eric Priepke Mar 28 at 16:04
  • Sorry I am new to this. Could you explain how to "modified the custom modules not not require bootstrap.php"? – Varsha Mar 30 at 18:43
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review – fmsthird Mar 30 at 23:44

So in the end, the road block was 2 custom modules that use the app/bootstrap.php

Between 2.2.7 and 2.2.8 there was a commit to bootstrap.php that only added:


Phar is enabled (verified with phpinfo(); ) but it doesn't seem to have the stream_wrapper enabled as that doesn't list specifically for Phar, but does list for other extensions, like bzip. So the Magento 2.2.8 code change just fires off a disable without a check to see if it IS enabled first -- apparently.

For now, we've modified the custom modules not not require bootstrap.php

  • Having a similar issue, but the upgrade went fine, but the error happens after the upgrade to 2.2.8 from 2.2.7 - how did you figure out which extension was causing the issue? – dawhoo Mar 29 at 21:56
  • 1
    Running the compile with verbose output (the -vvv argument) will show you the trace when it dies and which module it is that causes it. In our case, only one module on each site was trying to use the functions in bootstrap where the change occurred. The difference in bootstrap is specifically in the 2.2.8 update where they add the unregister without any checking to see if the stream wrapper is even enabled first. So to get around it you either have to enable the stream wrapper for phar somehow, or change the code to not need bootstrap. – Eric Priepke Apr 1 at 15:10
  • I tried using the -vvv during compile, but I didn't see any errors in CLI, but that may be because mine is already installed without issue? I was using php bin/magento setup:di:compile ---vvv But it didn't show anything much at all really. I also tried php bin/magento setup:di:compile -vvv and php bin/magento setup:di:compile -vvv and none seemed to look any different than the others as far as information display. It was same as if I didn't use -vvv so not to sure what the issue might be - still looking. – dawhoo Apr 4 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.