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(exec): default to @latest version #1926

Merged
merged 8 commits into from
Apr 22, 2024
Merged

fix(exec): default to @latest version #1926

merged 8 commits into from
Apr 22, 2024

Conversation

zph
Copy link
Contributor

@zph zph commented Apr 20, 2024

Addresses a bug with mise exec where using an unversioned tool reference causes the underlying binary to not be installed on first use.

Instead we treat an unqualified tool as having tool@latest and handle that in the else clause.

Discord discussion/question:

What's the expected behavior for mise backends when the desired tool@version does not exist in a config file and is not installed and mise x tool@version -- ... is run? I assumed it to be like npx behavior of install if missing then run, but it isn't for most backends other than npm.

For example, if I lack cargo:eza in any of my config files nor installed and run mise x cargo:eza -- which -a eza , I see that it does not install cargo:eza + run the --command with eza install folder in the path. In that case the command fails.

But if I run mise x npm:prettier@3.1.0 -- which -a prettier in similar circumstances I see that prettier is available and executed.

The behavior I expect is the npm case and the cargo case is surprising and undesirable for me, because I'm thinking of mise x as being like npx where it will setup dependency if missing then run it.  I see that if I first mise install cargo:eza followed by mise x cargo:eza it works as expected.

Is the npm behavior your expected/desired behavior?

(this is in the context of debugging my PR for a pipx backend and realizing that mise x and mise install followed by mise x have different behavior in my e2e tests)

jdx: I think mise x with any tool on any backend should autoinstall it

Closes #1247

Addresses a bug with `mise exec` where using an unversioned tool
reference causes the underlying binary to not be installed on first use.

Instead we treat an unqualified tool as having tool@latest and handle
that in the else clause.
@jdx
Copy link
Owner

jdx commented Apr 20, 2024

it seems I had been working on this myself a while ago but for some reason I couldn't get it to work correctly https://github.com/jdx/mise/pull/1247/files

zph added 2 commits April 20, 2024 17:18
Addresses a bug with `mise exec` where using an unversioned tool
reference causes the underlying binary to not be installed on first use.

Instead we treat an unqualified tool which has no current install as having tool@latest
and handle that in the else clause.

The desired behavior is:
eg mise x cargo:eza
- If any version of cargo:eza exists, use it
- If no version exists, install latest
@zph
Copy link
Contributor Author

zph commented Apr 21, 2024

it seems I had been working on this myself a while ago but for some reason I couldn't get it to work correctly https://github.com/jdx/mise/pull/1247/files

I see why it's tough to change. I spent more time on it yesterday but didn't come to a good solution.

I'm going to focus on the pipx backend PR and the gh releases backend and then this is my next interest to fix.

@zph zph mentioned this pull request Apr 21, 2024
10 tasks
@jdx
Copy link
Owner

jdx commented Apr 22, 2024

Yeah apologies for leading you down this path without warning you that it's a lot tougher than it appears but I completely forgot about these issues. I'll try to find some time this week myself to poke around with it and see if I can either come up with a solution or at least a sketch of one.

@jdx
Copy link
Owner

jdx commented Apr 22, 2024

glanced at this a bit and noticed I can't get the unit tests to pass locally either but wasn't able to figure out why. Only had a few minutes to spare so wasn't able to dive in further but hopefully one of us can track down what is going on in the unit tests. I suspect in some of the setup mise x is being called in a way that is causing this to not work properly.

@jdx jdx changed the title [bug] Fix mise x cargo:eza not installing during run when tool's version is unqualified fix(exec): default to @latest version Apr 22, 2024
@jdx
Copy link
Owner

jdx commented Apr 22, 2024

I don't love this solution since it makes things quite complex to reason about but I think it's the behavior we want

@jdx jdx merged commit 82e7077 into jdx:main Apr 22, 2024
6 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.

None yet

2 participants