jdx/mise

Project bin directories

Closed this issue · 1 comments

syhol commented

Preface

I have no idea if this is a good idea. I just want to throw it out there and see if it resonates with people. Also although I think this is technically possible, I'm not 100% sure.

Motivation

When in one of my larger project directories I have 36 directories in my path:

  • 10 from my ~/.config/mise/config.toml
  • 13 from my projects mise.toml
  • 13 more from homebrew, ~/.local/bin, and macOS system paths.

I doubt there's a performance issue with this, but from an organisation perspective it feels a little messy.

Proposal

This proposes a feature that creates a folder per project directory with symlinks to mise tools. I'll call this symlink folder mbin (short for mise binaries) for the sake of this proposal. We wouldn't expect users to call these symlinks directly, or if they do, they shouldn't expect the mise environment to be configured, these aren't shims. These mbin paths can be added/removed from path like tool bin paths are today. For me, my paths would then look like this:

  • 1 from my ~/.config/mise/config.toml
  • 1 from my projects mise.toml
  • 13 more from homebrew, ~/.local/bin, and macOS system paths.

36 down to 15, much more manageable.

Variant 1 - Inside a new mise data directory, e.g. ~/.local/share/mise/mbin/*

~/.config/mise/config.toml
~/projects/proj-1/mise.toml
~/projects/proj-1/nested-proj/mise.toml
~/projects/proj-2/mise.toml
~/.local/share/mise/mbin/home/USER/.config/ <-- contains symlinks to tools
~/.local/share/mise/mbin/home/USER/projects/proj-1/ <-- contains symlinks to tools
~/.local/share/mise/mbin/home/USER/projects/proj-1/nested-proj/ <-- contains symlinks to tools
~/.local/share/mise/mbin/home/USER/projects/proj-2/ <-- contains symlinks to tools

Variant 2 - Inside the directory (.venv/node_module) style e.g. ./.mbin

~/.config/mise/config.toml
~/.config/mise/.mbin <-- contains symlinks to tools
~/projects/proj-1/mise.toml
~/projects/proj-1/.mbin <-- contains symlinks to tools
~/projects/proj-1/nested-proj/mise.toml
~/projects/proj-1/nested-proj/.mbin <-- contains symlinks to tools
~/projects/proj-2/mise.toml
~/projects/proj-2/.mbin <-- contains symlinks to tools

Arguably it doesn't make sense to keep executables in ~/.config so for the user config I would perhaps make that a special case and keep it somewhere else.

jdx commented

I have thought about something similar, but I think the benefits aren't worth the complexity. It can't work for args and env var configured tools though, mise x node@18 and MISE_NODE_VERSION=18—that would still require the current logic. So this would be additional mapping of config files to project symlink dirs. We'd effectively need to rebuild this directory anytime mise runs to make sure it's up to date, which isn't probably expensive in terms of resources but it is in terms of code complexity.

these aren't shims

no, but they suffer the biggest downside that which is useless for them. Shims are also an existing solution to this problem we already have.

~/.local/share/mise/mbin/home/USER/projects/proj-1/nested-proj/ <-- contains symlinks to tools

this is probably not realistic, it'd need to be a hash of the path like we use for the tracked configs dir.