canonical / action-build

A Github action for building Snapcraft projects
MIT License
42 stars 22 forks source link

Invalid cross-device link on action-build #52

Closed deadc0de6 closed 1 year ago

deadc0de6 commented 1 year ago

I'm not sure what I'm doing wrong here, can you help me? I'm using snapcore/action-build in github action and it fails with following error during the build step. I tried using ubuntu-20.04 as well as using actions/checkout@v2 with no success.

This runs on this repository

+ snapcraftctl pull
[Errno 13] Permission denied: '/sys/kernel/mm/page_idle/bitmap'
Traceback (most recent call last):
  File "/snap/snapcraft/8619/lib/python3.8/site-packages/snapcraft_legacy/file_utils.py", line 101, in link_or_copy
    link(source, destination, follow_symlinks=follow_symlinks)
  File "/snap/snapcraft/8619/lib/python3.8/site-packages/snapcraft_legacy/file_utils.py", line 135, in link
    os.link(source_path, destination, follow_symlinks=False)
OSError: [Errno 18] Invalid cross-device link: '/sys/kernel/mm/page_idle/bitmap' -> '/root/parts/dotdrop/src/sys/kernel/mm/page_idle/bitmap'

here's my github action

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - uses: snapcore/action-build@v1
      id: build
      with:
        path: packages
    - uses: snapcore/action-publish@v1
      env:
        SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_LOGIN }}
      with:
        snap: ${{ steps.build.outputs.snap }}
        release: stable
jhenstridge commented 1 year ago

Sorry for not getting back to you. You're probably better off going to the Snapcraft forum for general Snapcraft problems like this.

The root cause seems to be that your snapcraft.yaml file is referencing files outside of the project (which is the ./packages subdirectory with the way you're invoking the action):

https://github.com/deadc0de6/dotdrop/blob/master/packages/snap/snapcraft.yaml#L35

Your project files get copied to a directory within a container before running the build. For the location the project appears at within the container, ../.. escapes to the root of the container filesystem. It then gets confused trying to access some files under /sys.

You'd be best off restructuring your project so you can run snapcraft from the base of the repository. This would mean moving packages/snap/snapcraft.yaml to one of the following locations, and using source: .:

deadc0de6 commented 1 year ago

@jhenstridge thanks for your answer, it makes sense, I've refactored the layout and it worked :+1: