Repository navigation
fix(exec): name installed-but-inactive tools on resolution failure #11803
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
Merged
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| Describe 'exec_inactive_tool' { | ||
| # Regression test for discussion #4407: `mise install <tool>` writes to no | ||
| # config file, so the tool's bin dir never joins the PATH `mise exec` builds | ||
| # and the bin fails to resolve. The Windows arm surfaced only the opaque | ||
| # `cannot find binary path`, with no hint that mise had just installed it. | ||
|
|
||
| BeforeAll { | ||
| $script:miseExe = (Get-Command mise).Source | ||
|
|
||
| # A scratch cwd so no repo-local mise.toml can activate the tool and | ||
| # make the "not activated" path unreachable. | ||
| $script:workdir = Join-Path -Path $env:TEMP -ChildPath "mise-4407-$PID" | ||
| New-Item -ItemType Directory -Force -Path $script:workdir | Out-Null | ||
| Push-Location $script:workdir | ||
|
|
||
| mise install usage | Out-Null | ||
|
|
||
| # Drop any host `usage` from PATH. The subject here is what mise says | ||
| # when the bin is genuinely unreachable; a preinstalled copy would | ||
| # resolve instead and mask the failure entirely. | ||
| $script:savedPath = $env:PATH | ||
| $env:PATH = ($env:PATH -split ';' | Where-Object { | ||
| $_ -and -not (Test-Path -Path (Join-Path -Path $_ -ChildPath 'usage.exe') -ErrorAction SilentlyContinue) | ||
| }) -join ';' | ||
| } | ||
|
|
||
| AfterAll { | ||
| $env:PATH = $script:savedPath | ||
| Pop-Location | ||
| Remove-Item -Recurse -Force $script:workdir -ErrorAction Ignore | ||
| } | ||
|
|
||
| It 'names the installed-but-inactive tool' { | ||
| $out = (& $script:miseExe exec -- usage 2>&1 | Out-String) | ||
| $LASTEXITCODE | Should -Not -Be 0 | ||
| $out | Should -Match "installed but not activated" | ||
| $out | Should -Match "mise use usage" | ||
| $out | Should -Match "mise exec usage -- usage" | ||
| } | ||
|
|
||
| It 'keeps the original error for a bin no installed tool provides' { | ||
| $out = (& $script:miseExe exec -- not-a-tool-4407 2>&1 | Out-String) | ||
| $LASTEXITCODE | Should -Not -Be 0 | ||
| $out | Should -Match "cannot find binary path" | ||
| $out | Should -Not -Match "installed but not activated" | ||
| } | ||
|
|
||
| It 'suggests a command that works' { | ||
| $out = (& $script:miseExe exec usage -- usage --version 2>&1 | Out-String) | ||
| $out | Should -Match "usage-cli" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # Regression test for discussion #4407: `mise install <tool>` writes to no config | ||
| # file, so the tool's bin dir never joins the PATH `mise exec` builds and the bin | ||
| # fails to resolve. That failure used to surface as a bare ENOENT ("couldn't exec | ||
| # process") with no hint that mise had just installed the tool. | ||
|
|
||
| mise install dummy@1.0.0 | ||
|
|
||
| # Installed, but activated nowhere, so this still fails -- it should now say why. | ||
| assert_fail_contains "mise exec -- dummy" "installed but not activated" | ||
| assert_fail_contains "mise exec -- dummy" "mise use dummy" | ||
| assert_fail_contains "mise exec -- dummy" "mise exec dummy -- dummy" | ||
|
|
||
| # The command the hint suggests has to actually work. | ||
| assert_contains "mise exec dummy -- dummy" "1.0.0" | ||
|
|
||
| # A bin belonging to no installed tool keeps the original error untouched: the | ||
| # hint is only added when mise can name the tool providing it. | ||
| unknown_out="$(mise exec -- not-a-tool-4407 2>&1 || true)" | ||
| assert_contains_text "$unknown_out" "couldn't exec process" | ||
| assert_not_contains_text "$unknown_out" "installed but not activated" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.