lucc / khard

Console vcard client
https://khard.readthedocs.io/en/latest/
GNU General Public License v3.0
600 stars 65 forks source link

TypeError: expected str, bytes or os.PathLike object, not list #245

Closed gitschneider closed 4 years ago

gitschneider commented 4 years ago

When using the default (mostly) khard will exit with a traceback on any action:

Traceback (most recent call last):
  File "/usr/bin/khard", line 11, in <module>
    load_entry_point('khard==0.14.0', 'console_scripts', 'khard')()
  File "/usr/lib/python3/dist-packages/khard/khard.py", line 1752, in main
    args = parse_args(argv)
  File "/usr/lib/python3/dist-packages/khard/khard.py", line 1703, in parse_args
    config = Config(args.config)
  File "/usr/lib/python3/dist-packages/khard/config.py", line 75, in __init__
    self.editor = find_executable(os.path.expanduser(self.editor))
  File "/usr/lib/python3.7/posixpath.py", line 235, in expanduser
    path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not list

After checking the traceback it was clear that the editor config is the culprit. The entry in ~/.config/khard/khard.conf is editor = vim, -i, NONE , and this gets converted to ['vim', '-i', 'NONE'] in config.py:74, but expanduser does not like the list.

When using just vim or leaving out the entry everything works as expected.

My config:

[addressbooks]
[[default]]
path = ~/.cache/contacts/contacts/

[general]
debug = yes
default_action = list
# These are either strings or comma seperated lists
editor = vim, -i, NONE
merge_editor = vimdiff

[contact table]
# display names by first or last name: first_name / last_name / formatted_name
display = first_name
# group by address book: yes / no
group_by_addressbook = no
# reverse table ordering: yes / no
reverse = no
# append nicknames to name column: yes / no
show_nicknames = no
# show uid table column: yes / no
show_uids = yes
# sort by first or last name: first_name / last_name / formatted_name
sort = last_name
# localize dates: yes / no
localize_dates = yes
# set a comma separated list of preferred phone number types in descending priority
# or nothing for non-filtered alphabetical order
preferred_phone_number_type = pref, cell, home
# set a comma separated list of preferred email address types in descending priority
# or nothing for non-filtered alphabetical order
preferred_email_address_type = pref, work, home

[vcard]
# extend contacts with your own private objects
# these objects are stored with a leading "X-" before the object name in the vcard files
# every object label may only contain letters, digits and the - character
# example:
#   private_objects = Jabber, Skype, Twitter
private_objects = Jabber, Skype, Twitter
# preferred vcard version: 3.0 / 4.0
preferred_version = 3.0
# Look into source vcf files to speed up search queries: yes / no
search_in_source_files = no
# skip unparsable vcard files: yes / no
skip_unparsable = no
scheibler commented 4 years ago

Khard supports editor command line args since version 0.15.0. Please either upgrade or remove the args after the editor command in your config file.

gitschneider commented 4 years ago

Oh, the config file says version strictly greater v0.14... And I had khard installed from ubuntu 19.10, which had v0.14. As pip3 show khard showed me the same version I assumed it's the latest one and did not check any further. But now I have 0.15 installed, everything works fine.

So: sorry, completely my own faul. Thanks!