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

[Bug]: Language Server Installed and Running but does not work in a sandbox environment - Worked until 2 versions ago. #553

Open
2 tasks done
varyP opened this issue Jul 4, 2024 · 14 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@varyP
Copy link

varyP commented Jul 4, 2024

Before Reporting

  • I have checked FAQ, and there is no solution to my issue
  • I have searched the existing issues, and there is no existing issue for my issue

What happened?

image
image

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

@varyP varyP added the bug Something isn't working label Jul 4, 2024
@intitni
Copy link
Owner

intitni commented Jul 4, 2024

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.

@varyP
Copy link
Author

varyP commented Jul 11, 2024

@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.

@intitni
Copy link
Owner

intitni commented Jul 11, 2024

@varyP But what do you mean by sandbox environment?

@intitni intitni added help wanted Extra attention is needed and removed bug Something isn't working labels Jul 11, 2024
@intitni
Copy link
Owner

intitni commented Jul 11, 2024

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"

@varyP
Copy link
Author

varyP commented Jul 11, 2024

@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?

image

@varyP
Copy link
Author

varyP commented Jul 11, 2024

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:/

image

@intitni
Copy link
Owner

intitni commented Jul 11, 2024

The older versions of the language server uses agent.js.

But what is a sandboxed environment? How to enable the sandboxed environment?

@intitni
Copy link
Owner

intitni commented Jul 11, 2024

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.

@intitni
Copy link
Owner

intitni commented Jul 11, 2024

But it's still weird, because you can access language server from the host app.

@intitni
Copy link
Owner

intitni commented Jul 12, 2024

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.

@varyP
Copy link
Author

varyP commented Jul 12, 2024

@intitni

  1. Sandbox is an internal tool that we use at work.
  2. Importing the host app inside results in this error
    image
  3. The host app works fine because it's outside the sandbox.
  4. Manual trigger has no affect.
  5. Might be due to the way it was launched in the past, but if we can get to the root cause - might be helpful.

@intitni
Copy link
Owner

intitni commented Jul 12, 2024

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:

  1. 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
        )
  1. You need to verify if it can still run other processes. You can verify that by sending /run some_command in the chat.

@intitni
Copy link
Owner

intitni commented Jul 12, 2024

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.

@sandeeprana011
Copy link

sandeeprana011 commented Aug 29, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants