Skip to content

On Windows 10, Launch of LLDB gets error regarding init_fs_encoding #301

Closed
@KimTheLearner

Description

@KimTheLearner

Issue Description

On Windows 10, the launch of Swift's LLDB gets error:

Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Possibly related, but perhaps this was submitted to the wrong project: vadimcn/codelldb#566

Note that I had previously accepted the VS Code prompt that created this in my workspace settings.json file, which correctly points to the Swift custom LLDB:

{
    "lldb.library": "C:\\Library\\Developer\\Toolchains\\unknown-Asserts-development.xctoolchain\\usr\\bin\\liblldb.dll"
}

And hey, thanks so much for this work!!

Environment

OS: Windows 10
VSCode version: 1.65.2
Swift extension version: 0.5.1 (released just yesterday)
CodeLLDB version: 1.7.0
Compiler: Swift 5.6.1

Test Case

md hello
cd hello
swift package init --type=executable
place these lines into main.swift:

print("Hello, world!")
print()
print()

open folder with VS Code
compile with: Terminal > Build Debug hello
hello.exe is built, and I can run it just fine from the command prompt.

The Error

set breakpoint on line 2
Run > Start Debugging
this error pops up in VS Code:

"Oops! The debug adapter has terminated abnormally."
Source: CodeLLDB (Extension)          Open log

and that log says:

configuration: {
  type: 'lldb',
  request: 'launch',
  name: 'Debug hello',
  program: '${workspaceFolder:hello}/.build/debug/hello',
  args: [],
  cwd: '${workspaceFolder:hello}',
  preLaunchTask: 'swift: Build Debug hello',
  __configurationTarget: 5,
  relativePathBase: 'k:\\Kim Shared\\CodeLab\\SwiftTests\\hello'
}
Python path configuration:
  PYTHONHOME = 'C:/hostedtoolcache/windows/Python/3.10.2/x64'
  PYTHONPATH = (not set)
  program name = 'python'
  isolated = 0
  environment = 1
  user site = 1
  import site = 1
  sys._base_executable = 'c:\\Users\\Kim\\.vscode\\extensions\\vadimcn.vscode-lldb-1.7.0\\adapter\\codelldb.exe'
  sys.base_prefix = 'C:/hostedtoolcache/windows/Python/3.10.2/x64'
  sys.base_exec_prefix = 'C:/hostedtoolcache/windows/Python/3.10.2/x64'
  sys.platlibdir = 'lib'
  sys.executable = 'c:\\Users\\Kim\\.vscode\\extensions\\vadimcn.vscode-lldb-1.7.0\\adapter\\codelldb.exe'
  sys.prefix = 'C:/hostedtoolcache/windows/Python/3.10.2/x64'
  sys.exec_prefix = 'C:/hostedtoolcache/windows/Python/3.10.2/x64'
  sys.path = [
    'C:\\Program Files\\Python\\Python310\\python310.zip',
    'C:/hostedtoolcache/windows/Python/3.10.2/x64\\DLLs',
    'C:/hostedtoolcache/windows/Python/3.10.2/x64\\lib',
    'c:\\Users\\Kim\\.vscode\\extensions\\vadimcn.vscode-lldb-1.7.0\\adapter',
  ]
Fatal Python error: init_fs_encoding: Debug adapter exit code=1, signal=null.
failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00001328 (most recent call first):
  <no Python frame>

Note that sys.path references python310.zip and .../Python/3.10.2/... - neither of which do I have. However I do have these in my Path before the start of VS Code:

C:\Program Files\Python\Python310\;C:\Program Files\Python\Python310\Scripts\

I know this Path addition solved the identical error for me a couple weeks ago when I was using LLDB from the Command Prompt, so I suspect they are not in the Path at the time LLDB is launched by the extension.

Variations

I can run LLDB from the command prompt on this program and the debugger works just fine.

If I delete settings.json, so that the default LLDB is used, then Run > Start Debugging will cause the debugger to run the program and break at the desired breakpoint. While it does allow stepping through the program, no variables are displayable, which of course is why we have the Swift custom version of LLDB.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions