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

postinstall is not run for mise exec #2877

Open
hverlin opened this issue Oct 31, 2024 · 9 comments
Open

postinstall is not run for mise exec #2877

hverlin opened this issue Oct 31, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@hverlin
Copy link
Contributor

hverlin commented Oct 31, 2024

Describe the bug

  • postinstall step is not run when using mise exec.
  • It also forces one to do mise install --force <tool> again if mise x <tool> was already run.

To Reproduce

[tools]
node = { version = "23", postinstall = 'corepack enable' }

Here is the current behavior

> mise x node -c 'pnpm -v'
mise [email protected] ✓ installed 
zsh:1: command not found: pnpm

> pnpm
zsh: command not found: pnpm

> mise install
mise all runtimes are installed

Expected behavior
Using mise x node -c 'pnpm -v' I would expect:

  • mise to install node specified in my mise.toml file
  • run the postinstall
  • successfully run pnpm -v

i.e. same behavior as:

mise install
mise x -c 'pnpm -v'
9.12.2

mise version

mise -v
2024.10.13 macos-arm64 (ee83488 2024-10-28)
@hverlin hverlin added the bug Something isn't working label Oct 31, 2024
@jdx
Copy link
Owner

jdx commented Oct 31, 2024

We can fix this, but since node is in your config there isn't any need to also specify it on the command line. If you didn't include it then it would work.

@hverlin
Copy link
Contributor Author

hverlin commented Oct 31, 2024

I have noticed that it's not always working as it should if I don't specify the tool.
Let's say I only update mise.toml file and try to run mise -x.

Here is what happens:

[tools]
node = "23"
> mise x -c 'node -v'
mise WARN  missing: [email protected]
zsh:1: command not found: node

However, if I just type node it works (given that my shell had mise activated)

> node
mise [email protected] ✓ installed 
Welcome to Node.js v23.1.0.
Type ".help" for more information.
> 

@jdx
Copy link
Owner

jdx commented Oct 31, 2024

Oh right, I forgot that is by design. It doesn't auto install if no other versions are installed

@hverlin
Copy link
Contributor Author

hverlin commented Oct 31, 2024

For additional context, this is how I was thinking of using this.
In GitLab CI, I was thinking I could just do:

build:
  stage: build
  image: some-image-with-mise
  script: |
    mise x -c 'pnpm i'

without mise install

@hverlin
Copy link
Contributor Author

hverlin commented Oct 31, 2024

It doesn't auto install if no other versions are installed

Ah, makes sense! Do you think it could be added to the warning message?

@jdx
Copy link
Owner

jdx commented Nov 1, 2024

Do you think it could be added to the warning message?

I think it's too much noise, the fix should be obvious I would think—running mise i

@hverlin
Copy link
Contributor Author

hverlin commented Nov 1, 2024

Maybe then, would it be possible to have a flag for mise exec and mise run to always run the install?

mise run --install ...
mise exec --install ...

(since in the code it anyway checks for it, and there is a force install option in the code)

This would fit nicely with https://mise.jdx.dev/tips-and-tricks.html#shebang

Another thing which surprised me is that postinstall does not require one to trust the file, whereas env variables do?

(Happy to contribute to fix this issue, btw)

@hverlin
Copy link
Contributor Author

hverlin commented Nov 1, 2024

There is this setting also: https://mise.jdx.dev/configuration/settings.html#not_found_auto_install
I think it would need to clarify that it will auto-install only if:

  • plugin is trusted?
  • a tool does not exist already?

@jdx
Copy link
Owner

jdx commented Nov 1, 2024

it only autoinstalls if at least 1 version is already installed

mise run --install ...

I don't think it's worth adding a flag for. I would just run mise i && mise x. shebang trick is a good point but I still don't think it's worth the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants