简体   繁体   中英

Updating UTF in VSCode Terminal

Problem

There is an error when launching a flutter application in VSCode. It require the LANG setting to be en_US.UTF-8

Already Tried

The issue and warning can be found here: https://github.com/NativeScript/NativeScript/issues/3659

I've followed the advice I found there and added export LANG=en_US.UTF-8 in my .bash_profile (mac) which has updated VSCode's UTF as well.

Error Message(s)

However, when I re-run, I receive the same warning(s):

 WARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
        Consider adding the following to ~/.profile:
        export LANG=en_US.UTF-8

Where can I find the ~/.profile file to update it as well?

The problem here is likely that where you've set the environment variable doesn't apply to VS Code based on how you ran it. For example if you set an env variable in .profile but then launch VS Code from the iOS dock, it might not inherit that value.

To confuse things, when you use the built-in Terminal in VS Code, it will cause your bash startup scripts to run, which meants the built-in terminal makes it seem like the variable is set (but it's actually only set for the terminal, and not for commands that VS Code extensions spawn).

There are two possible fixes:

  1. Set the environment variable somewhere that it is applied system-wide (this may be tricky depending on your OS)
  2. Set it in dart.env in your VS Code user settings:
     "dart.env": { "LANG": "en_US.UTF-8" }, 
    This should apply it to any Flutter processes spawned by the Flutter extension and prevent the warning.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM