[Bug]: Language Server Installed and Running but does not work in a sandbox environment - Worked until 2 versions ago.
Before Reporting
- [X] I have checked FAQ, and there is no solution to my issue
- [X] I have searched the existing issues, and there is no existing issue for my issue
What happened?
Node path & installation paths are correct - verified.
From Console- Language server is not installed. Please install it in the host app. Try getting suggestions again: Language server error: Server error: -32602 D
How to reproduce the bug.
It just happened!
Relevant log output
No response
macOS version
13.6.1
Xcode version
15.2
Copilot for Xcode version
0.33.4
What do you mean by sandbox environment? If you mean the App Sandbox capability, the service app doesn't work with it enabled because it has to run other processes, for example Node, to perform its jobs. App Sandbox will prevent this.
@intitni i've node and other necessary services. Rolling back to a couple of versions ago works, the newer versions don't. Does the logs signal you anything?
Thanks for looking into.
@varyP But what do you mean by sandbox environment?
This error throws only when the app can't find or access the language server js file. Please make sure it has the right permission to access the files in the folder inside Application Support, If you are using my releases, it should be "~/Library/Application Support/com.intii.CopilotForXcode/GitHub Copilot/executable/copilot/dist/language-server.js"
@intitni - got a sandboxed environment running at a work Macbook.
I don't see the language-server.js here. But the suggestions work outside sandbox on this version, but not inside.
Any other logs I can check?
Update to .0.35, still works outside but doesn't inside.
I keep seeing errors that it is unable to access files opened in XCode inside the sandboxed environment.
Language server error: Server error: -32602 Document for URI could not be found: file:/
The older versions of the language server uses agent.js.
But what is a sandboxed environment? How to enable the sandboxed environment?
If it works before 0.33.0, the app was launched by launch agent as a mach service, and macOS may accidentally grant extra permissions to the app. But this method causes severe performance issues to the app so we will not go back.
But it's still weird, because you can access language server from the host app.
What happens if you quit and open the CopilotForXcodeExtensionService.app manually? If Copilot for Xcode.app has the permissions, the cause may be the way we launch the service app.
@intitni
- Sandbox is an internal tool that we use at work.
- Importing the host app inside results in this error
- The host app works fine because it's outside the sandbox.
- Manual trigger has no affect.
- Might be due to the way it was launched in the past, but if we can get to the root cause - might be helpful.
I can't test it for you since it's an internal tool. But I can offer something that you can experiment with:
In the past the service app is launched by launch agent, now it's launched by the CoomunicationBridge target, which is launched by the launch agent.
Could it be that the old method is launching the service app outside of the sandbox?
If the service app is now launched inside the sandbox, two things may have changed:
- It may be looking for a different directory when it looks for the language server. You can verify it by creating an app that prints the path to the application supports folder
FileManager.default.urls(
for: .applicationSupportDirectory,
in: .userDomainMask
)
- You need to verify if it can still run other processes. You can verify that by sending
/run some_commandin the chat.
Or you can simply try installing the language server again in the sandboxed host app. It's fine that it can't register the launch agent.
This has been happening for Me If project has build errors. So seems like if your project has some file references but File doesn't exists. Extension throws the error. So resolve all the file references and it starts working fine.
I my self would fix it. and will raise a PR.