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

pear-pear.php.net packages install fails on Windows #3942

Closed
brandomeniconi opened this issue Apr 16, 2015 · 3 comments · Fixed by #4100
Closed

pear-pear.php.net packages install fails on Windows #3942

brandomeniconi opened this issue Apr 16, 2015 · 3 comments · Fixed by #4100
Labels
Milestone

Comments

@brandomeniconi
Copy link

When I'm trying to install this project with a PEAR dependancy:

...
"repositories": [
    {
        "type": "pear",
        "url": "http://pear.php.net"
    }    
  ],
  "require": {
    "php": ">=5.4",
    "pear-pear.php.net/Services_GeoNames":"*"    
  } 
...

i'm getting the following error:

Initializing PEAR repository http://pear.php.net
Updating dependencies (including require-dev)
  - Installing pear-pear.php.net/net_url2 (2.1.1)
    Loading from cache

[UnexpectedValueException]
Failed to extract PEAR package C:\Users\Username\project\vendor/pear-pear.php.net/Net_URL2/Net_URL2-2.1.1.tgz to C:\Users\Username\project\vendor/pear-pear.php.net/Net_URL2. 
Reason: simplexml_load_file(): I/O warning : failed to load external entity "C:\Users\Username\project\vendor/pear-pear.php.net/Net_URL2/tarball/package.xml"

[ErrorException]
simplexml_load_file(): I/O warning : failed to load external entity "C:\Users\Username\project\vendor/pear-pear.php.net/Net_URL2/tarball/package.xml"

update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--with-dependencies] [-v|vv|v
vv|--verbose] [-o|--optimize-autoloader] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [packages1] ... [packagesN]

I'm on a Windows 8.1 machine and I noticed that the path passed to simplexml_load_file(), which causes the error, has mixed backward and forward slashes. Could be that the problem?

@brandomeniconi
Copy link
Author

Update: tested on linux env and works good.

@jakoch
Copy link
Contributor

jakoch commented Apr 16, 2015

I can't reproduce this on Win7. I ran composer install twice. First a normal install, then with deleted vendor folder to test the package loading from cache, like in your issue.

@brandomeniconi
Copy link
Author

I found the problem: the PHP installation shipped with Google AppEngine comes with external XML entity loader disabled.

I just recompiled composer with:

libxml_disable_entity_loader(false);

and the installer works. Sorry :).

But I can propose to use:

if ($fileContents = file_get_contents($uri)) {
  $xmlItem = simplexml_load_string($fileContents);
}

to workaround this rare issue.

Thanks

@Seldaek Seldaek added the Bug label May 1, 2015
@Seldaek Seldaek added this to the Bugs milestone May 1, 2015
alcohol added a commit to alcohol/composer that referenced this issue Jun 3, 2015
If the entity loader is disabled on a system, loading files, even from
the local file system, is considered as external to the running php
process, and thus not allowed by the libxml extension. Reading the file
contents and loading the xml as a string is a valid alternative however.
Seldaek added a commit that referenced this issue Jun 3, 2015
load xml as string from local file, fixes #3942
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants