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

Add support for untrusted workspace #523

Merged
merged 1 commit into from
Jul 12, 2024
Merged

Conversation

dhruvmanila
Copy link
Member

@dhruvmanila dhruvmanila commented Jul 11, 2024

Summary

This PR adds support for untrusted workspaces.

This wasn't possible with ruff-lsp because it always required a Python interpreter to run but we can support it with the native server.

resolves: #510

Preview

Restricted configuration view:

Screenshot 2024-07-11 at 17 38 57

Switching from an untrusted workspace to a trusted one:

Config:

{
  "ruff.nativeServer": "auto",
  "ruff.path": ["/Users/dhruv/work/astral/ruff/target/debug/ruff"]
}

Here, the ruff.path configuration isn't considered. But, as soon as we trust the workspace, the server is restarted using the ruff.path setting as seen in the logs.

Screen.Recording.2024-07-11.at.17.43.24.mov

Test Plan

Explicitly using native server:

{
	"ruff.nativeServer": "on"
}

Logs:

2024-07-11 17:37:18.167 [info] Workspace is not trusted, using bundled executable: /Users/dhruv/work/astral/ruff-vscode/bundled/libs/bin/ruff
2024-07-11 17:37:18.167 [info] Found Ruff 0.5.0 at /Users/dhruv/work/astral/ruff-vscode/bundled/libs/bin/ruff
2024-07-11 17:37:18.167 [info] Server run command: /Users/dhruv/work/astral/ruff-vscode/bundled/libs/bin/ruff server --preview

Explicitly using ruff-lsp:

{
	"ruff.nativeServer": "off"
}
2024-07-11 17:41:31.432 [warning] Cannot use the legacy server (ruff-lsp) in an untrusted workspace; switching to the native server using the bundled executable.
2024-07-11 17:41:31.432 [info] Workspace is not trusted, using bundled executable: /Users/dhruv/work/astral/ruff-vscode/bundled/libs/bin/ruff
2024-07-11 17:41:31.451 [info] Found Ruff 0.5.0 at /Users/dhruv/work/astral/ruff-vscode/bundled/libs/bin/ruff
2024-07-11 17:41:31.452 [info] Server run command: /Users/dhruv/work/astral/ruff-vscode/bundled/libs/bin/ruff server --preview

Notification preview:
Screenshot 2024-07-11 at 17 41 24

Using auto behavior:

{
	"ruff.nativeServer": "auto"
}

Logs:

2024-07-11 17:41:57.784 [info] Resolved 'ruff.nativeServer: auto' to use the native server in an untrusted workspace
2024-07-11 17:41:57.784 [info] Workspace is not trusted, using bundled executable: /Users/dhruv/work/astral/ruff-vscode/bundled/libs/bin/ruff
2024-07-11 17:41:57.794 [info] Found Ruff 0.5.0 at /Users/dhruv/work/astral/ruff-vscode/bundled/libs/bin/ruff
2024-07-11 17:41:57.795 [info] Server run command: /Users/dhruv/work/astral/ruff-vscode/bundled/libs/bin/ruff server --preview

@dhruvmanila dhruvmanila marked this pull request as draft July 11, 2024 11:33
@dhruvmanila dhruvmanila marked this pull request as ready for review July 11, 2024 12:15
Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@dhruvmanila dhruvmanila merged commit 4b03f7c into main Jul 12, 2024
6 checks passed
@dhruvmanila dhruvmanila deleted the dhruv/untrusted-workspace branch July 12, 2024 05:00
dhruvmanila added a commit that referenced this pull request Jul 18, 2024
## Summary

This PR adds a section in the README to provide documentation around
untrusted workspace support.

This is a follow-up from #523.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle the "untrusted" workspace
2 participants