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

fix: stop luarocks server list from being overwritten #542

Merged
merged 1 commit into from
Sep 20, 2024

Conversation

simifalaye
Copy link
Contributor

The constants DEFAULT_ROCKS_SERVERS and DEFAULT_DEV_SERVERS are tables and the get_servers/get_dev_servers can return these values meaning that the exact table instance will be returned, not a copy. This means that if the returned table instance is modified, the constants will also be modified. The get_all_servers function uses vim.list_extend which will modify the table of the first argument and so the DEFAULT_ROCKS_SERVERS list will continue to grow each time this function is called appending the dev servers each time.

May want to consider returning a copy of the constant tables OR just note to never modify the returned table values

For some reason, this was actually causing an issue when trying to install some rocks because it would actually prioritize the luarocks manifest over the rocks-binaries server (even though it's supposed to prioritize in the reverse order of the table). Maybe the server list passed to the luarocks cli is too long and it defaults to using luarocks? Not sure, but I didn't spend any time to investigate why appending additional dev server strings to the server list would cause the rocks-binaries server to get skipped. Either way, this change fixed it for me and now the rocks-binaries server is being prioritized when doing tree-sitter-... package installs.

Copy link
Contributor

Review Checklist

Does this PR follow the Contribution Guidelines? Following is a partial checklist:

Proper conventional commit scoping:

  • For example, fix(installer): some installer bugfix

  • Pull request title has the appropriate conventional commit prefix.

If applicable:

  • Tested
    • Tests have been added.
    • Tested manually (steps in PR description).
  • Updated documentation.

@mrcjkb
Copy link
Member

mrcjkb commented Sep 19, 2024

Thanks 🙏 🚀

May want to consider returning a copy of the constant tables OR just note to never modify the returned table values

I like this idea.
Let's make config.get_servers and config.get_dev_servers return a vim.deepcopy of the respective constants (with a comment explaining why).

@mrcjkb mrcjkb merged commit 39ac8f0 into nvim-neorocks:master Sep 20, 2024
7 checks passed
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.

2 participants