Flutter项目执行pod install遇Unicode归一化编码错误求助
执行pod install时出现如下错误:
WARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
Consider adding the following to ~/.profile:
export LANG=en_US.UTF-8/Users/chandan/.rvm/rubies/ruby-3.1.0/lib/ruby/3.1.0/unicode_normalize/normalize.rb:141:in
normalize': Unicode Normalization not appropriate for ASCII-8BIT (Encoding::CompatibilityError) from /Users/chandan/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/cocoapods-1.15.2/lib/cocoapods/config.rb:167:inunicode_normalize'
from /Users/chandan/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/cocoapods-1.15.2/lib/cocoapods/config.rb:167:ininstallation_root' from /Users/chandan/.rvm/rubies/ruby-3.1.0/lib/ruby/gems/3.1.0/gems/cocoapods-1.15.2/lib/cocoapods/config.rb:227:inpodfile_path'
解决方案
1. 临时修复(当前终端会话有效)
在终端直接执行以下命令,随后重新运行pod install:
export LANG=en_US.UTF-8
2. 永久修复(所有终端会话生效)
根据你使用的Shell类型编辑对应配置文件:
- Bash:编辑
~/.bash_profile或~/.profile - Zsh:编辑
~/.zshrc
在文件末尾添加以下内容:
export LANG=en_US.UTF-8 export LC_ALL=en_US.UTF-8
保存后执行命令使配置生效:
- Bash:
source ~/.bash_profile或source ~/.profile - Zsh:
source ~/.zshrc
3. RVM环境额外处理(若上述方法无效)
检查当前Ruby环境的编码设置:
rvm ruby-3.1.0 do ruby -e 'puts Encoding.default_external'
若输出不是UTF-8,编辑RVM环境配置文件~/.rvm/environments/ruby-3.1.0,添加:
export LANG=en_US.UTF-8 export LC_ALL=en_US.UTF-8
执行以下命令重新加载RVM:
rvm reload
内容的提问来源于stack exchange,提问作者Chandan

