raycast / extensions

Everything you need to extend Raycast.
https://developers.raycast.com
MIT License
5.3k stars 2.98k forks source link

[Visual Studio Code] Multiple commands not working with VSCode installed by nix-darwin #14871

Open Fr4nk1inCs opened 2 hours ago

Fr4nk1inCs commented 2 hours ago

Extension

https://www.raycast.com/thomas/visual-studio-code

Raycast Version

1.82.5

macOS Version

15.0.1

Description

I'm using nix-darwin (nix module for darwin) for my macOS environment management so it's a little different.

Basically, VSCode is installed into /Applications/Nix Apps/Visual Studio Code.app with two levels of symlinking (xxxxx below stands for a unique hash for every package in the nix eco-system):

  • /Applications/Nix Apps -> /nix/store/xxxxx-system-applications/
  • /Applications/Nix Apps/Visual Studio Code.app/ -> /nix/store/xxxxx-vscode-1.93.1/Applications/Visual Studio Code.app

Following commands on my machine failed to function:

I'm glad to provide extra info if needed.

Steps To Reproduce

  1. Environment: As described in description.
    • VSCode installed in /Applications/Nix Apps/Visual Studio Code.app which is a symlink (in a symlinked directory)
  2. Extension Config: No extra modification except command Commands enabled.
  3. Run commands mentioned in description. (Open New Window, Install Extension, Commands)

Current Behaviour

As described in description.

Expected Behaviour

All commands function perfectly.

raycastbot commented 2 hours ago

Thank you for opening this issue!

🔔 @thomaspaulmann @iainsimmons @macbookandrew @cy-98 @immint023 @pernielsentikaer @vimtor @tonka3000 @aka-rabbi-inv @oilbeater @QIanGua @hakob8956 @erics118 @tmwrnr @tleo19 @aeither @yug2005 you might want to have a look.

💡 Author and Contributors commands The author and contributors of `thomas/visual-studio-code` can trigger bot actions by commenting: - `@raycastbot close this issue` Closes the issue. - `@raycastbot close as not planned` Closes the issue as not planned. - `@raycastbot rename this issue to "Awesome new title"` Renames the issue. - `@raycastbot reopen this issue` Reopens the issue. - `@raycastbot assign me` Assigns yourself to the issue. - `@raycastbot good first issue` Adds the "Good first issue" label to the issue. - `@raycastbot keep this issue open` Make sure the issue won't go stale and will be kept open by the bot.
Fr4nk1inCs commented 2 hours ago

Currently the Open New Window command is done by executing some AppleScript: https://github.com/raycast/extensions/blob/7a8c6d2e5f45991a456af97841e5b40c80376703/extensions/visual-studio-code-recent-projects/src/open-new-window.ts#L7-L19

The same script can't find application "com.microsoft.VSCode" on my machine, although osascript did find application "Code":

$ osascript -e 'id of application "Code"'
com.microsoft.VSCode

Another issue with this script is that if there's a language pack (Simplified Chinese for example) installed in VSCode, the menubar item is not displayed in English, making this script failed to click the New Window button.

A possible way to open a new window is to use the command line argument -n or --new-window provided by VSCode (and VSCodium/Cursor):

$ code --new-window

But this would encounter the same problem (to find to executable code) which the Install Extension command has met. Maybe add a configuration item to let user set the executable path if VSCode is not installed by a "standard" procedure?