question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[macOS]: failed to launch from VSCode: ArgumentError - invalid byte sequence in US-ASCII

See original GitHub issue

_Issue moved from https://github.com/google/flutter-desktop-embedding/issues/586#event-2689960105_

I got this error when I was trying to launch macOS from VSCode:

Launching lib/main.dart on macOS in debug mode...
CocoaPods' output:
↳
      Preparing
    Analyzing dependencies
    Inspecting targets to integrate
      CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only perfomed in repo update
    ――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
    ### Command
    ```
    /usr/local/Cellar/cocoapods/1.8.1/libexec/bin/pod install --verbose

   ...

   ArgumentError - invalid byte sequence in US-ASCII

   ...


    [!] Oh no, an error occurred.
    Search for existing GitHub issues similar to yours:
    https://github.com/CocoaPods/CocoaPods/search?q=invalid+byte+sequence+in+US-ASCII&type=Issues
    If none exists, create a ticket, with the template displayed above, on:
    https://github.com/CocoaPods/CocoaPods/issues/new
    Be sure to first read the contributing guide for details on how to properly submit a ticket:
    https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md
    Don't forget to anonymize any private data!
    Looking for related issues on cocoapods/cocoapods...
     - Pod Install failed
       https://github.com/CocoaPods/CocoaPods/issues/9222 [open] [1 comment]
       14 hours ago
     - Error while setting up CocoaPods
       https://github.com/CocoaPods/CocoaPods/issues/5979 [closed] [23 comments]
       06 Dec 2018
     - invalid byte sequence in US-ASCII
       https://github.com/CocoaPods/CocoaPods/issues/1036 [closed] [9 comments]
       08 Jun 2017
    and 15 more at:
    https://github.com/cocoapods/cocoapods/search?q=invalid%20byte%20sequence%20in%20US-ASCII&type=Issues&utf8=βœ“
Error output from CocoaPods:
↳
        WARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
        Consider adding the following to ~/.profile:
        export LANG=en_US.UTF-8

I have export LANG=en_US.UTF-8 in my ~/.profile and have also configured VSCode as:

{
  "dart.env": {
    "LANG": "en-US.UTF-8",
  }
}

However, directly launch from terminal works:

flutter run -d macOS

My other targets web, ios and android work from VSCode.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:29 (17 by maintainers)

github_iconTop GitHub Comments

2reactions
mrottlercommented, Oct 21, 2019

Never mind. It’s amazing how many times you can look at something and not see the error until after you post it! Anyway, once I fixed the entry for LC_ALL in my VS Code settings.json file, then the error went away for me too.

For reference, here’s the entry in my settings.json file that is working:

   "dart.env": {
        "LC_ALL": "en_US.UTF-8",
        "LANG": "en_US.UTF-8"
    }

Thank you @DanTup for your help with this. I am sorry for the noise.

1reaction
DanTupcommented, Nov 27, 2019

I’m seeing this on my Mac now, so was able to do some more debugging. Here’s my understanding of the issue:

  • CocoaPods warns if the default encoding isn’t set to something UTF8 (which it gets from reading LANG etc.) because it affects how it reads files
  • On macOS, the LANG env var is set by the terminal at startup - it is not set system-wide for programs not launched from the terminal
  • If you launch VS Code outside of the terminal, it doesn’t have LANG set, that results in us spawning flutter run without it set, and that results in CocoaPods/Ruby using ansii encoding and breaking on UTF-8

The ideal fix would be β€œDart-Code should just set UTF8” on all its processes - however LANG requires both a language part and encoding, so if LANG isn’t already set, we don’t know what to set this to. In VS Code it seems that Intl.DateTimeFormat().resolvedOptions().locale returns the correct thing for the main process, however it’s incorrect in the extension host.

I’ve opened https://github.com/microsoft/vscode/issues/85675 to see if this can be fixed. Using dart.env is still the current workaround, but I think if VS Code can expose the system language to us, we could set this explicitly to avoid the need for that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"invalid byte sequence" running remote code via ssh from ...
Running File.open('/home/bob/input.txt').read.encoding gives US-ASCII when executed from Windows/Cygwin/ssh and UTF-8 from macOS/Terminal/ssh.
Read more >
Fix for bundle install: ArgumentError: invalid byte sequence in ...
I stumbled across a weird issue with bundler on MacOS X: ... v2.1) ArgumentError: invalid byte sequence in US-ASCII An error occured whileΒ ......
Read more >
error running pod install - You.com | The AI Search Engine ...
I am trying to run my application in ios simulator but i am getting below error. The application was running okay but then...
Read more >
Trying to install Brew on MacOS 10.10.5. Getting "invalid byte ...
Coding example for the question Trying to install Brew on MacOS 10.10.5. Getting "invalid byte sequence in UTF-8 (ArgumentError)"-ruby.
Read more >
colorls/CHANGELOG and colorls Releases | LibHunt
Can't re-install colorls after updating to macOS Big Sur #418 ... invalid byte sequence in US-ASCII (ArgumentError) #352; An error was reported after...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found