Skip to content

mpremote utility doesn't find config.py in Windows #9689

Closed as not planned
Closed as not planned
@jerrens

Description

@jerrens

The mpremote utility expects to find the .config/mpremote/config.py file relative to the path stored in the XDG_CONFIG_HOME environment variable first, then looks in the HOME environment variable next if that was not defined. 1

In Windows, HOME is not an environment variable defined by default, but the counterpart is HOMEPATH.

I am currently able to work around this problem by manually creating a HOME env var and setting it's value to %HOMEPATH%, but if the mpremote utility could be updated to either check the OS first and then use that to determine the appropriate environment variable, or use the suggestion in this StackOverflow answer 2:

from os.path import expanduser
home = expanduser("~")

If you're on Python 3.5+ you can use pathlib.Path.home():

from pathlib import Path
home = str(Path.home())

to correctly find the user's home directory, then support for user-defined commands would be enabled for all OSes.

Footnotes

  1. https://github.com/micropython/micropython/blob/f13134e40308c24bcb2c09084f17fc9d54efe5db/tools/mpremote/mpremote/main.py#L330-#L357

  2. https://stackoverflow.com/a/4028943/2136313

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions