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

refactor: Do not use .metals for checking the metals version #1076

Merged
merged 1 commit into from
Sep 1, 2022

Conversation

tanishiking
Copy link
Member

@tanishiking tanishiking commented Jul 25, 2022

partially tackle #1143

This PR replaces $PROJECT_DIR/.metals/versions-meta.json and $HOME/.metals/versions-meta.json" to workspaceState and globalState respectively.

I remember someone has trouble because Metals creates .metals in their home directory (on Discord, but I couldn't find the link to the discussion).
Anyway, it's best practice to use context.globalState (or workspaceState) for managing the state of the extension.

@tanishiking tanishiking marked this pull request as ready for review July 25, 2022 09:50
@dos65
Copy link
Member

dos65 commented Jul 25, 2022

@tanishiking I initially wanted to store it in inside settings but vscode doesn't allow writing into unknown fields. Every setting must be declared in package.json. There is an option to rename global directory from .metals to smth else

@tanishiking
Copy link
Member Author

tanishiking commented Jul 26, 2022

I initially wanted to store it in inside settings but vscode doesn't allow writing into unknown fields. Every setting must be declared in package.json.

Are you talking about the coursier mirror settings?

const mirrorContents = [
"metals.from=https://repo1.maven.org/maven2",
`metals.to=${mirrorString}`,
].join("\n");

https://scalameta.org/metals/docs/troubleshooting/proxy/ I don't have a plan to replace it with something else at least in this PR.

I don't have a context why metals-vscode has settings to edit the coursier mirror properties, but I'm wondering why users want to configure it via metals-vscode instead of setting global coursier mirrors properties by themselves.

@tgodzik
Copy link
Contributor

tgodzik commented Jul 26, 2022

I don't have a context why metals-vscode has settings to edit the coursier mirror properties, but I'm wondering why users want to configure it via metals-vscode instead of setting global coursier mirrors properties by themselves.

It's just a bit more convenient for the users to have it metals instead of manually searching how to do it.

return needCheckForUpdates(serverVersion, suggestUpgradeSetting.target);
return needCheckForUpdates(
serverVersion,
suggestUpgradeSetting.target,
Copy link
Member

Choose a reason for hiding this comment

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

If I understand correctly, depending on where user set checkForUpdates switch then version will be stored in that scope (global vs workspace), I'm right?
Here, because it's a simple boolean there are no such cases like with server version itself (where empty string in workspace is treated as a valid value and global setting is discarded)

Copy link
Member Author

@tanishiking tanishiking Sep 1, 2022

Choose a reason for hiding this comment

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

If I understand correctly, depending on where user set checkForUpdates switch then version will be stored in that scope (global vs workspace), I'm right?

Yes, you're right!

Here, because it's a simple boolean there are no such cases like with server version itself

What do you mean?
This is the same behavior with the previous one.

Do you mean, we should check for updating both Global and Workspace settings, even if suggetUpgradeSetting is true only in Global or Workspace?
In that case, I agree, but I think we can work on that in another issue / PR #1071

Copy link
Member

@kpodsiad kpodsiad Sep 1, 2022

Choose a reason for hiding this comment

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

@tanishiking I honestly don't remember what I was thinking and what I meant 😅 (even after reading my comment)

Copy link
Member Author

Choose a reason for hiding this comment

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

haha, no worries! sorry for my delayed reply

@tanishiking
Copy link
Member Author

It's just a bit more convenient for the users to have it metals instead of manually searching how to do it.

Ok, it would be awesome if we could completely remove the usage of ~/.metals directory for metals-vscode, but we can work on that in another issue / PR 👍
(I personally think, vscode settings shouldn't change the global behavior (coursier mirror setting in this case). I think people won't expect a change in the vscode setting create/modify the global coursier setting though...)

@tanishiking
Copy link
Member Author

Also added unit test (while refactoring the project structure) for needCheckForUpdate tanishiking#82
I'll open a PR against this repository after this PR has merged.

@tgodzik
Copy link
Contributor

tgodzik commented Sep 1, 2022

(I personally think, vscode settings shouldn't change the global behavior (coursier mirror setting in this case). I think people won't expect a change in the vscode setting create/modify the global coursier setting though...)

I understand what you mean, but it was really complicated for people to find the right place for where to put the file and it is far from obvious. Maybe it would be better to have mirror as a parameter in that case, but I think last time I checked that was not possible. And this was hard to get working right 😅

Copy link
Member

@dos65 dos65 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!

@tanishiking
Copy link
Member Author

it was really complicated for people to find the right place for where to put the file and it is far from obvious. Maybe it would be better to have mirror as a parameter in that case, but I think last time I checked that was not possible. And this was hard to get working right 😅

I see, thank you for sharing the background!
Maybe we can keep those settings without placing proxy files in ~/.metals directory, I'll take a look!

@tanishiking tanishiking merged commit 53b051a into scalameta:main Sep 1, 2022
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.

None yet

4 participants