Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

iconv(): Wrong charset, conversion from UTF-8 to ASCII//TRANSLIT//IGNORE is not allowed #43

Closed
deleugpn opened this issue May 14, 2019 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@deleugpn
Copy link
Contributor

When running Insights on my Laravel project, I get the following stack

[14-May-2019 11:33:45 UTC] [2019-05-14 11:33:45] testing.ERROR: iconv(): Wrong charset, conversion from `UTF-8' to `ASCII//TRANSLIT//IGNORE' is not allowed {"exception":"[object] (ErrorException(code: 0): iconv(): Wrong charset, conversion from `UTF-8' to `ASCII//TRANSLIT//IGNORE' is not allowed at /app/vendor/nette/utils/src/Utils/Strings.php:185)
[stacktrace]
#0 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(8, 'iconv(): Wrong ...', '/app/vendor/net...', 185, Array)
#1 /app/vendor/nette/utils/src/Utils/Strings.php(185): iconv('UTF-8', 'ASCII//TRANSLIT...', '/app')
#2 /app/vendor/nette/utils/src/Utils/Strings.php(201): Nette\\Utils\\Strings::toAscii('/app')
#3 /app/vendor/symplify/easy-coding-standard/packages/ChangedFilesDetector/src/Cache/Simple/FilesystemCacheFactory.php(22): Nette\\Utils\\Strings::webalize('/app')
#4 /tmp/easy_coding_standard/ContainerDWVx86O/getFilesystemCacheService.php(9): Symplify\\EasyCodingStandard\\ChangedFilesDetector\\Cache\\Simple\\FilesystemCacheFactory->create()
#5 /tmp/easy_coding_standard/ContainerDWVx86O/HttpKernelSymplify_EasyCodingStandard_HttpKernel_EasyCodingStandardKernelProd19580Container.php(174): require('/tmp/easy_codin...')
#6 /tmp/easy_coding_standard/ContainerDWVx86O/getSimpleCacheAdapterService.php(9): ContainerDWVx86O\\HttpKernelSymplify_EasyCodingStandard_HttpKernel_EasyCodingStandardKernelProd19580Container->load('getFilesystemCa...')
#7 /tmp/easy_coding_standard/ContainerDWVx86O/HttpKernelSymplify_EasyCodingStandard_HttpKernel_EasyCodingStandardKernelProd19580Container.php(174): require('/tmp/easy_codin...')
#8 /tmp/easy_coding_standard/ContainerDWVx86O/getTagAwareAdapterService.php(9): ContainerDWVx86O\\HttpKernelSymplify_EasyCodingStandard_HttpKernel_EasyCodingStandardKernelProd19580Container->load('getSimpleCacheA...')
#9 /tmp/easy_coding_standard/ContainerDWVx86O/HttpKernelSymplify_EasyCodingStandard_HttpKernel_EasyCodingStandardKernelProd19580Container.php(174): require('/tmp/easy_codin...')
#10 /tmp/easy_coding_standard/ContainerDWVx86O/getChangedFilesDetectorService.php(9): ContainerDWVx86O\\HttpKernelSymplify_EasyCodingStandard_HttpKernel_EasyCodingStandardKernelProd19580Container->load('getTagAwareAdap...')
#11 /tmp/easy_coding_standard/ContainerDWVx86O/HttpKernelSymplify_EasyCodingStandard_HttpKernel_EasyCodingStandardKernelProd19580Container.php(174): require('/tmp/easy_codin...')
#12 /tmp/easy_coding_standard/ContainerDWVx86O/getErrorAndDiffCollectorService.php(9): ContainerDWVx86O\\HttpKernelSymplify_EasyCodingStandard_HttpKernel_EasyCodingStandardKernelProd19580Container->load('getChangedFiles...')
#13 /tmp/easy_coding_standard/ContainerDWVx86O/HttpKernelSymplify_EasyCodingStandard_HttpKernel_EasyCodingStandardKernelProd19580Container.php(174): require('/tmp/easy_codin...')
#14 /tmp/easy_coding_standard/ContainerDWVx86O/getFileFactoryService.php(9): ContainerDWVx86O\\HttpKernelSymplify_EasyCodingStandard_HttpKernel_EasyCodingStandardKernelProd19580Container->load('getErrorAndDiff...')
#15 /tmp/easy_coding_standard/ContainerDWVx86O/HttpKernelSymplify_EasyCodingStandard_HttpKernel_EasyCodingStandardKernelProd19580Container.php(174): require('/tmp/easy_codin...')
#16 /tmp/easy_coding_standard/ContainerDWVx86O/getSniffFileProcessorService.php(9): ContainerDWVx86O\\HttpKernelSymplify_EasyCodingStandard_HttpKernel_EasyCodingStandardKernelProd19580Container->load('getFileFactoryS...')
#17 /tmp/easy_coding_standard/ContainerDWVx86O/HttpKernelSymplify_EasyCodingStandard_HttpKernel_EasyCodingStandardKernelProd19580Container.php(174): require('/tmp/easy_codin...')
#18 /app/vendor/symfony/dependency-injection/Container.php(243): ContainerDWVx86O\\HttpKernelSymplify_EasyCodingStandard_HttpKernel_EasyCodingStandardKernelProd19580Container->load('getSniffFilePro...')
#19 /app/vendor/symfony/dependency-injection/Container.php(225): Symfony\\Component\\DependencyInjection\\Container->make('Symplify\\\\EasyCo...', 1)
#20 /app/vendor/nunomaduro/phpinsights/src/Application/Injectors/FileProcessors.php(31): Symfony\\Component\\DependencyInjection\\Container->get('Symplify\\\\EasyCo...')
#21 [internal function]: NunoMaduro\\PhpInsights\\Application\\Injectors\\FileProcessors::NunoMaduro\\PhpInsights\\Application\\Injectors\\{closure}()
#22 /app/vendor/league/container/src/Definition/Definition.php(233): call_user_func_array(Object(Closure), Array)
#23 /app/vendor/league/container/src/Definition/Definition.php(196): League\\Container\\Definition\\Definition->resolveCallable(Object(Closure))
#24 /app/vendor/league/container/src/Definition/DefinitionAggregate.php(94): League\\Container\\Definition\\Definition->resolve(false)
#25 /app/vendor/league/container/src/Container.php(153): League\\Container\\Definition\\DefinitionAggregate->resolve('NunoMaduro\\\\PhpI...', false)
#26 /app/vendor/nunomaduro/phpinsights/src/Domain/Insights/InsightFactory.php(175): League\\Container\\Container->get('NunoMaduro\\\\PhpI...')
#27 /app/vendor/nunomaduro/phpinsights/src/Domain/Insights/InsightFactory.php(71): NunoMaduro\\PhpInsights\\Domain\\Insights\\InsightFactory->getSniffCollector(Array)
#28 /app/vendor/nunomaduro/phpinsights/src/Domain/Insights/InsightCollectionFactory.php(74): NunoMaduro\\PhpInsights\\Domain\\Insights\\InsightFactory->makeFrom('ObjectCalisthen...', Array)
#29 [internal function]: NunoMaduro\\PhpInsights\\Domain\\Insights\\InsightCollectionFactory::NunoMaduro\\PhpInsights\\Domain\\Insights\\{closure}('ObjectCalisthen...')
#30 /app/vendor/nunomaduro/phpinsights/src/Domain/Insights/InsightCollectionFactory.php(79): array_map(Object(Closure), Array)
#31 /app/vendor/nunomaduro/phpinsights/src/Application/Console/Analyser.php(43): NunoMaduro\\PhpInsights\\Domain\\Insights\\InsightCollectionFactory->get(Array, Array, '/app')
#32 /app/vendor/nunomaduro/phpinsights/src/Application/Console/Commands/AnalyseCommand.php(68): NunoMaduro\\PhpInsights\\Application\\Console\\Analyser->analyse(Object(NunoMaduro\\PhpInsights\\Application\\Console\\Style), Array, '/app')
#33 /app/vendor/nunomaduro/phpinsights/src/Application/Adapters/Laravel/Commands/InsightsCommand.php(43): NunoMaduro\\PhpInsights\\Application\\Console\\Commands\\AnalyseCommand->__invoke(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#34 [internal function]: NunoMaduro\\PhpInsights\\Application\\Adapters\\Laravel\\Commands\\InsightsCommand->handle(Object(NunoMaduro\\PhpInsights\\Application\\Console\\Commands\\AnalyseCommand))
#35 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#36 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#37 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#38 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(572): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#39 /app/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\\Container\\Container->call(Array)
#40 /app/vendor/symfony/console/Command/Command.php(255): Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#41 /app/vendor/laravel/framework/src/Illuminate/Console/Command.php(170): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#42 /app/vendor/symfony/console/Application.php(908): Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#43 /app/vendor/symfony/console/Application.php(269): Symfony\\Component\\Console\\Application->doRunCommand(Object(NunoMaduro\\PhpInsights\\Application\\Adapters\\Laravel\\Commands\\InsightsCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#44 /app/vendor/symfony/console/Application.php(145): Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#45 /app/vendor/laravel/framework/src/Illuminate/Console/Application.php(89): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#46 /app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(122): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#47 /app/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#48 {main}
"}


In Strings.php line 185:

  iconv(): Wrong charset, conversion from `UTF-8' to `ASCII//TRANSLIT//IGNORE' is not allowed

I haven't figured out what's the root cause yet.

@deleugpn
Copy link
Contributor Author

deleugpn commented May 14, 2019

Looks like it's an upstream issue with a dependency. Nette Utils doesn't work properly on Docker Alpine images.

Insights depends on Simplify (deprecated-packages/symplify#966) which depends on Nette (nette/utils#109) which uses iconv in a state that doesn't work well with Alpine. Alpine seems to think that this is a weird quirk with how PHP works (docker-library/php#240 (comment)).

There's a trail of assigning blame, but ultimately the current state of PHP Insights won't work from an Alpine image without at least trying out to hack iconv (docker-library/php#240 (comment)). I want to try some static analyses, but I'm not changing dozens of production-ready Alpine images for it, unfortunately.

@nunomaduro nunomaduro added the help wanted Extra attention is needed label May 14, 2019
@deleugpn deleugpn mentioned this issue May 16, 2019
@zolotov88
Copy link

# fix work iconv library with alphine
RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/ --allow-untrusted gnu-libiconv
ENV LD_PRELOAD /usr/lib/preloadable_libiconv.so php

@back-2-95
Copy link

This helped we when I tried to use https://github.com/palantirnet/drupal-rector first time with my Alpine 3.11 based Docker image.

@gsusI
Copy link

gsusI commented Sep 11, 2021

Fixed by installing php7-mbstring php7-iconv in that order

RUN apk --no-cache add php7-mbstring php7-iconv

Original solution here: docker-library/php#240 (comment)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants