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

Make the language server binary executable after download #20

Merged
merged 1 commit into from
Aug 23, 2024

Conversation

424ever
Copy link
Contributor

@424ever 424ever commented Aug 16, 2024

Resolves #19
Draft because I'm unsure this repo is the correct place to fix the issue. Maybe it should be zed::download_file's job to carry over file permissions when extracting a zip file.

Note that zed::make_file_executable is a noop on non-unix platforms, so it shouldn't be an issue to call it here.

@424ever
Copy link
Contributor Author

424ever commented Aug 16, 2024

If this goes through, it might also be a good idea to update the following condition

if fs::metadata(path).map_or(false, |stat| stat.is_file()) {
    return Ok(path.clone());
}

to check for execute permissions, so that the lsp is downloaded again with the correct permissions, something like this:

if fs::metadata(path).map_or(false, |stat| {
    stat.is_file()
        && #[cfg(unix)]
        {
            const USER_HAS_EXEC_ACCESS: u32 = 0o100;
            (stat.permissions().mode() & USER_HAS_EXEC_ACCESS) != 0
        }
}) {
    return Ok(path.clone());
}

But note that this currently doesn't work because attributes on expressions are experimental: rust-lang/rust#15701.

@maxdeviant maxdeviant changed the title Draft: Make the language server binary executable after download Make the language server binary executable after download Aug 23, 2024
@maxdeviant
Copy link
Collaborator

If this goes through, it might also be a good idea to update the following condition

if fs::metadata(path).map_or(false, |stat| stat.is_file()) {
    return Ok(path.clone());
}

to check for execute permissions, so that the lsp is downloaded again with the correct permissions, something like this:

if fs::metadata(path).map_or(false, |stat| {
    stat.is_file()
        && #[cfg(unix)]
        {
            const USER_HAS_EXEC_ACCESS: u32 = 0o100;
            (stat.permissions().mode() & USER_HAS_EXEC_ACCESS) != 0
        }
}) {
    return Ok(path.clone());
}

But note that this currently doesn't work because attributes on expressions are experimental: rust-lang/rust#15701.

It's moot either way, as we can't use platform cfg!s since this executes in Wasm instead of on the host platform.

Copy link
Collaborator

@maxdeviant maxdeviant left a comment

Choose a reason for hiding this comment

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

Thank you!

@maxdeviant maxdeviant merged commit 1a49951 into zed-extensions:main Aug 23, 2024
@maxdeviant maxdeviant mentioned this pull request Aug 23, 2024
maxdeviant added a commit that referenced this pull request Aug 23, 2024
Changes:

- #20
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.

Language server binary is not executable
2 participants