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

Entering Bash Subshell Results in Functions in prompt.sh and Prompt Hooks Not Being Found #766

Closed
korenyoni opened this issue Jan 30, 2022 · 3 comments · Fixed by #769 or #771
Closed

Comments

@korenyoni
Copy link
Member

korenyoni commented Jan 30, 2022

Found a bug? Maybe our Slack Community can help.

Slack Community

Describe the Bug

Spawning an interactive subshell via bash results in a broken command line prompt and other errors.

[Edit: yes, that is how Geodesic works. To spawn an interactive subshell, use bash -l]

Steps to Reproduce

Steps to reproduce the behavior:

  1. Enter Geodesic
  2. Enter subshell via bash
  3. See error

Expected Behavior

Functions in prompt.sh and prompt hooks should be properly sourced when entering a subshell, however bash complains about functions in prompt.sh and prompt hooks not being found (see below).

Screenshots / Logs

(without a valid kubeconfig set via KUBECONFIG)

. [none] (HOST) geodesic ⨠ 
 ⧉  geodesic 
 ✗ . [none] (HOST) geodesic ⨠ bash
bash: _kube_ps1_update_cache: command not found
bash: prompter: command not found
  geodesic 

(with a valid kubeconfig set via KUBECONFIG)

. [none] (HOST) geodesic ⨠
 ⧉  geodesic (eg-mgmt-uw2-sandbox:default)
 ✗ . [none] (HOST) geodesic ⨠ bash
bash: _kube_ps1_update_cache: command not found
bash: prompter: command not found
   geodesic (eg-mgmt-uw2-sandbox:default)

Environment (please complete the following information):

Anything that will help us triage the bug will help. Here are some ideas:

  • OS: OSX (host)
  • Geodesic Flavor: Alpine
  • Version 0.149.1

Additional Context

@korenyoni korenyoni added the bug 🐛 An issue with the system label Jan 30, 2022
@drmikecrowe
Copy link

drmikecrowe commented Jan 30, 2022

I believe this problem (at least in #763) is due to permissions in /etc/profile.d:

 ✗ . [none] (HOST) infrastructure ⨠ sudo ls -l --color /etc/profile.d/prom*
-rwxrwxrwx 1 root root  7534 Jan 24 22:45 /etc/profile.d/prompt.sh
-rw------- 1 root root 10441 Jan  1  1970 /etc/profile.d/prompt:kube-ps1.sh

Could this affect this issue as well?

Fix:

RUN chmod 755 /etc/profile.d/*

should be added to the Dockerfile's

@korenyoni
Copy link
Member Author

@drmikecrowe changing the permissions of the files in /etc/profile.d/ does not resolve this issue — I can reproduce it after doing so in the container. I think this has to do with what gets sourced when entering a subshell, but I haven't looked into it deeply yet.

@Nuru Nuru added wontfix This will not be worked on feature request and removed bug 🐛 An issue with the system wontfix This will not be worked on labels Jan 31, 2022
@Nuru
Copy link
Contributor

Nuru commented Jan 31, 2022

This is one of many things that could be better documented (#768) about Geodesic. I prefer to view it as a limitation rather than a bug.

Geodesic is a complex, richly featured toolkit, built using standard Linux tools. It is not an app running under Java or Python or .NET, but has features competitive with apps that do. It does most of it with bash features, including heavy use of bash functions.

However, setting up all those bash functions takes a significant amount of time, and they can actually cause problems when running scripts or other commands that run subshells. So Geodesic only sets up all the functions when running:

  • A "login" shell
  • with a Terminal attached

In other words, lack of a custom prompt when you run plain bash is a feature, not a bug.

Granted, Geodesic could behave in a more friendly way in this situation, but it is not obvious to me what the best behavior would be. For example, if we output a warning, that output could end up messing up a script. Maybe we could just change the prompt to Geodesic Features Disabled # ?

@osterman what do you think?

In any case, the preferred usage of Geodesic is that when you want to start an interactive subshell, you do so by running

bash -l

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants