Closed Cosmic7373 closed 6 months ago
What happens when you open a terminal window inside VSCode and type swift --version
if that works what is the output of
/bin/sh -c "LC_MESSAGES=C type swift"
Also when you set the swift.path
setting have you tried using the full path without the tilda?
From within the VS Code terminal typing "swift --version" I get Swift version 5.9.2 (swift-5.9.2-RELEASE) Target: x86_64-unknown-linux-gnu
Entering "/bin/sh -c "LC_MESSAGES=C type swift"" I get "swift: not found"
I tried replacing the tilda with what I think is the full path "/home/testing_vm/Downloads/swift-5.9.2-RELEASE-ubuntu22.04/usr/bin/"
And then it seems to be working better now! It's not failing when I load VS Code. /bin/sh -c "LC_MESSAGES=C type swift" still says not found though.
And do features like "Go to Definition/Go to Declaration" for a function not work with the Swift extension in VS Code, or is something still broken? It just says no definition/declaration found even though I can find them with a ctrl+f search.
That is really odd you can run swift but type swift
doesn't find it. Can you test it with another executable in your path?
I'll look to support ~
in paths in a future release. #668
You need to build your application before "Go to Definition/Go to Declaration" starts working
I have the same issue having just installed swift as described here, and installing the swift extension in vscode.
I added the following to my bashrc:
export PATH=/home/[username]/devPackages/swift-5.9.2-RELEASE-ubuntu22.04/usr/bin:"${PATH}"
,
after tar xzf
'ing the tarball to downloads and mv
'ing it there. I've also rebooted for good measure.
swift --version
gives me
Swift version 5.9.2 (swift-5.9.2-RELEASE)
Target: x86_64-unknown-linux-gnu
and /bin/sh -c "LC_MESSAGES=C type swift"
gives
swift is /home/[username]/devPackages/swift-5.9.2-RELEASE-ubuntu22.04/usr/bin/swift
I haven't set swift.path
, is that an environment variable? Something in vs code? Can't find docs on it.
Thanks!
Ok, I've answered my own question. swift.path
is in ~/.vscode/extensions/sswg.swift-lang-1.7.2/package.json. (Sorry, I'm a vscode noob). Setting this var to the same path as mentioned in the above comment fixes the issue entirely. Kind of weird that just searching PATH didn't work (since it says this should be default behavior), but ¯\(ツ)/¯
@kjabon I'm surprised the extension is not working if /bin/sh -c "LC_MESSAGES=C type swift"
is finding swift.
By the way the settings can be edited from VSCode itself. You can go via menu Code -> Settings...
or keyboard shortcut Ctrl+,
(Cmd+,
on macOS). You can find the swift settings by expanding the extensions
section.
I am using Mac and receive the same issue.
❯ /bin/sh -c "LC_MESSAGES=C type swift" swift is /usr/bin/swift
and I have following setup in vscode: "swift.path.shell": "/usr/bin/swift"
but I still receive "Activating Swift extension failed: Failed to find swift executable"
I am using Mac and receive the same issue.
❯ /bin/sh -c "LC_MESSAGES=C type swift"
swift is /usr/bin/swift
and I have following setup in vscode: "swift.path.shell": "/usr/bin/swift"
but I still receive "Activating Swift extension failed: Failed to find swift executable"
Don't set swift.path
. On macOS you only need to set that for snapshot toolchain.
I've been having trouble getting the swift extension to activate in VS Code.
I'm running a newly setup VirtualBox Ubuntu 22.04. I followed the installation steps on the Extensions page in VS Code that begins with https://www.swift.org/install/linux/#installation-via-tarball I have unpacked the tarball and added it to my path so that commands like "swift --version" work anywhere in the standard bash terminal that comes with Ubuntu by modifying my .bashrc file. CodeLLDB is installed as a VS Code Extension as is "Swift". I tried to post on your Slack like the help page suggested, but it says I don't have an account. Tried reloading VS Code and restarting the VM. Been getting this error for a while. I've tried modifying the extension setting where it says: Swift: Path The path of the folder containing the Swift executables. The default is to look in the PATH environment variable. To be the folder where my executable is in to be ~/Downloads/swift-5.9.2-RELEASE-ubuntu22.04/usr/bin And it still fails. Leaving it blank (where I assume it should off of my PATH which works in the terminal) also fails.
This is a brand new environment I setup just to run VS Code with Swift as I've been having this same issue on other platforms.