Coder Social home page Coder Social logo

Comments (13)

Hlsgs avatar Hlsgs commented on August 17, 2024

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.

schlessera avatar schlessera commented on August 17, 2024

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.

Hlsgs avatar Hlsgs commented on August 17, 2024

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.

schlessera avatar schlessera commented on August 17, 2024

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.

schlessera avatar schlessera commented on August 17, 2024

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.

Hlsgs avatar Hlsgs commented on August 17, 2024

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.

schlessera avatar schlessera commented on August 17, 2024

Okay, so I assume that:

  1. Can you try to temporarily unset openssl.cafile to see whether that fixes the issue?
  2. 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.

Hlsgs avatar Hlsgs commented on August 17, 2024
  1. Unsetting openssl.cafile = "\dev\xampp\apache\bin\curl-ca-bundle.crt" solves the issue. Also, setting the full path including the drive letter like so openssl.cafile = "d:\dev\xampp\apache\bin\curl-ca-bundle.crt" also solves the issue. The former is the way XAMPP portable configures itself, and it makes sense so that the stack is fully portable, as in working from a USB stick.
  2. I don't know how to test that, but I presume it's to do with the above mentioned path.

from package-command.

schlessera avatar schlessera commented on August 17, 2024

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.

Hlsgs avatar Hlsgs commented on August 17, 2024

@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.

schlessera avatar schlessera commented on August 17, 2024

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.

Hlsgs avatar Hlsgs commented on August 17, 2024

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.

maheshwaghmare avatar maheshwaghmare commented on August 17, 2024

I was facing the same issue on my windows setup.

Quick SOLUTION is:

  1. In my php.ini there is a code openssl.cafile which have set the file curl-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\

  1. On other computers localhost, I found that the path for openssl.cafile in php.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 the cacert.pem file in the same directory.
  • Step 4: Rename the cacert.pem file to curl-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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.