Auth error when trying to build with snapcraft 7.5.4

I am getting an error when trying to build my project with snapcraft 7.5.4. It is a core 18 project and previously was building ok. Since January I refreshed from the 7.x channel to maintain support for core18. Now I get this error:

> ubuntu@snapcraft-epi-gateway:/Users/jennymurphy/GITHUB/DEV/EPI_GATEWAY_#3/epi-gateway$ snapcraft --destructive-mode -v
> Starting Snapcraft 7.5.4                                                                                                                                              
> Logging execution to '/home/ubuntu/.local/state/snapcraft/log/snapcraft-20240111-133157.121225.log'                                                                   
> Sorry, an error occurred in Snapcraft:
> [Errno 13] Permission denied: 'auth.conf.d'
> We would appreciate it if you anonymously reported this issue.
> No other data than the traceback and the version of snapcraft in use will be sent.
> Would you like to send this error data? (Yes/No/Always/View) [no]: no
> You can find the traceback in file '/tmp/tmpn4srh9qx/trace.txt'.

Here are the contents of the trace file:

> ubuntu@snapcraft-epi-gateway:/Users/jennymurphy/GITHUB/DEV/EPI_GATEWAY_#3/epi-gateway$ more /tmp/tmpn4srh9qx/trace.txt
> Traceback (most recent call last):
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/snapcraft/cli.py", line 256, in run
>     _run_dispatcher(dispatcher, global_args)
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/snapcraft/cli.py", line 229, in _run_dispatcher
>     dispatcher.run()
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/craft_cli/dispatcher.py", line 448, in run
>     return self._loaded_command.run(self._parsed_command_args)
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/snapcraft/commands/lifecycle.py", line 265, in run
>     super().run(parsed_args)
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/snapcraft/commands/lifecycle.py", line 138, in run
>     parts_lifecycle.run(self.name, parsed_args)
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 179, in run
>     yaml_data = process_yaml(snap_project.project_file)
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 142, in process_yaml
>     yaml_data = yaml_utils.load(yaml_file)
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/snapcraft/parts/yaml_utils.py", line 94, in load
>     raise errors.LegacyFallback(f"base is {build_base}")
> snapcraft.errors.LegacyFallback: base is core18
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/snapcraft_legacy/cli/legacy.py", line 27, in legacy_run
>     run()
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
>     return self.main(*args, **kwargs)
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/click/core.py", line 1055, in main
>     rv = self.invoke(ctx)
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/click/core.py", line 1635, in invoke
>     rv = super().invoke(ctx)
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
>     return ctx.invoke(self.callback, **ctx.params)
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/click/core.py", line 760, in invoke
>     return __callback(*args, **kwargs)
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/click/decorators.py", line 26, in new_func
>     return f(get_current_context(), *args, **kwargs)
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/snapcraft_legacy/cli/_runner.py", line 139, in run
>     snap_command.invoke(ctx)
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
>     return ctx.invoke(self.callback, **ctx.params)
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/click/core.py", line 760, in invoke
>     return __callback(*args, **kwargs)
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/snapcraft_legacy/cli/lifecycle.py", line 405, in snap
>     _execute(steps.PRIME, parts=tuple(), pack_project=True, output=output, **kwargs)
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/snapcraft_legacy/cli/lifecycle.py", line 131, in _execute
>     lifecycle.execute(step, project_config, parts)
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/snapcraft_legacy/internal/lifecycle/_runner.py", line 145, in execute
>     executor.run(step, part_names)
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/snapcraft_legacy/internal/lifecycle/_runner.py", line 199, in run
>     self._handle_step(part_names, part, step, current_step, cli_config)
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/snapcraft_legacy/internal/lifecycle/_runner.py", line 213, in _handle_step
>     getattr(self, "_run_{}".format(current_step.name))(part)
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/snapcraft_legacy/internal/lifecycle/_runner.py", line 255, in _run_pull
>     self._run_step(step=steps.PULL, part=part, progress="Pulling")
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/snapcraft_legacy/internal/lifecycle/_runner.py", line 353, in _run_step
>     self._prepare_step(step=step, part=part)
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/snapcraft_legacy/internal/lifecycle/_runner.py", line 344, in _prepare_step
>     preparation_function()
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/snapcraft_legacy/internal/pluginhandler/__init__.py", line 489, in prepare_pull
>     self._fetch_stage_packages()
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/snapcraft_legacy/internal/pluginhandler/__init__.py", line 468, in _fetch_stage_packages
>     self.stage_packages = self._stage_packages_repo.fetch_stage_packages(
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/snapcraft_legacy/internal/repo/_deb.py", line 493, in fetch_stage_packages
>     with AptCache(
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/snapcraft_legacy/internal/repo/apt_cache.py", line 53, in __enter__
>     self._populate_stage_cache_dir()
>   File "/snap/snapcraft/10085/lib/python3.8/site-packages/snapcraft_legacy/internal/repo/apt_cache.py", line 120, in _populate_stage_cache_dir
>     shutil.rmtree(cache_etc_apt_path)
>   File "/snap/snapcraft/10085/usr/lib/python3.8/shutil.py", line 718, in rmtree
>     _rmtree_safe_fd(fd, path, onerror)
>   File "/snap/snapcraft/10085/usr/lib/python3.8/shutil.py", line 659, in _rmtree_safe_fd
>     onerror(os.rmdir, fullname, sys.exc_info())
>   File "/snap/snapcraft/10085/usr/lib/python3.8/shutil.py", line 657, in _rmtree_safe_fd
>     os.rmdir(entry.name, dir_fd=topfd)
> PermissionError: [Errno 13] Permission denied: 'auth.conf.d'

Hi there, how unfortunate! Was the previous version of snapcraft also 7.5.4 before the refresh to 7.x to track that version?

This looks like something was once run in --destructive-mode with sudo and then wasn’t, could that have been the case?

Yes that could be the exact scenario!. I would have have version 7.5.4 before.