Skip to content

Conversation

diego-velez
Copy link
Contributor

As part of my workflow, I use a Git bare repository. For this, I have a Lua script for Neovim to automatically detect and set up environment variables so that it can work with other Git integration plugins. In particular, I define vim.env.GIT_WORK_TREE and vim.env.GIT_DIR.

When I run DepsUpdate, the update fails and the remote origin for the git repository that Neovim was set up to follow with the aforementioned environment variables changes to the last plugin I added with mini.deps.

This PR aims to fix this issue by explicitly not using any environment variables when running git from mini.deps.

@diego-velez diego-velez force-pushed the main branch 2 times, most recently from ceab772 to 1878d1b Compare August 27, 2025 21:50
@echasnovski
Copy link
Member

Thanks for the PR!

Although sounds reasonable, I think there might be some environment variables related to git clone and or git fetch that is worth respecting.

So I have couple of questions:

  • Does this change (not using any environment variables) indeed solve your particular issue? I.e. have you verified it locally?
  • Can you take a look if there is a more targeted way to address your use case? For example, maybe setting only those variables to some explicit value? It should be enough to fix your use case, but in a way that works for regular usages.

@diego-velez
Copy link
Contributor Author

* Does this change (not using any environment variables) indeed solve your particular issue? I.e. have you verified it locally?

Yes, it does solve my issue, and I have tested it locally. DepsUpdate works again when applying this PR, and I also tested DepsAdd.

* Can you take a look if there is a more targeted way to address your use case? For example, maybe setting only those variables to some explicit value? It should be enough to fix your use case, but in a way that works for regular usages.

I tested setting those environment variables for Git, and it worked fine both for DepsUpdate and DepsAdd.

Let me know what you think.

@echasnovski
Copy link
Member

I tested setting those environment variables for Git, and it worked fine both for DepsUpdate and DepsAdd.

Let me know what you think.

The local env variable was not actually used. Could you test locally after applying my suggestion?

If the user had environment variables related to Git, it would collide
with mini.deps functionality
@diego-velez
Copy link
Contributor Author

Yes, sorry. I tested both with the environment variables and without to make sure everything worked as it should, but I forgot to change it back to use the variables.

@echasnovski
Copy link
Member

Yes, sorry. I tested both with the environment variables and without to make sure everything worked as it should, but I forgot to change it back to use the variables.

I see, thanks. Now, with knowledge that this solves your use case, I'll take (later) a closer look if this is okay for regular use cases. I'll also adjust tests myself, as they are quite finicky here :)

@echasnovski
Copy link
Member

@diego-velez, so after re-educating myself about GIT_DIR and GIT_WORK_TREE I was able to reproduce this issue pretty easily.

After experiments with opts.env in vim.system() and reading its source code, I think the cleanest way to deal with this is to unset problematic variables directly while explicitly supplying all other relevant variables. This might introduce a bit of an overhead with extra vim.fn.environ(), but it shouldn't be too bad.

This should now be fixed on latest main and I plan to push a similar fix to the Neovim's vim.pack. Thanks again for finding this and helping two projects :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants