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

Install Fails on Windows with error "not within the allowed path" #2636

Closed
sarcanon opened this issue Jan 26, 2014 · 6 comments
Closed

Install Fails on Windows with error "not within the allowed path" #2636

sarcanon opened this issue Jan 26, 2014 · 6 comments

Comments

@sarcanon
Copy link

I am unable to install composer on Windows using either the installer or manual installation. This is on Windows 7 (64). I'm trying to install in my development stack (WT-NMP).

With the automatic installer, the error is:

The PHP file you specified did not execute correctly: F:\WT-NMP\bin\php-5.4.24\php.exe

Running it from the command line might highlight the problem.
Use the -v switch to show the PHP version - it must be at least 5.3.2
Internal Error [ERR_STATUS], exit code 255

When I attempt to install manually, this is what happens:

F:\WT-NMP\bin\php-5.4.24>php -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"
#!/usr/bin/env php
All settings correct for using Composer
PHP Warning:  realpath(): open_basedir restriction in effect. File(F:\WT-NMP\bin\php-5.4.24) is not within the allowed path(s): (c:/work/wt-nmp) in Command line code(1) : eval()'d code on line 312

Warning: realpath(): open_basedir restriction in effect. File(F:\WT-NMP\bin\php-5.4.24) is not within the allowed path(s): (c:/work/wt-nmp) in Command line code(1) : eval()'d code on line 312
PHP Warning:  is_readable(): open_basedir restriction in effect. File(F:\WT-NMP\bin\php-5.4.24\composer.phar) is not within the allowed path(s): (c:/work/wt-nmp)
in Command line code(1) : eval()'d code on line 315

Warning: is_readable(): open_basedir restriction in effect. File(F:\WT-NMP\bin\php-5.4.24\composer.phar) is not within the allowed path(s): (c:/work/wt-nmp) in Command line code(1) : eval()'d code on line 315
Downloading...
Could not create file F:\WT-NMP\bin\php-5.4.24\composer.phar: fopen(): open_basedir restriction in effect. File(F:\WT-NMP\bin\php-5.4.24\composer.phar) is not within the allowed path(s): (c:/work/wt-nmp)
fopen(F:\WT-NMP\bin\php-5.4.24\composer.phar): failed to open stream: Operation not permitted
Download failed: fopen(): open_basedir restriction in effect. File(F:\WT-NMP\bin\php-5.4.24\composer.phar) is not within the allowed path(s): (c:/work/wt-nmp)
fopen(F:\WT-NMP\bin\php-5.4.24\composer.phar): failed to open stream: Operation not permitted
fwrite() expects parameter 1 to be resource, boolean given
Downloading...
Could not create file F:\WT-NMP\bin\php-5.4.24\composer.phar: fopen(): open_basedir restriction in effect. File(F:\WT-NMP\bin\php-5.4.24\composer.phar) is not within the allowed path(s): (c:/work/wt-nmp)
fopen(F:\WT-NMP\bin\php-5.4.24\composer.phar): failed to open stream: Operation not permitted
Download failed: fopen(): open_basedir restriction in effect. File(F:\WT-NMP\bin\php-5.4.24\composer.phar) is not within the allowed path(s): (c:/work/wt-nmp)
fopen(F:\WT-NMP\bin\php-5.4.24\composer.phar): failed to open stream: Operation not permitted
fwrite() expects parameter 1 to be resource, boolean given
Downloading...
Could not create file F:\WT-NMP\bin\php-5.4.24\composer.phar: fopen(): open_basedir restriction in effect. File(F:\WT-NMP\bin\php-5.4.24\composer.phar) is not within the allowed path(s): (c:/work/wt-nmp)
fopen(F:\WT-NMP\bin\php-5.4.24\composer.phar): failed to open stream: Operation not permitted
Download failed: fopen(): open_basedir restriction in effect. File(F:\WT-NMP\bin\php-5.4.24\composer.phar) is not within the allowed path(s): (c:/work/wt-nmp)
fopen(F:\WT-NMP\bin\php-5.4.24\composer.phar): failed to open stream: Operation not permitted
fwrite() expects parameter 1 to be resource, boolean given
The download failed repeatedly, aborting.

Might someone be able to tell me what I am doing wrong?

Thank you.

@sarcanon
Copy link
Author

No doubt this is probably obvious to the experts, but for the sake of the archive should any other newb run across this issue in the future, it was a matter of PHP not knowing where to find its php.ini file, thus it defaulted to some basic set of settings, which included a non-existent base directory. Once I figured this out, I re-ran the install command explicitly setting the path to the php.ini file, like this:

php -c F:\WT-NMP\conf\php.ini -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"

and all was well.

May I recommend some better error handling in the installer pointing out this possible problem if PHP is not give a valid .ini file?

Thanks.

@jakoch
Copy link
Contributor

jakoch commented Jan 31, 2014

You found the solution yourself: this is not a Composer, but PHP environment / configuration issue.

@sachinjadhav21
Copy link

Thanks, but I am still facing the same issue.

C:>php -c c:\WT-NMP\conf\php.ini -r "eval('?>'.file_get_contents('https://getco
mposer.org/installer'));"
#!/usr/bin/env php
All settings correct for using Composer

Warning: realpath(): open_basedir restriction in effect. File(C:) is not within
the allowed path(s): (c:/wt-nmp) in Command line code(1) : eval()'d code on lin
e 366

Warning: is_readable(): open_basedir restriction in effect. File(C:\composer.ph
ar) is not within the allowed path(s): (c:/wt-nmp) in Command line code(1) : eva
l()'d code on line 369

Warning: is_readable(): open_basedir restriction in effect. File(/etc/pki/tls/ce
rts/ca-bundle.crt) is not within the allowed path(s): (c:/wt-nmp) in Command lin
e code(1) : eval()'d code on line 787

Warning: is_readable(): open_basedir restriction in effect. File(/etc/ssl/certs/
ca-certificates.crt) is not within the allowed path(s): (c:/wt-nmp) in Command l
ine code(1) : eval()'d code on line 787

Warning: is_readable(): open_basedir restriction in effect. File(/etc/ssl/ca-bun
dle.pem) is not within the allowed path(s): (c:/wt-nmp) in Command line code(1)
: eval()'d code on line 787

Warning: is_readable(): open_basedir restriction in effect. File(/usr/local/shar
e/certs/ca-root-nss.crt) is not within the allowed path(s): (c:/wt-nmp) in Comma
nd line code(1) : eval()'d code on line 787

Warning: is_readable(): open_basedir restriction in effect. File(/usr/ssl/certs/
ca-bundle.crt) is not within the allowed path(s): (c:/wt-nmp) in Command line co
de(1) : eval()'d code on line 787

Warning: is_readable(): open_basedir restriction in effect. File(/opt/local/shar
e/curl/curl-ca-bundle.crt) is not within the allowed path(s): (c:/wt-nmp) in Com
mand line code(1) : eval()'d code on line 787

Warning: is_readable(): open_basedir restriction in effect. File(/usr/local/shar
e/curl/curl-ca-bundle.crt) is not within the allowed path(s): (c:/wt-nmp) in Com
mand line code(1) : eval()'d code on line 787

Warning: is_readable(): open_basedir restriction in effect. File(/usr/share/ssl/
certs/ca-bundle.crt) is not within the allowed path(s): (c:/wt-nmp) in Command l
ine code(1) : eval()'d code on line 787

Fatal error: Uncaught exception 'RuntimeException' with message 'Unable to write
bundled cacert.pem to: C:/Users/Sachin/AppData/Roaming/Composer/cacert.pem' in
Command line code(1) : eval()'d code:402
Stack trace:
#0 Command line code(1) : eval()'d code(112): installComposer(false, false, 'com
poser.phar', false, false, false)
#1 Command line code(1) : eval()'d code(14): process(Array)
#2 Command line code(1): eval()
#3 {main}
thrown in Command line code(1) : eval()'d code on line 402

@jakoch
Copy link
Contributor

jakoch commented Mar 17, 2014

Can not reproduce.
Tested:
composer-install-windows-test
Command used php -r "readfile('https://getcomposer.org/installer');" | php

My suggestion: instead of using WT-NMP, you might consider using a server stack for windows, which ships Composer out of the box, like http://wpn-xm.org/

@vdohare
Copy link

vdohare commented Jun 28, 2018

I knew its too late, but may help someone else.
I just commented a line in php.ini by putting a semicolon in front of the following line
;open_basedir =

And this worked for me

@Bogdancev
Copy link

@vdohare Thanx, it worked for me too.

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

No branches or pull requests

5 participants