canonical / multipass

Multipass orchestrates virtual Ubuntu instances
https://multipass.run
GNU General Public License v3.0
7.54k stars 635 forks source link

`multipass sh vmname` is not working in git-bash.exe #3458

Closed akhilsahuji closed 3 months ago

akhilsahuji commented 3 months ago

Describe the bug multipass sh vmname is not working in git-bash.exe

To Reproduce How, and what happened?

  1. run multipass .sh vmname in git-bash

  2. image

Expected behavior image

Additional info

ricab commented 3 months ago

Yeah I can reproduce this. Most of the time not even that header comes through. Running with -v shows that there is some problem reading console input:

ricab@win10-hyper-v-reborn MINGW64 ~
$ multipass shell -v lucky-tilapia
[2024-04-03T19:16:54.492] [warning] [windows console] Could not read console input; error code: 1
[2024-04-03T19:16:54.492] [warning] [windows console] Could not read console input; error code: 1
[2024-04-03T19:16:54.492] [warning] [windows console] Could not read console input; error code: 1
[2024-04-03T19:16:54.492] [warning] [windows console] Could not read console input; error code: 1
[2024-04-03T19:16:54.492] [warning] [windows console] Could not read console input; error code: 1
[2024-04-03T19:16:54.492] [warning] [windows console] Could not read console input; error code: 1
[2024-04-03T19:16:54.492] [warning] [windows console] Could not read console input; error code: 1
[...]

That 1 is the value returned by GetLastError(). Not very informative...

I don't know where the limitation is coming from, but it seems to involve that mintty thing. If I run git bash in a regular windows terminal it works:

C:\>"C:\Program Files\Git\usr\bin\bash.exe"

$ multipass ls
Name                    State             IPv4             Image
lucky-tilapia           Running           172.26.161.74    Ubuntu 22.04 LTS

$ multipass sh lucky-tilapia
Welcome to Ubuntu 22.04.4 LTS (GNU/Linux 5.15.0-101-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

  System information as of Wed Apr  3 19:24:46 WEST 2024

  System load:  0.00390625        Processes:             89
  Usage of /:   34.4% of 4.67GB   Users logged in:       0
  Memory usage: 25%               IPv4 address for eth0: 172.26.161.74
  Swap usage:   0%

Expanded Security Maintenance for Applications is not enabled.

21 updates can be applied immediately.
15 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable

Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status

To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

ubuntu@lucky-tilapia:~$
akhilsahuji commented 3 months ago

@ricab yeah it works on regular windows terminal i am using it only currently. but recently i started of using tmux on windows. tmux only works on gitbash mintty version that's why i faced this error. i also saw event viewer for logs but it didn't helped. although i can ssh into the vm on git-bash.exe one.

also one more question is multipass sh vmname is diffrent than ssh vmname ? because what i download in ssh vmname don't show in multipass sh vmname

ricab commented 3 months ago

It looks like mintty isn't compatible with the Windows API we use for the console. There might be a way for us to detect that and use our Linux implementation, but there is no guarantee that would work either and honestly I don't think this will rank very high on our priority list. But you should be able to use tmux inside a VM in a regular terminal, if that is what you're after(?).

For Windows, there should be better, native, alternatives, as tmux is meant for Unix-like operating systems. Something like Cmder perhaps? I haven't tried it myself and I don't mean to endorse it, it's just an example of something that should do much the same but meant for Windows proper.

also one more question is multipass sh vmname is diffrent than ssh vmname ?

The main difference is that the multipass command takes care of resolution and authentication for you. To use ssh directly, you need two things:

akhilsahuji commented 3 months ago

thanks @ricab pointing me in the right direction.

i was logging in with a ssh vmname and that created a new user by ssh and multipass created its another user named ubuntu.

so, i generated a ssh key with ubuntu named user and started using ubuntu as username with the newly generated ssh key and changed my ssh config accordingly and then boom I was able to login on git-bash.exe

also, multipass is a great product.

thanks for working on it.

also,if i can help with something, do tell me.

ricab commented 3 months ago

OK, great to know that you've sorted it out for you. I don't think we should cater to terminals that are incompatible with the Windows API, on windows, so I am going to close this now. Feel free to reopen if you find something missing.

also,if i can help with something,

Thanks, we welcome contributions! If you ever feel like contributing, you can look for issues with the tag "god first issue". It's probably wise to propose a solution in text before jumping into code, to make sure we're on the same page. Stating your intention to work on it or even assigning yourself is a good way to avoid multiple people working on the same thing.