Skip to content

Error on Arch Linux: Path to shell executable "/usr/lib/usr/bin/swift" does not exist. #605

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

Closed
bitnom opened this issue Sep 5, 2023 · 7 comments · Fixed by #606
Closed
Labels
bug Something isn't working

Comments

@bitnom
Copy link

bitnom commented Sep 5, 2023

Error: Path to shell executable "/usr/lib/usr/bin/swift" does not exist. which also prevents my vscode terminal from working.

I saw #218

My binaries are at /usr/lib/swift/bin which I added to $PATH and started code via :

env PATH=/usr/lib/swift/bin:$PATH code ./

but I continue to get the error The terminal process failed to launch: Path to shell executable "/usr/lib/usr/bin/swift" does not exist. as well as SourceKit error Launching server using command /usr/lib/usr/bin/sourcekit-lsp failed. Error: spawn /usr/lib/usr/bin/sourcekit-lsp ENOENT

If I manually set Swift: Path extension setting to /usr/lib/swift/bin I get the same error.

When swift was installed, it linked /usr/lib/swift/bin/swift to /bin/swift. I deleted the link while trying to resolve this issue.

λ ls -hal /usr/lib/swift/bin
Permissions Size User Date Modified Name
drwxr-xr-x     - root 28 Jul 08:37   .
drwxr-xr-x     - root 28 Jul 08:37   ..
drwxr-xr-x     - root 28 Jul 08:37   sdk-module-lists
lrwxrwxrwx     8 root 28 Jul 08:36   clang -> clang-13
lrwxrwxrwx     5 root 28 Jul 08:36   clang++ -> clang
.rwxr-xr-x  121M root 28 Jul 08:36   clang-13
lrwxrwxrwx     5 root 28 Jul 08:36   clang-cache -> clang
lrwxrwxrwx     5 root 28 Jul 08:36   clang-cl -> clang
lrwxrwxrwx     5 root 28 Jul 08:36   clang-cpp -> clang
.rwxr-xr-x   49M root 28 Jul 08:36   clangd
.rwxr-xr-x   50M root 28 Jul 08:36   docc
lrwxrwxrwx     3 root 28 Jul 08:36   ld.lld -> lld
lrwxrwxrwx     3 root 28 Jul 08:36   ld64.lld -> lld
.rwxr-xr-x   74M root 28 Jul 08:36   lld
lrwxrwxrwx     3 root 28 Jul 08:36   lld-link -> lld
.rwxr-xr-x  255k root 28 Jul 08:36   lldb
.rwxr-xr-x   88k root 28 Jul 08:36   lldb-argdumper
.rwxr-xr-x   99M root 28 Jul 08:36   lldb-server
.rwxr-xr-x   14M root 28 Jul 08:36   llvm-ar
.rwxr-xr-x  5.2M root 28 Jul 08:36   llvm-cov
.rwxr-xr-x  5.8M root 28 Jul 08:36   llvm-profdata
.rwxr-xr-x  8.6M root 28 Jul 08:36   plutil
.rwxr-xr-x  8.1k root 28 Jul 08:36   repl_swift
.rwxr-xr-x  127M root 28 Jul 08:36   sourcekit-lsp
lrwxrwxrwx    14 root 28 Jul 08:36   swift -> swift-frontend
.rwxr-xr-x   12k root 28 Jul 08:36   swift-api-checker.py
lrwxrwxrwx    14 root 28 Jul 08:36   swift-api-digester -> swift-frontend
lrwxrwxrwx    14 root 28 Jul 08:36   swift-api-extract -> swift-frontend
lrwxrwxrwx    14 root 28 Jul 08:36   swift-autolink-extract -> swift-frontend
lrwxrwxrwx    13 root 28 Jul 08:36   swift-build -> swift-package
.rwxr-xr-x   36M root 28 Jul 08:36   swift-build-sdk-interfaces
.rwxr-xr-x  1.4M root 28 Jul 08:36   swift-build-tool
.rwxr-xr-x  1.6M root 28 Jul 08:36   swift-demangle
.rwxr-xr-x   36M root 28 Jul 08:36   swift-driver
lrwxrwxrwx    13 root 28 Jul 08:36   swift-experimental-destination -> swift-package
.rwxr-xr-x  147M root 28 Jul 08:36   swift-frontend
.rwxr-xr-x   11M root 28 Jul 08:36   swift-help
.rwxr-xr-x   93M root 28 Jul 08:36   swift-package
lrwxrwxrwx    13 root 28 Jul 08:36   swift-package-collection -> swift-package
lrwxrwxrwx    13 root 28 Jul 08:36   swift-package-registry -> swift-package
lrwxrwxrwx    13 root 28 Jul 08:36   swift-run -> swift-package
lrwxrwxrwx    14 root 28 Jul 08:36   swift-symbolgraph-extract -> swift-frontend
lrwxrwxrwx    13 root 28 Jul 08:36   swift-test -> swift-package
lrwxrwxrwx    14 root 28 Jul 08:36   swiftc -> swift-frontend
lrwxrwxrwx     3 root 28 Jul 08:36   wasm-ld -> lld

Environment

  • OS: Garuda Linux (Arch)
  • Swift version: 5.8.1
  • Visual Studio Code version: 1.8.1.1
  • vscode-swift version: v1.5.1

Additional context
The package: http://aur.archlinux.org/packages/swift-bin

executing sudo ln -s /usr/lib/swift/bin /usr/lib/usr/bin temporarily fixed the issue, though this is obviously not great.

@bitnom bitnom added the bug Something isn't working label Sep 5, 2023
@adam-fowler
Copy link
Contributor

It looks like your Swift install does not follow the standard pattern for a Linux install. Executables should be in a folder usr/bin relative to the root of your install.

How did you install Swift?

@stevapple
Copy link
Contributor

stevapple commented Sep 6, 2023

I guess Swift is failing because /usr/lib/swift is a hard-coded path for Swift compiler resources (system-wide). A proper installation should be /usr/libexec/swift. The package is absolutely doing something dangerous.

P.S. Linking Swift binary into /bin is also discouraged. /bin is a place for system essentials. Swift should be linked into /usr/bin instead.

@jdberry
Copy link

jdberry commented Sep 9, 2023

I'm having a very similar problem with vscode-swift. My installation is on a raspberry-pi 64 bit bullseye. Swift 5.8 installed from the distribution at https://swift-arm.com.

I get the following errors in VSCode, to which I'm a novice:

[Error - 11:43:21] SourceKit Language Server client: couldn't create connection to server.
Launching server using command /usr/libexec/usr/bin/sourcekit-lsp failed. Error: spawn /usr/libexec/usr/bin/sourcekit-lsp ENOENT
Failed to load watchdog/Package.swift: {"errno":-2,"code":"ENOENT","syscall":"spawn /usr/libexec/usr/bin/swift","path":"/usr/libexec/usr/bin/swift","spawnargs":["package","describe","--type","json"],"cmd":"/usr/libexec/usr/bin/swift package describe --type json"}
$ env | grep PATH
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
$ ls -l /usr/bin | grep swift
lrwxrwxrwx 1 root root          36 Sep  9 11:20 sourcekit-lsp -> /usr/libexec/swift/bin/sourcekit-lsp
lrwxrwxrwx 1 root root          37 Sep  9 11:18 swift -> /usr/libexec/swift/bin/swift-frontend
lrwxrwxrwx 1 root root          37 Sep  9 11:19 swiftc -> /usr/libexec/swift/bin/swift-frontend
$ ls /usr/libexec/swift
bin  include  lib  local  share

Is this an issue with how the swift-arm distribution is layed out? @futurejones

(The symlinks in /usr/bin were initially relative links like the following, but I made them absolute, thinking that might be the issue):

$ ls -l /usr/bin/ | grep swift
lrwxrwxrwx 1 root root          34 Jun  1 22:30 sourcekit-lsp -> ../libexec/swift/bin/sourcekit-lsp
lrwxrwxrwx 1 root root          35 Jun  1 22:30 swift -> ../libexec/swift/bin/swift-frontend
lrwxrwxrwx 1 root root          35 Jun  1 22:30 swiftc -> ../libexec/swift/bin/swift-frontend

@adam-fowler
Copy link
Contributor

The extension assumes that all swift toolchains are structured as the Apple released ones ie all binaries are inside a usr/bin folder. This was a recent change previously it was more flexible but subject to some vagueness about where to find executables. I can review this change.

Perhaps @futurejones can comment on why he chose to not include the usr folder in his installs.

@stevapple
Copy link
Contributor

stevapple commented Sep 9, 2023

🤔After trying to understand the situation correctly… It seems the fix is as simple as not hard-coding (and relying on) the parent directory of bin to be usr? I can’t think about any use cases where we’re relying on it to get things work.

@futurejones
Copy link

The extension assumes that all swift toolchains are structured as the Apple released ones ie all binaries are inside a usr/bin folder. This was a recent change previously it was more flexible but subject to some vagueness about where to find executables.

@adam-fowler can you post links to the commits where this change has occurred.

Moving the installation directory from /usr/ to /usr/libexec/swift/ was done to eliminate conflicts caused by swift shipping with its own version of clang, llvm, libicu and others. Adding an extra /usr was not added as there was no indication that is was needed in testing prior to the package releases.

The installation directory can be changed to /usr/libexec/swift/usr/ if this will fix the issue but I would like to know why this is now needed as there was no issues previously with this installation path.

@adam-fowler
Copy link
Contributor

ok, I'll have to work around it. I made an assumption that all swift installs were structured as Apple structured theirs.

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

Successfully merging a pull request may close this issue.

5 participants