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

"failed to get console mode for stdout" in windows powershell #30

Closed
ghost opened this issue Nov 22, 2022 · 12 comments
Closed

"failed to get console mode for stdout" in windows powershell #30

ghost opened this issue Nov 22, 2022 · 12 comments

Comments

@ghost
Copy link

ghost commented Nov 22, 2022

image

I get this error message on windows powershell.

What i did:

  • Downloaded the Exe file
  • Renamed it to llama.exe
  • Put it in PATH
  • Added your PS snipped (ll command) to my profile
  • called ll in ps
  • Moved to a directory
  • Esc

Expected behavior: Setting Location to my selected location
Actual Behavior: Error above

Any idea where this is from?

@antonmedv
Copy link
Owner

Looks like powershell script should be little bit different. Does anyone know?

@samg7b5
Copy link

samg7b5 commented Nov 22, 2022

The powershell script in your README is fine in the sense that executing my_ll <path> defined below works as expected:

function my_ll() {
  cd "$(echo $args)"
}

So it's a problem with llama returning an error instead of path. Possibly this line is erroring https://github.com/antonmedv/llama/blob/master/main.go#L76 output := termenv.NewOutput(os.Stderr). Seems strange to have not tested it.

@ghost
Copy link
Author

ghost commented Nov 22, 2022

As an addition when i call llama.exe "manually" and then exit with esc, the outputting of the path works. Somehow the script seems to not find the correct handle to put the output to in the powershell-script case:

image

@mike-ward
Copy link

I'm seeing the same thing here.

image

@mike-ward
Copy link

Also, could the PowerShell command be simplified to

llama | cd

It seems to work, even with the error messages.

@antonmedv
Copy link
Owner

Looks like the problem is in upstream dependency: charmbracelet/gum#32

@ghost
Copy link
Author

ghost commented Nov 25, 2022

@mike-ward: For me this just prints the error message at the time I execute ll. After that it works with the cd but just looks not nice as the folders are kind of "over" the error message.

@TheReptar
Copy link
Contributor

@mike-ward I also received undesirable results with the llama | cd approach, unfortunately.

@zch-lusa I was able to put together a simple workaround that seemed to behave as expected during my testing; you can modify your powershell script to the following:

function ll() {
  cd $(llama $args | Out-String -Stream)[-1]
}

This is by no means a perfect solution as this will ignore the error message altogether by splitting the llama output by line and simply grabbing the last line (which for me was always the desired path), but this should at least get you rolling until a better long-term solution is put together.

@RND332
Copy link

RND332 commented Nov 28, 2022

@mike-ward I also received undesirable results with the llama | cd approach, unfortunately.

@zch-lusa I was able to put together a simple workaround that seemed to behave as expected during my testing; you can modify your powershell script to the following:

function ll() {
  cd $(llama $args | Out-String -Stream)[-1]
}

This is by no means a perfect solution as this will ignore the error message altogether by splitting the llama output by line and simply grabbing the last line (which for me was always the desired path), but this should at least get you rolling until a better long-term solution is put together.

It helps, Windows 11 powershell, if it's a dependency-level error, can add it to the README until it's fixed? Better not an ideal solution than non-working ones

@RND332
Copy link

RND332 commented Nov 30, 2022

@zch-lusa can i ask what version of powershell are you use?

It seems that powershell 5.1, crookedly shows errors after using llama, on powershell 7 at myself and in your screenshots, I don't see this. Maybe it makes sense to open an Issue, or just mention it in the README

@LucaSalzani
Copy link

LucaSalzani commented Nov 30, 2022

Name Value


PSVersion 7.3.0
PSEdition Core
GitCommitId 7.3.0
OS Microsoft Windows 10.0.22000
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

Seems to be ps 7

edit: whoops different account :) i am zch-lusa

@antonmedv
Copy link
Owner

Should be fixed.

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

No branches or pull requests

6 participants