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

Permission issue when Swift toolchain/docc is installed as root user #1136

Open
2 tasks done
xtremekforever opened this issue Jan 12, 2025 · 1 comment
Open
2 tasks done
Labels
bug Something isn't working

Comments

@xtremekforever
Copy link

Description

When the Swift toolchain is installed to / or /usr/libexec (as is done with Debian and Fedora distributions), the docc binary throws a permissions issue when attempting to preview or generate documentation:

xtremek@Winter ~/t/swift-async-algorithms (main) [1]> ls -la /usr/libexec/swift/6.0.3/bin/docc
-rwxr-xr-x 1 root root 23984936 Dec 15 19:00 /usr/libexec/swift/6.0.3/bin/docc*
xtremek@Winter ~/t/swift-async-algorithms (main)> /usr/libexec/swift/6.0.3/bin/docc preview
Input: ~/tmp/swift-async-algorithms
Template: /usr/libexec/swift/6.0.3/share/docc/render
Error: Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission."

However, if the Swift toolchain and docc are installed to a directory under the user, like in the user's home directory or via Swiftly, then it works perfectly fine:

xtremek@Winter ~/t/swift-async-algorithms (main)> ls -la $(which docc)
lrwxrwxrwx 1 xtremek xtremek 32 Jan  4 15:36 ~/.local/bin/docc -> ~/.local/bin/swiftly*
xtremek@Winter ~/t/swift-async-algorithms (main)> ~/.local/bin/docc preview
Input: ~/tmp/swift-async-algorithms
Template: ~/.local/share/swiftly/toolchains/6.0.3/usr/share/docc/render
========================================
Starting Local Preview Server
         Address: http://localhost:8080/documentation/validation
========================================

Any ideas why this happens? It makes it impossible to have Swift installed to the system and then use docc to preview and generate documentation, for example in a CI environment...

Checklist

  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue.

Expected Behavior

Running docc convert or docc preview when the Swift toolchain is installed to a system directory with root permissions works.

Actual behavior

Running docc convert or docc preview when the Swift toolchain is installed to a system directory with root permissions throws a permissions error:

Error: Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission."

Steps To Reproduce

  1. Install Swift to a system directory such as / or /usr/libexec/swift.
  2. Run docc preview from the system directory.
  3. Observe that it does not work, but throws a permissions issue.

Swift-DocC Version Information

Swift 6.0.3 Release

Swift Compiler Version Information

Swift version 6.0.3 (swift-6.0.3-RELEASE)
Target: aarch64-unknown-linux-gnu
@RandomHashTags
Copy link

Can confirm using Swiftly + manually selecting the toolchain in VS Code and updating the PATH as a workaround (at least for Arch Linux).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants