Comments (13)
Running wp package list
results in:
PHP Warning: file_get_contents(phar://D:/dev/wp-cli/wp-cli.phar/vendor/composer/ca-bundle/src/../res/cacert.pem): failed to open stream: phar error: "vendor/composer/ca-bundle/res/cacert.pem" is not a file in phar "D:/dev/wp-cli/wp-cli.phar" in phar://D:/dev/wp-cli/wp-cli.phar/vendor/composer/ca-bundle/src/CaBundle.php on line 140
Warning: file_get_contents(phar://D:/dev/wp-cli/wp-cli.phar/vendor/composer/ca-bundle/src/../res/cacert.pem): failed to open stream: phar error: "vendor/composer/ca-bundle/res/cacert.pem" is not a file in phar "D:/dev/wp-cli/wp-cli.phar" in phar://D:/dev/wp-cli/wp-cli.phar/vendor/composer/ca-bundle/src/CaBundle.php on line 140
Error: Failed to get composer instance: The configured cafile was not valid or could not be read.
So this seems related to #4703, #72 and it's resolution #73.
Has #73 not been merged into the latest WP-CLI 2.1.0?
from package-command.
The fix in #73 has been merged into WP-CLI and is part of v2.1.0.
My first guess would be that the SSL_CERT_FILE
environment variable that the fix wants to set is either not correctly set or that Composer does ignore it in this case.
from package-command.
The SSL_CERT_FILE
env variable is not set. However, if I do set it to phar://wp-cli.phar/vendor/rmccue/requests/library/Requests/Transport/cacert.pem
as per wp-cli/wp-cli#4703 (comment), everything works fine. This is regardless of whether I run everything as admin or not.
from package-command.
Okay, so the fix we did has a few conditionals, and maybe one if them is failing:
https://github.com/wp-cli/package-command/pull/73/files#diff-ca5ded108d7e84b923c359071e50f993R1070
Can you check whether one of these environment variables might be set for you?
from package-command.
Okay, to be more precise, check whether any of the following exist:
- environment variable
SSL_CERT_FILE
(you already checked that one) - environment variable
SSL_CERT_DIR
- PHP ini value
openssl.cafile
- PHP ini value
openssl.capath
Also, maybe the check to see whether you're in a Phar is failing for you. Please verify the result of the following command:
wp eval "var_dump( WP_CLI\Utils\inside_phar() );"
from package-command.
Only openssl.cafile
is set: openssl.cafile = "\dev\xampp\apache\bin\curl-ca-bundle.crt"
and the result of that command is bool(true)
. This is a XAMPP
portable stack, so this will be pretty common.
from package-command.
Okay, so I assume that:
openssl.cafile
being set disable the fix in #73- This means we would land here in Composer: https://github.com/composer/ca-bundle/blob/1.1.0/src/CaBundle.php#L84
- I assume this fails somehow (maybe file cannot be validated?), so we fall through until Composer tries to load the bundled file: https://github.com/composer/ca-bundle/blob/1.1.0/src/CaBundle.php#L121
- Can you try to temporarily unset
openssl.cafile
to see whether that fixes the issue? - Can you try to diagnose why one of the conditions in here fails: https://github.com/composer/ca-bundle/blob/1.1.0/src/CaBundle.php#L85
from package-command.
- Unsetting
openssl.cafile = "\dev\xampp\apache\bin\curl-ca-bundle.crt"
solves the issue. Also, setting the full path including the drive letter like soopenssl.cafile = "d:\dev\xampp\apache\bin\curl-ca-bundle.crt"
also solves the issue. The former is the wayXAMPP
portable configures itself, and it makes sense so that the stack is fully portable, as in working from a USB stick. - I don't know how to test that, but I presume it's to do with the above mentioned path.
from package-command.
Okay, so this is in fact an upstream issue with Composer on Windows then.
Composer fails to properly validate the provided CA file here: https://github.com/composer/ca-bundle/blob/1.1.0/src/CaBundle.php#L85
This means that there's not much to change at the WP-CLI side of things, but it might make sense to introduce a bug report to the Composer repository instead.
from package-command.
@schlessera Doing that is unfortunately beyond my knowledge level, so, if you could be bothered to do it instead, it would be great. Regardless, thank you for your time!
from package-command.
I've created an upstream ticket. I'm not sure this is something that can be solved by Composer, so you shouldn't hold your breath and just remove/adapt the openssl.cafile
setting for now.
I'm closing the ticket as there's currently no next action for WP-CLI, but we can reopen if needed.
from package-command.
I will set the SSL_CERT_FILE
env variable to phar://wp-cli.phar/vendor/rmccue/requests/library/Requests/Transport/cacert.pem
as a mitigation for now. Thank you!
from package-command.
I was facing the same issue on my windows setup.
Quick SOLUTION is:
- In my
php.ini
there is a codeopenssl.cafile
which have set the filecurl-ca-bundle.crt
E.g.
openssl.cafile="C:\xampp\apache\bin\curl-ca-bundle.crt"
I notice that the file curl-ca-bundle.crt
NOT EXIST in location C:\xampp\apache\bin\
- On other computers localhost, I found that the path for
openssl.cafile
inphp.ini
file was not set.
For both the above cases, I have followed the below steps:
- Step 1: Download the
cacert.pem
file from https://curl.haxx.se/docs/caextract.html - Step 2: Paste into
C:\xampp\apache\bin\
- Step 3: Make sure the
curl.exe
and thecacert.pem
file in the same directory. - Step 4: Rename the
cacert.pem
file tocurl-ca-bundle.crt
- Step 5: Re-run
curl.exe
!
More Details
My old version of WP CLI was 2.1.0
.
C:\xampp\htdocs\dev.test\wp-content
λ wp cli info
OS: Windows NT 6.3 build 9600 (Windows 8.1 Professional Edition) AMD64
Shell: C:\Windows\system32\cmd.exe
PHP binary: C:\xampp\php\php.exe
PHP version: 7.3.2
php.ini used: C:\xampp\php\php.ini
WP-CLI root dir: phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir: phar://wp-cli.phar/vendor
WP_CLI phar path: C:\xampp\htdocs\dev.test\wp-content
WP-CLI packages dir: C:\Users\MaheshW/.wp-cli/packages/
WP-CLI global config:
WP-CLI project config:
WP-CLI version: 2.1.0
I have update my WP CLI version:
C:\xampp\htdocs\dev.test\wp-content
λ wp cli update
You have version 2.1.0. Would you like to update to 2.2.0? [y/n] y
Downloading from https://github.com/wp-cli/wp-cli/releases/download/v2.2.0/wp-cli-2.2.0.phar...
md5 hash verified: ffdc73bf30a4fa74079b9472993b0645
New version works. Proceeding to replace.
Success: Updated WP-CLI to 2.2.0.
But, After update still getting the same error.
C:\xampp\htdocs\dev.test\wp-content
λ wp package list
PHP Warning: file_get_contents(phar://C:/wp-cli/wp-cli.phar/vendor/composer/ca-bundle/src/../res/cacert.pem): failed to open stream: phar error: "vendor/composer/ca-bundle/res/cacert.pem" is not a file in phar "C:/wp-cli/wp-cli.phar" in phar://C:/wp-cli/wp-cli.phar/vendor/composer/ca-bundle/src/CaBundle.php on line 140
Warning: file_get_contents(phar://C:/wp-cli/wp-cli.phar/vendor/composer/ca-bundle/src/../res/cacert.pem): failed to open stream: phar error: "vendor/composer/ca-bundle/res/cacert.pem" is not a file in phar "C:/wp-cli/wp-cli.phar" in phar://C:/wp-cli/wp-cli.phar/vendor/composer/ca-bundle/src/CaBundle.php on line 140
Error: Failed to get composer instance: The configured cafile was not valid or could not be read.
I have execute the wp eval "var_dump( WP_CLI\Utils\inside_phar() );"
as per about discussion:
C:\xampp\htdocs\dev.test\wp-content
λ wp eval "var_dump( WP_CLI\Utils\inside_phar() );"
bool(true)
I thought its composer issue so I was update an composer:
C:\xampp\htdocs\dev.test\wp-content
λ composer -V
Composer version 1.8.0 2018-12-03 10:31:16
C:\xampp\htdocs\dev.test\wp-content
λ cd C:\ProgramData\ComposerSetup\bin
C:\ProgramData\ComposerSetup\bin
λ composer selfupdate
Updating to version 1.8.5 (stable channel).
Downloading (100%)
Use composer self-update --rollback to return to version 1.8.0
C:\ProgramData\ComposerSetup\bin
λ composer -V
Composer version 1.8.5 2019-04-09 17:46:47
After composer update still getting the same error.
C:\ProgramData\ComposerSetup\bin
λ cd C:\xampp\htdocs\dev.test\wp-content
C:\xampp\htdocs\dev.test\wp-content
λ wp package list
PHP Warning: file_get_contents(phar://C:/wp-cli/wp-cli.phar/vendor/composer/ca-bundle/src/../res/cacert.pem): failed to open stream: phar error: "vendor/composer/ca-bundle/res/cacert.pem" is not a file in phar "C:/wp-cli/wp-cli.phar" in phar://C:/wp-cli/wp-cli.phar/vendor/composer/ca-bundle/src/CaBundle.php on line 140
Warning: file_get_contents(phar://C:/wp-cli/wp-cli.phar/vendor/composer/ca-bundle/src/../res/cacert.pem): failed to open stream: phar error: "vendor/composer/ca-bundle/res/cacert.pem" is not a file in phar "C:/wp-cli/wp-cli.phar" in phar://C:/wp-cli/wp-cli.phar/vendor/composer/ca-bundle/src/CaBundle.php on line 140
Error: Failed to get composer instance: The configured cafile was not valid or could not be read.
After a search on stackoverflow, I found the solution. https://stackoverflow.com/questions/28858351/php-ssl-certificate-error-unable-to-get-local-issuer-certificate
After implementing the solution, I have successfully fixed the above issue.
C:\xampp\htdocs\dev.test\wp-content
λ wp package list
+------------------------+---------+------------+-----------+----------------+
| name | authors | version | update | update_version |
+------------------------+---------+------------+-----------+----------------+
| wp-cli/profile-command | | dev-master | available | dev-master |
+------------------------+---------+------------+-----------+----------------+
Hope, It helps for you too.
from package-command.
Related Issues (20)
- installing package on Intranet HOT 3
- Adopt and enforce new `WP_CLI_CS` standard HOT 2
- Allow install from a Git repository specific branch HOT 1
- check_git_package_name hardcode reference to GitHub HOT 2
- Commands Cookbook link goes to a 404 HOT 1
- Lock framework to stable version again before release
- Compatibility with Composer 2 HOT 7
- Legacy package index prevents installation of current release of a package HOT 2
- Allow composer ^2.0 HOT 6
- SSL certificate problem: certificate has expired HOT 9
- Declaration of WP_CLI\ComposerIO::isVerbose() and others not compatible with Composer\IO\NullIO::isVerbose(): bool HOT 2
- Restore 'Install a package with a dependency' test
- Support for Composer 2.5 HOT 8
- Errors installing command into development environment HOT 3
- Add command to get information about single package HOT 4
- Move command over to new v2 structure
- Prefer packagist.org over Github
- Automatically rerun failed scenarios
- Broke composer commands when used with phpcodesniffer-composer-installer HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from package-command.