Code cracker
Code cracker

Reputation: 396

How to rectify Call to undefined function Symfony\Component\Console\Helper\mb_detect_encoding() after installing composer?

I am using ubuntu 21.04 in that i installed composer by using this command sudo apt-get install composer ,after installing i type composer it's showing following error

HP Fatal error:  Uncaught Error: Call to undefined function Symfony\Component\Console\Helper\mb_detect_encoding() in /usr/share/php/Symfony/Component/Console/Helper/Helper.php:50
Stack trace:
#0 /usr/share/php/Symfony/Component/Console/Descriptor/TextDescriptor.php(329): Symfony\Component\Console\Helper\Helper::strlen('h')
#1 /usr/share/php/Symfony/Component/Console/Descriptor/TextDescriptor.php(97): Symfony\Component\Console\Descriptor\TextDescriptor->calculateTotalWidthForOptions(Array)
#2 /usr/share/php/Symfony/Component/Console/Descriptor/TextDescriptor.php(197): Symfony\Component\Console\Descriptor\TextDescriptor->describeInputDefinition(Object(Symfony\Component\Console\Input\InputDefinition), Array)
#3 /usr/share/php/Symfony/Component/Console/Descriptor/Descriptor.php(55): Symfony\Component\Console\Descriptor\TextDescriptor->describeApplication(Object(Composer\Console\Application), Array)
#4 /usr/share/php/Symfony/Component/Console/Helper/DescriptorHelper.php(67): Symfony\Component\Console\Descriptor\Descriptor->describ in /usr/share/php/Symfony/Component/Console/Helper/Helper.php on line 50

please help me to fix this issue

Upvotes: 12

Views: 29773

Answers (4)

Cassette.-Earthling0
Cassette.-Earthling0

Reputation: 91

Hello I encountered this issue on php8.2 while the stack trace differs from OP doing as mentionned by @MiraTech @user16784870 or @Jay-Teli fixed this error :

sudo apt-get install php8.2-mbstring

Upvotes: 5

Maxim Suslov
Maxim Suslov

Reputation: 5465

Check phpinfo.php for ctype module information. In my case, it wasn't loaded and I didn't see the following:

ctype module loaded

I activated it in php.ini (location depends on your configuration):

;extension=curl
extension=ctype # uncomment or add this
;extension=ffi

and restart php service. You should see ctype module's block and error should go away.

Upvotes: 0

MiraTech
MiraTech

Reputation: 1302

If you're using PHP 7.4:

sudo apt-get install php7.4-mbstring

Upvotes: 3

user16784870
user16784870

Reputation:

You simply enable mbstring extension it will remove the uncaught error

sudo apt-get install php7.2-mbstring

Upvotes: 24

Related Questions