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

multipass shell should be a login shell #115

Closed
simos opened this issue Feb 9, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@simos
Copy link

commented Feb 9, 2018

You can get a shell in multipass with

$ multipass exec myvm bash
ubuntu@myvm:~$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
ubuntu@myvm:~$ snap list
Name         Version  Rev   Developer  Notes
core         16-2.30  3887  canonical  core
hello-world  6.3      27    canonical  -
ubuntu@myvm:~$ hello-world
hello-world: command not found
ubuntu@myvm:~$ /snap/bin/hello-world
Hello World!
ubuntu@myvm:~$ 

The issue is that multipass exec myvm bash does not give you a login shell. A login shell is required so that /etc/profile.d/apps-bin-path.sh runs, which would set correctly the $PATH and add /snap/bin to it.

Workaround

The workaround is to run instead the following (add -- and then --login).

$ multipass exec myvm -- bash --login
ubuntu@myvm:~$ echo $PATH
/home/ubuntu/bin:/home/ubuntu/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
ubuntu@myvm:~$ 

What should happen?

Ideally, there should be a dedicated command to get a login shell to the VM.
I suggest

$ multipass shell go
ubuntu@myvm:~$ echo $PATH
/home/ubuntu/bin:/home/ubuntu/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
ubuntu@myvm:~$ 

Having a shell subcommand would make it similar to LXD. In LXD it gives you a root login shell because LXD supports many different distributions that may not have a default non-root account.
If multipass is meant to ever be only for Ubuntu images, then multipass shell myvm should be OK to give a non-root login shell.

References

@Saviq

This comment has been minimized.

Copy link
Collaborator

commented Feb 9, 2018

We do have a connect command already:

$ multipass help connect
Usage: multipass connect [options] <name>
Open a prompt on the instance.

But we will indeed rename it to multipass shell to align with lxd.

Saviq added a commit that referenced this issue Feb 16, 2018

cli: rename `connect` to `shell` to align with lxd (Fixes: #115)
The `lxc` command line has a (non-advertised yet) `shell` command, let's
rename our `connect` to align. It's a better name as well.

I've left `connect` as an alias to not break people's muscle memory.

@Saviq Saviq closed this in 5fe6d2f Feb 16, 2018

@Saviq Saviq added this to the 2018.2.1 milestone Feb 21, 2018

albaguirre pushed a commit to albaguirre/multipass that referenced this issue Jun 22, 2018

Merge tag '2018.2.1' into full
Release 2018.2.1

- support JSON output in the CLI (CanonicalLtd#65)
- switch to using a file socket for daemon-client IPC
- refactor ssh code and add unit tests for it
- switch to a patched libssh fork
  - improve mount performance (CanonicalLtd#99)
- fix bash completion for mounts (CanonicalLtd#40)
- wait for cloud-init on start (CanonicalLtd#41)
- sanitize mount targets (CanonicalLtd#17, CanonicalLtd#47)
- support proxy configuratiion (CanonicalLtd#53)
- default to a 5GB rootfs (CanonicalLtd#29)
- randomize bridge subnet (CanonicalLtd#49)
- fix a handful of mount bugs (CanonicalLtd#71, CanonicalLtd#64, CanonicalLtd#78, CanonicalLtd#77, CanonicalLtd#83, CanonicalLtd#82, CanonicalLtd#81, CanonicalLtd#104,
  CanonicalLtd#105)
- add `--all` option to `info` (CanonicalLtd#73)
- clean up networking on shutdown (CanonicalLtd#75)
- set a 10s timeout for download progress (CanonicalLtd#108)
- support rebooting instances (CanonicalLtd#50)
- rename `connect` to `shell` to align with lxd (CanonicalLtd#115)

Saviq added a commit that referenced this issue Feb 11, 2019

Merge #115
115: Limit which images are available for launching on Windows r=Saviq,gerboland a=townsend2010,Saviq

Co-authored-by: Christopher Townsend <christopher.townsend@canonical.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.