JetBrains / JetBrains/junie

Windows: generated junie.bat fails with "The system cannot find the batch label specified - after_channel_oneshot"

Open
#72 0 comments 8 reactions 0 assignees View on GitHub
Dominant language
Shell
Stars
437
Forks
32
Avg merge
4h 43m
Merged PRs (30d)
7

Description

# Windows: generated `junie.bat` fails with `The system cannot find the batch label specified - after_channel_oneshot`

## Description

After installing Junie CLI on Windows using the official `install.ps1` script, running `junie --help` fails with the following error:

```text
The system cannot find the batch label specified - after_channel_oneshot
```

The issue was reproducible even after removing Junie and reinstalling it.

It looks like the generated Windows batch shim file `junie.bat` may be written with line endings that are not handled correctly by `cmd.exe`.

Rewriting the generated `junie.bat` file with Windows CRLF line endings fixed the issue.

## Environment

* OS: Windows 11
* Shell: PowerShell
* Junie command resolved to: `C:\Users\andre\.local\bin\junie.bat`

## Installation command

```powershell
powershell -NoProfile -ExecutionPolicy Bypass -Command "iex (irm 'https://junie.jetbrains.com/install.ps1')"
```

## Steps to reproduce

1. Install Junie CLI on Windows using the official installer:

```powershell
powershell -NoProfile -ExecutionPolicy Bypass -Command "iex (irm 'https://junie.jetbrains.com/install.ps1')"
```

2. Run:

```powershell
junie --help
```

## Actual result

The command fails with:

```text
The system cannot find the batch label specified - after_channel_oneshot
```

## Expected result

`junie --help` should work immediately after installation.

## Diagnostics

`where.exe junie` output:

```text
C:\Users\andre\.local\bin\junie.bat
```

`Get-Command junie -All` output:

```text
CommandType Name Version Source
----------- ---- ------- ------
Application junie.bat 0.0.0.0 C:\Users\andre\.local\bin\junie.bat
```

So there does not appear to be another `junie` executable earlier in `PATH`. The command resolves only to the generated batch file:

```text
C:\Users\andre\.local\bin\junie.bat
```

## Workaround

The issue was fixed by rewriting the generated `junie.bat` file with Windows CRLF line endings:

```powershell
$p = "$env:USERPROFILE\.local\bin\junie.bat"

Copy-Item $p "$p.bak" -Force

$text = [System.IO.File]::ReadAllText($p)
$text = $text -replace "`r?`n", "`r`n"

$utf8NoBom = [System.Text.UTF8Encoding]::new($false)
[System.IO.File]::WriteAllText($p, $text, $utf8NoBom)

junie --help
```

After this, `junie --help` started working correctly.

## Additional notes

This seems to indicate that the generated Windows batch shim may need to be written explicitly with CRLF line endings.

The batch file appears to jump to the `:after_channel_oneshot` label, but before normalizing line endings, `cmd.exe` fails with:

```text
The system cannot find the batch label specified - after_channel_oneshot
```

After converting line endings to CRLF, the same generated batch file works correctly.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.