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

feat: use user local data dir for lsp daemon files #1238

Merged
merged 15 commits into from
Dec 22, 2023

Conversation

bestmike007
Copy link
Contributor

Summary

biome lsp server does not work on linux with multiple users. Below is a demonstration using a Dockerfile.

FROM node:slim
RUN npm i -g @biomejs/biome && \
    useradd -m alice && \
    useradd -m bob && \
    su - alice -c 'whoami && biome start && biome __print_socket' && \
    su - bob -c 'whoami && biome start && biome __print_socket'
docker build --force-rm -t test .
<deducted output>
2.885 alice
2.962 The Biome server was successfully started
3.021 /tmp/biome-socket-1.4.1
3.033 bob
3.061 internalError/io ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
3.061
3.061   × Errors occurred while executing I/O operations.
3.061
3.061     Caused by:
3.061       Permission denied (os error 13)
3.061
3.061
------
Dockerfile:2

This is because biome lsp server is using the shared temp_dir (/tmp) to create linux socket file along with the logs.

This PR is to change it to using user local data directory, and fallback to env::temp_dir() if it's not available.

Test Plan

  • GitHub Actions
  • cargo build && docker run --rm -v $PWD/target/debug/biome:/usr/local/bin/biome node:slim sh -c "useradd -m alice && useradd -m bob && su - alice -c 'whoami && biome start && biome __print_socket' && su - bob -c 'whoami && biome start && biome __print_socket'"

Copy link

netlify bot commented Dec 17, 2023

Deploy Preview for biomejs ready!

Name Link
🔨 Latest commit f8d6dfe
🔍 Latest deploy log https://app.netlify.com/sites/biomejs/deploys/6582ea875778f90008f86255
😎 Deploy Preview https://deploy-preview-1238--biomejs.netlify.app/guides/integrate-in-editor
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (no change from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 93 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions github-actions bot added A-CLI Area: CLI A-Core Area: core labels Dec 17, 2023
Signed-off-by: bestmike007 <i@bestmike007.com>
@bestmike007 bestmike007 force-pushed the feat/user-local-data-dir branch from dd665a1 to ce673be Compare December 17, 2023 17:02
crates/biome_fs/src/dir.rs Outdated Show resolved Hide resolved
crates/biome_fs/src/dir.rs Outdated Show resolved Hide resolved
multiuser.dockerfile Outdated Show resolved Hide resolved
Signed-off-by: bestmike007 <i@bestmike007.com>
@Conaclos
Copy link
Member

Conaclos commented Dec 17, 2023

Because the socket is a temporary data, I think that $XDG_CACHE_HOME (generally $HOME/.cache/) is more appropriate to store it?

Signed-off-by: bestmike007 <i@bestmike007.com>
@bestmike007
Copy link
Contributor Author

Because the socket is a temporary data, I think that $XDG_CACHE_HOME (generally $HOME/.cache/) is more appropriate to store it?

Changed. Is it also appropriate to store daemon logs?

@Conaclos
Copy link
Member

Because the socket is a temporary data, I think that $XDG_CACHE_HOME (generally $HOME/.cache/) is more appropriate to store it?

Changed. Is it also appropriate to store daemon logs?

I think so (We could change it in the future if we think it is not).

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

Looks good!

@bestmike007
Copy link
Contributor Author

The test is failing, what should I do to fix it? @ematipico

image

@ematipico
Copy link
Member

ematipico commented Dec 18, 2023

@bestmike007 It seems that your lock file updates a bunch of the internal dependencies. One of them is bpaf, which now adds a new line to the version.

Can you make sure to revert the lock file and add only the new crate without updating the rest of the dependencies?

@bestmike007
Copy link
Contributor Author

The lock file was rebuilt when I tried to resolve the conflicts. Let me see what I can do to revert it.

@bestmike007
Copy link
Contributor Author

@ematipico Reverted. Can you help me re-trigger the GA?

@bestmike007
Copy link
Contributor Author

All good now.

@bestmike007
Copy link
Contributor Author

Any chance to include this in the next release?

@ematipico
Copy link
Member

Any chance to include this in the next release?

We would love to, but this change requires some changes in the documentation. Would like to update it?

We document where people can check their logs, now that this PR changes it, we need to document this change. This is very important:

@bestmike007
Copy link
Contributor Author

Sure, let me work on that.

Signed-off-by: bestmike007 <i@bestmike007.com>
@github-actions github-actions bot added the A-Website Area: website label Dec 19, 2023
@bestmike007
Copy link
Contributor Author

Documents updated, and I also added a __print_cache_dir command to help with getting the precise path. @ematipico

@ematipico ematipico merged commit c841b94 into biomejs:main Dec 22, 2023
17 checks passed
@bestmike007 bestmike007 deleted the feat/user-local-data-dir branch December 23, 2023 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CLI Area: CLI A-Core Area: core A-Website Area: website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants