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

Can't follow symlinks: ENOENT: no such file or directory, lstat 'filename' #130

Closed
ranisalt opened this issue Dec 30, 2020 · 10 comments · Fixed by #135
Closed

Can't follow symlinks: ENOENT: no such file or directory, lstat 'filename' #130

ranisalt opened this issue Dec 30, 2020 · 10 comments · Fixed by #135
Labels

Comments

@ranisalt
Copy link

Behaviour

Steps to reproduce this issue

  1. Generate files inside build_dir
  2. Create a symbolic link to a file within that same dir (analogous to running ln -s ./filename.tar.gz ./filename inside build_dir)
  3. Get the error from the title

Expected behaviour

Tell me what should happen

It should publish the symlinks (though I think GH pages does not support it) or copy the destination file/dir over the symlink before publishing.

Actual behaviour

Tell me what happens instead

I have two of such files, they all fail:

Cannot stat symlink rsa.db.tar.zst for  ./pkgs/rsa.db: Error: ENOENT: no such file or directory, lstat  'rsa.db.tar.zst'
Cannot stat symlink rsa.files.tar.zst for ./pkgs/rsa.files: Error: ENOENT: no such file or directory, lstat 'rsa.files.tar.zst' 

I ran ls -Ahl <build_dir> after generating such files, and it outputs the following:

Run ls -Ahl /__w/rsaur/rsaur/pkgs
total 3.5M
-rw-r--r-- 1 builduser builduser 1.4M Dec 30 08:58 chili-sddm-theme-0.1.5-1-x86_64.pkg.tar.zst
-rw-r--r-- 1 builduser builduser  86K Dec 30 08:58 gamemode-1.6-3-x86_64.pkg.tar.zst
-rw-r--r-- 1 builduser builduser 201K Dec 30 08:58 gamescope-3.7.1-1-x86_64.pkg.tar.zst
-rw-r--r-- 1 builduser builduser 761K Dec 30 09:00 gdm-nox-3.36.3-6-x86_64.pkg.tar.zst
-rw-r--r-- 1 builduser builduser  58K Dec 30 09:00 gnome-shell-extension-arch-update-git-38+3+gbe86f9e-1-any.pkg.tar.zst
-rw-r--r-- 1 builduser builduser  15K Dec 30 09:01 gnome-shell-extension-clock-override-git-5+47+g7a40543-1-any.pkg.tar.zst
-rw-r--r-- 1 builduser builduser 5.6K Dec 30 09:01 gnome-shell-extension-no-annoyance-git-r34.f6e7691-1-any.pkg.tar.zst
-rw-r--r-- 1 builduser builduser  12K Dec 30 08:58 lib32-gamemode-1.6-3-x86_64.pkg.tar.zst
-rw-r--r-- 1 builduser builduser 415K Dec 30 09:02 lib32-mangohud-0.6.1-2-x86_64.pkg.tar.zst
-rw-r--r-- 1 builduser builduser 118K Dec 30 09:00 libgdm-nox-3.36.3-6-x86_64.pkg.tar.zst
-rw-r--r-- 1 builduser builduser 405K Dec 30 09:02 mangohud-0.6.1-2-x86_64.pkg.tar.zst
-rw-r--r-- 1 builduser builduser 7.9K Dec 30 09:03 mangohud-common-0.6.1-2-x86_64.pkg.tar.zst
-rw-r--r-- 1 builduser builduser 6.6K Dec 30 09:03 nvidia-xrun-git-0.3.83.g270b6c0-1-x86_64.pkg.tar.zst
lrwxrwxrwx 1 root      root        14 Dec 30 09:03 rsa.db -> rsa.db.tar.zst
-rw-r--r-- 1 root      root      3.5K Dec 30 09:03 rsa.db.tar.zst
lrwxrwxrwx 1 root      root        17 Dec 30 09:03 rsa.files -> rsa.files.tar.zst
-rw-r--r-- 1 root      root      7.5K Dec 30 09:03 rsa.files.tar.zst

Configuration

Those are the exact commit and build that fail.

action .yml config here

Logs

Download the log file of your build and attach it to this issue.

log.txt

Beware that the log is very long.

@ranisalt
Copy link
Author

ranisalt commented Dec 30, 2020

Meanwhile, if that's not trivial to solve, I can run something like this:

for f in ${{ env.PKGDEST }}/*; do
  if [ -L "$f" ]; then
    rp=$(realpath "$f")
    unlink "$f"
    cp "$rp" "$f"
  fi
done

To get rid of the symbolic links

@crazy-max
Copy link
Owner

@ranisalt I think it's linked to permissions issues on these files and your whole workflow where you tamper the GitHub Runner with your builduser user. Fyi, the standard user in the GitHub Runner is already sudoer. You can try to recover permissions on pkgs folder with sudo chown -R $(id -u):$(id -g) ./pkgs before the GitHub Pages step.

@ranisalt
Copy link
Author

@crazy-max this action runs as root, it should not have any permission issues, but I will try that nevertheless

@ranisalt
Copy link
Author

No luck. Still the same problem, even with all files owned by root (id -u and id -g)

https://github.com/ranisalt/rsaur/runs/1627374177

@crazy-max
Copy link
Owner

- run: chown -R $(id -u):$(id -g) ${{ env.PKGDEST }}

should be:

- run: sudo chown -R $(id -u):$(id -g) ${{ env.PKGDEST }}

@ranisalt
Copy link
Author

ranisalt commented Dec 31, 2020

The action already runs as superuser. It is clear that the owner and group have been updated. id -u and id -g return root.

@jlstevens
Copy link

I've just bumped into this issue after encountering the same problem. Symlinks do indeed work on gh-pages and can be quite useful (e.g to create an index.html that directs to another page).

The PR referenced above is trying to get a bunch of automatically generated symlinks pushed to gh-pages for this exact use case. Such a workflow was used successfully on Travis until we had to migrate to Github Actions.

I'll try fiddling with file ownership as suggeted above to see if I can get it working. Meanwhile any suggestions about how to address this issue would be appreciated!

@ranisalt
Copy link
Author

ranisalt commented Jan 29, 2021

@jlstevens there are no issues with the ownership, it changes nothing. You have to replace links with the actual files instead.

To me it was easy, I just use cp with the flag to copy the file when a symlink is encountered: https://github.com/ranisalt/rsaur/blob/825cf272159798d3d616f6fed8b241ce686bf7f4/.github/workflows/repo.yml#L56 where ${{ env.PKGDEST }} is where the files are, and output is where they will be copied into (the build_dir for this action)

@crazy-max
Copy link
Owner

@jlstevens

Symlinks do indeed work on gh-pages

Yes we can use symlinks on GitHub Pages but in some cases link target is not available or is based on an absolute path which cannot be resolved on the target branch.

@ranisalt

To me it was easy, I just use cp with the flag to copy the file when a symlink is encountered

Thanks for pointing this out. I think we could mitigate this behavior here. I will take a look and keep you in touch.

@stale
Copy link

stale bot commented Feb 28, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants