azure-dev icon indicating copy to clipboard operation
azure-dev copied to clipboard

Can not display option and select option when run `azd init` by GoLand

Open rujche opened this issue 1 year ago • 8 comments

Describe the problem Can not display option and select option when run by GoLand

To Reproduce

  1. Use GoLand to open current project.
  2. Run cli/azd/main.go by GoLand.
  3. It outputs Initializing an app to run on Azure (azd init) How do you want to initialize your app? , but no option displayed.

image

Expected behavior Options displayed and can be selected.

Environment Information on your environment:

  • Language name and version: go version go1.23.1 windows/amd64
  • IDE and version: GoLand 2024.2.1.1
  • Device information:

image

  • Go Settings in GoLand:

image image image image

rujche avatar Sep 12 '24 11:09 rujche

@rujche I haven't looked into how the goland terminal is implemented, but the auto-TTY detection behavior isn't working as expected.

With #4318, we'll give you the ability to specify AZD_FORCE_TTY=true to ignore the terminal detection logic. The private build should be available for you to test soon. I'll reply back when that's available.

If you have spare time and would love to help us, you can run the code snippet from the library we're using to investigate why the terminal detection logic isn't working as expected -- and what we may want to contribute upstream (issue or code) to fix this behavior.

package main

import (
	"fmt"
	"github.com/mattn/go-isatty"
	"os"
)

func main() {
	if isatty.IsTerminal(os.Stdout.Fd()) {
		fmt.Println("Is Terminal")
	} else if isatty.IsCygwinTerminal(os.Stdout.Fd()) {
		fmt.Println("Is Cygwin/MSYS2 Terminal")
	} else {
		fmt.Println("Is Not Terminal")
	}
}

weikanglim avatar Sep 16 '24 16:09 weikanglim

@rujche Feel free to install a private build and set AZD_FORCE_TTY=true to get it working in the Goland terminal.

weikanglim avatar Sep 16 '24 18:09 weikanglim

Hi, @weikanglim

Thanks for the reply. I tried the code above here is the result:

Is Not Terminal

Here is the related screenshot: image

rujche avatar Sep 18 '24 01:09 rujche

@rujche Feel free to install a private build and set AZD_FORCE_TTY=true to get it working in the Goland terminal.

Hi, @weikanglim After adding the changed in your PR, it returns the new error:

image

rujche avatar Sep 18 '24 02:09 rujche

After adding the changed in your PR, it returns the new error:

It looks like AZD_FORCE_TTY is taking effect, but you may hitting this issue in the survey library we're using in the terminal environment. Perhaps under the covers GoLand Terminal is using a MingW64 bash-for-windows-like variant. Unfortunately, fixing this would likely be along the times of a feature request along the lines of changing our UI library. I wish I had better news here...

Once thing that could help -- there's a new beta GoLand terminal that you could try here. I'm not sure if they changed things underneath that could fix the experience here.

weikanglim avatar Sep 19 '24 19:09 weikanglim

Issue addressed via #4318

rajeshkamal5050 avatar Oct 02 '24 00:10 rajeshkamal5050

Here is current status:

  1. After set AZD_FORCE_TTY=true, it returns error like this:

Image

  1. Even if I changed Terminal to Powershell and "Enabled New Terminal", this problem still exists:

Image

Image

rujche avatar Oct 17 '24 14:10 rujche

/unresolve

rujche avatar Oct 17 '24 14:10 rujche

Hi, @weikanglim

  1. I solved this problem by changing to VS Code.
  2. Seems this problem is caused by survey library.
  3. But it's not cause by https://github.com/AlecAivazis/survey/issues/148, because it still exists when I use PowerShell instead of Git Bash.
  4. The survey library is no longer maintained, How about changing to the suggested library written in the readme?

Image

rujche avatar Nov 18 '24 09:11 rujche

@rujche just curious, are you using Windows PowerShell? Or pwsh? I do think we have users that are able to run azd there -- we haven't heard this being reported widely.

weikanglim avatar Dec 13 '24 01:12 weikanglim

Hi, @weikanglim Thanks for the response.

1. are you using Windows PowerShell? Or pwsh?

I'm using Windows + Go Land + (PowerShell or GitBash) In my understand, In Go Land, the Terminal and Run are different:

  1. Terminal is related to PowerShell or GitBash, and this can be configured.
  2. Run is not related to PowerShell or GitBash.

Here are related screenshots:

  1. Run window:

    Image

  2. Terminal window:

    Image

  3. And the IDE setting can only change the Terminal windlow

    Image

Correct me if my understanding is wrong.

2. I do think we have users that are able to run azd there -- we haven't heard this being reported widely.

Maybe this problem only happens when run in IDE, not happens when it compiled into an executable file (azd.exe)

This problem not only happened in my machine, it also happened in @haozhan's machine. You can install GoLand to have a try if you are using windows.

rujche avatar Dec 13 '24 06:12 rujche

@rujche Thanks for the extra information. From the screenshots, it seems like you are still running into the issue with Git Bash. I really doubt GoLand is doing anything weird here -- it's entirely due to the shell implementation. I'm not entirely sure what I'd recommend here -- for what it's worth, in my workflow I run a WSL container + VSCode to get bash and other GNU utilities while running on a Windows desktop.

I was really interested in the earlier response you had provided:

But it's not cause by https://github.com/AlecAivazis/survey/issues/148, because it still exists when I use PowerShell instead of Git Bash.

If this is happening, do share a screenshot of this.

But I suspect that we're ultimately coming back to https://github.com/AlecAivazis/survey/issues/148 and migrating to other UI libraries are indeed something we're thinking about -- but it's a big feature ask that will need to be done separately outside of this bug report. We will gladly test out MINGW64 scenarios if we ever do such a work.

weikanglim avatar Dec 13 '24 17:12 weikanglim

Hi, @weikanglim Thanks for the quick response.

1. it seems like you are still running into the issue with Git Bash

Not related to Git Bash. Because this problem still exists when I changed Terminal to PowerShell. Here are related screenshots:

Image

Image

Image

2. I really doubt GoLand is doing anything weird here

I doubt in GoLand, the Run Console and the Terminal are not the same. The Terminal can be configured to use Git Bash or Powershell, but the Console can not be changed.

3. If this is happening, do share a screenshot of this.

But it's not cause by https://github.com/AlecAivazis/survey/issues/148, because it still exists when I use PowerShell instead of Git Bash.

If this is happening, do share a screenshot of this.

Please see the screenshots above.

rujche avatar Dec 16 '24 01:12 rujche