Ubuntu – How to solve the error: WARNING:root:could not open file ‘/etc/apt/sources.list’


wazir@wazir:~$ sudo software-properties-gtk
[sudo] password for wazir: 

(process:15506): Gtk-WARNING **: Locale not supported by C library.
    Using the fallback 'C' locale.
Cannot set locale: unsupported locale setting
WARNING:root:could not open file '/etc/apt/sources.list'

WARNING:root:could not open file '/etc/apt/sources.list'

Traceback (most recent call last):
  File "/usr/bin/software-properties-gtk", line 104, in <module>
    app = SoftwarePropertiesGtk(datadir=options.data_dir, options=options, file=file)
  File "/usr/lib/python2.7/dist-packages/softwareproperties/gtk/SoftwarePropertiesGtk.py", line 89, in __init__
    SoftwareProperties.__init__(self, options=options, datadir=datadir)
  File "/usr/lib/python2.7/dist-packages/softwareproperties/SoftwareProperties.py", line 97, in __init__
  File "/usr/lib/python2.7/dist-packages/softwareproperties/SoftwareProperties.py", line 585, in reload_sourceslist
  File "/usr/lib/python2.7/dist-packages/aptsources/distro.py", line 87, in get_sources
    raise NoDistroTemplateException("Error: could not find a "
aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template

Best Answer

Changing the permissions might work:

sudo chmod -R 0644 /etc/apt/sources.list.d/

UPDATE: I previously set the mode to 0420, which worked in my case, but per comments and further testing it seems that 0644 is correct.

Related Question