Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snapcraft 8.2.1: snapcraft pack not respecting <directory> arg to find snapcraft.yaml #4769

Closed
dbungert opened this issue Apr 29, 2024 · 11 comments · Fixed by canonical/craft-application#340
Labels
bug Actual bad behavior that don't fall into maintenance or documentation

Comments

@dbungert
Copy link

Bug Description

When using snapcraft 8.2.1, I find that repacking an existing snap by using the directory arg has regressed. Reverting snapcraft (to 8.0.5 in my case) allows this to work again.

To Reproduce

snap download hello
unsquashfs hello_42.snap
snapcraft pack squashfs-root --output hello.snap

workaround:

snap download hello
unsquashfs hello_42.snap
cd squashfs-root
snapcraft pack . --output ../hello.snap

Environment

Ubuntu 24.04

snapcraft.yaml

# n/a

Relevant log output

2024-04-29 15:05:47.128 Starting snapcraft, version 8.2.1
2024-04-29 15:05:47.128 Log verbosity level set to BRIEF
2024-04-29 15:05:47.128 Configuring application...
2024-04-29 15:05:47.128 Preparing application...
2024-04-29 15:05:47.129 Build plan: platform=None, build_for=None
2024-04-29 15:05:47.129 Project file 'snapcraft.yaml' not found in '/tmp/tmp.2ItMSEP6Oi'.
2024-04-29 15:05:47.129 Detailed information: The project file could not be found.
2024-04-29 15:05:47.131 Traceback (most recent call last):
2024-04-29 15:05:47.131   File "/snap/snapcraft/11471/lib/python3.10/site-packages/snapcraft/application.py", line 136, in _resolve_project_path
2024-04-29 15:05:47.131     return super()._resolve_project_path(project_dir / "snap")
2024-04-29 15:05:47.131   File "/snap/snapcraft/11471/lib/python3.10/site-packages/craft_application/application.py", line 242, in _resolve_project_path
2024-04-29 15:05:47.131     return (project_dir / f"{self.app.name}.yaml").resolve(strict=True)
2024-04-29 15:05:47.131   File "/snap/snapcraft/11471/usr/lib/python3.10/pathlib.py", line 1077, in resolve
2024-04-29 15:05:47.131     s = self._accessor.realpath(self, strict=strict)
2024-04-29 15:05:47.131   File "/snap/snapcraft/11471/bin/../usr/lib/python3.10/posixpath.py", line 396, in realpath
2024-04-29 15:05:47.131     path, ok = _joinrealpath(filename[:0], filename, strict, {})
2024-04-29 15:05:47.131   File "/snap/snapcraft/11471/bin/../usr/lib/python3.10/posixpath.py", line 431, in _joinrealpath
2024-04-29 15:05:47.131     st = os.lstat(newpath)
2024-04-29 15:05:47.131 FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp.2ItMSEP6Oi/snap'
2024-04-29 15:05:47.131 
2024-04-29 15:05:47.131 During handling of the above exception, another exception occurred:
2024-04-29 15:05:47.131 Traceback (most recent call last):
2024-04-29 15:05:47.131   File "/snap/snapcraft/11471/lib/python3.10/site-packages/snapcraft/application.py", line 139, in _resolve_project_path
2024-04-29 15:05:47.131     return super()._resolve_project_path(project_dir)
2024-04-29 15:05:47.131   File "/snap/snapcraft/11471/lib/python3.10/site-packages/craft_application/application.py", line 242, in _resolve_project_path
2024-04-29 15:05:47.131     return (project_dir / f"{self.app.name}.yaml").resolve(strict=True)
2024-04-29 15:05:47.131   File "/snap/snapcraft/11471/usr/lib/python3.10/pathlib.py", line 1077, in resolve
2024-04-29 15:05:47.131     s = self._accessor.realpath(self, strict=strict)
2024-04-29 15:05:47.131   File "/snap/snapcraft/11471/bin/../usr/lib/python3.10/posixpath.py", line 396, in realpath
2024-04-29 15:05:47.131     path, ok = _joinrealpath(filename[:0], filename, strict, {})
2024-04-29 15:05:47.131   File "/snap/snapcraft/11471/bin/../usr/lib/python3.10/posixpath.py", line 431, in _joinrealpath
2024-04-29 15:05:47.131     st = os.lstat(newpath)
2024-04-29 15:05:47.131 FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp.2ItMSEP6Oi/snapcraft.yaml'
2024-04-29 15:05:47.131 
2024-04-29 15:05:47.131 During handling of the above exception, another exception occurred:
2024-04-29 15:05:47.131 Traceback (most recent call last):
2024-04-29 15:05:47.131   File "/snap/snapcraft/11471/lib/python3.10/site-packages/craft_application/application.py", line 263, in get_project
2024-04-29 15:05:47.131     project_path = self._resolve_project_path(self.project_dir)
2024-04-29 15:05:47.131   File "/snap/snapcraft/11471/lib/python3.10/site-packages/snapcraft/application.py", line 141, in _resolve_project_path
2024-04-29 15:05:47.131     return super()._resolve_project_path(project_dir / "build-aux" / "snap")
2024-04-29 15:05:47.131   File "/snap/snapcraft/11471/lib/python3.10/site-packages/craft_application/application.py", line 242, in _resolve_project_path
2024-04-29 15:05:47.131     return (project_dir / f"{self.app.name}.yaml").resolve(strict=True)
2024-04-29 15:05:47.131   File "/snap/snapcraft/11471/usr/lib/python3.10/pathlib.py", line 1077, in resolve
2024-04-29 15:05:47.131     s = self._accessor.realpath(self, strict=strict)
2024-04-29 15:05:47.131   File "/snap/snapcraft/11471/bin/../usr/lib/python3.10/posixpath.py", line 396, in realpath
2024-04-29 15:05:47.131     path, ok = _joinrealpath(filename[:0], filename, strict, {})
2024-04-29 15:05:47.131   File "/snap/snapcraft/11471/bin/../usr/lib/python3.10/posixpath.py", line 431, in _joinrealpath
2024-04-29 15:05:47.131     st = os.lstat(newpath)
2024-04-29 15:05:47.131 FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp.2ItMSEP6Oi/build-aux'
2024-04-29 15:05:47.131 Recommended resolution: Ensure the project file exists.

Additional context

No response

@dbungert dbungert added the bug Actual bad behavior that don't fall into maintenance or documentation label Apr 29, 2024
Copy link

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-2861.

This message was autogenerated

@mr-cal
Copy link
Collaborator

mr-cal commented Apr 29, 2024

Thanks for the report. I can confirm this is a regression. We had a similar report in the Snapcraft channel on Matrix here.

I'll take a look and see what we can do to fix this.

@caarlos0
Copy link

got an issue about this on goreleaser too

goreleaser/goreleaser#4816

@caarlos0
Copy link

also worth noting that before this version the snapcraft.yaml file wasn't even needed.

Before, we created an structure like this:

❯ lt /tmp/nix-shell.NTGJBy/TestRunPipe348068566/001/dist/foo_amd64/prime
 prime
├──  foo
└──  meta
    └──  snap.yaml

and it was enough for it to work.

is this behavior being removed? if so, this should probably have been a major release 🤔

@mr-cal
Copy link
Collaborator

mr-cal commented Apr 30, 2024

is this behavior being removed? if so, this should probably have been a major release 🤔

No, sorry about this. This was an unintentional regression and we're working on a fix.

As a temporary workaround, you can revert to the previous release with the revisions listed here: https://forum.snapcraft.io/t/call-for-testing-snapcraft-8-2-1/39928/2

@twpayne
Copy link

twpayne commented Apr 30, 2024

Thank you for the speedy response @mr-cal -- much appreciated!

@mr-cal
Copy link
Collaborator

mr-cal commented May 9, 2024

This should be fixed in snapcraft 8.2.6, which has been released to latest/stable.

If anyone here can test and confirm, I would appreciate it. Thanks!

@dbungert
Copy link
Author

dbungert commented May 9, 2024

Retested with 8.2.6, LGTM. Thanks for the fix!

@caarlos0
Copy link

caarlos0 commented May 9, 2024

goreleaser tests are passing with 8.2.6!

thanks!

@twpayne
Copy link

twpayne commented May 9, 2024

chezmoi passing too, thanks!

@claudioandre-br
Copy link

It's actually a little bit more complicated than that. Launchpad plus:

  • Snapcraft 8.0.5 is able to find and use a file called .snapcraft.yaml in the main folder.
  • Snapcraft 8.2.7 cannot. The error message is:
Project file 'snapcraft.yaml' not found in [...]

The obvious solution is to rename .snapcraft.yaml to snapcraft.yaml and move on. Just did that.

But this could also be a regression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Actual bad behavior that don't fall into maintenance or documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants