question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Shell detection failure inside docker image on ARM Macbook

See original GitHub issue

We have a docker container, for which we’re running into a shell detection failure:

Traceback (most recent call last):
  File "/opt/conda/bin/verdi", line 8, in <module>
    sys.exit(verdi())
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/opt/conda/lib/python3.7/site-packages/click/core.py", line 777, in main
    _bashcomplete(self, prog_name, complete_var)
  File "/opt/conda/lib/python3.7/site-packages/click_completion/patch.py", line 122, in _shellcomplete
    echo(get_code(prog_name=prog_name, env_name=complete_var))
  File "/opt/conda/lib/python3.7/site-packages/click_completion/core.py", line 299, in get_code
    shell = get_auto_shell()
  File "/opt/conda/lib/python3.7/site-packages/click_completion/lib.py", line 125, in get_auto_shell
    return shellingham.detect_shell()[0]
  File "/opt/conda/lib/python3.7/site-packages/shellingham/__init__.py", line 24, in detect_shell
    raise ShellDetectionFailure()
shellingham._core.ShellDetectionFailure

For some reason, this only happens when running the docker container on M1 Macbooks (on Intel Macbooks, the error in the container does not occur). Observations:

  • Shellingham version in container is 1.4.0
  • Shellingham 1.4.0 in a local conda environment on my machine detects the shell just fine (tested with both python 3.7 and 3.9)
  • Both inside container and on my machine, the detected os.name is posix

For some reason, the shell detection for posix returns None https://github.com/sarugaku/shellingham/blob/325c643e89877eb325adf44bc62547251e87acef/src/shellingham/posix/__init__.py#L82-L90

Steps to reproduce:

  1. Own a Macbook M1 (sorry!)
docker run -d -it --name aiida-core aiidateam/aiida-core:1.6.5
docker exec -it --user aiida aiida-core bash

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
uranusjrcommented, Aug 14, 2022

Alright I finally have a chance to look into this. So for this specific environment combination (an Intel image running in Docker on ARM Mac), the parent process is (interestingly) hooked to a different TTY from the Python process itself. I suspect this is due to some simulation implementation detail that leaked into the container. So this is “easily” amendable by removing the TTY check, but I’m hesitant to just do that since it makes the proc implementation quite a bit slower.

An alternative approach would be to do some refactoring and make process look up lazier, so we only access process IDs that are related to the current process. I’m not particularly motivated to do this myself (especially considering that setting PIPENV_SHELL is a pretty adequate workaround), but anyone would be much welcomed to contribute to this.

0reactions
uranusjrcommented, Aug 14, 2022

Shellingham is never called if you set PIPENV_SHELL, since the variable forces pipenv shell to use that instead of doing any detection. So yeah, you could use that to work around whatever the problem is here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Run x86 (Intel) and ARM based images on Apple Silicon (M1 ...
Being an Apple customer, I am wondering if use a Mac Mini M1, do ALL Docker images run as expected? Does this happen...
Read more >
[v20.10] Platform architecture detection is broken #1170 - GitHub
Docker correctly identifies and uses the image's platform architecture. In my example: It should detect and use armhf on the Raspberry Pi.
Read more >
Docker on Mac M1 gives: "The requested image's platform ...
Docker on Mac M1 gives: "The requested image's platform (linux/amd64) does not match the detected host platform" - Stack Overflow. Stack ...
Read more >
Why new Macs break your Docker build, and how to fix it
In short: on an Intel/AMD PC or Mac, docker pull will pull the linux/amd64 image. On a newer Mac using M1/M2/Silicon chips, docker...
Read more >
Using Apple Silicon (M1) as a cloud engineer, two months in
In some situations, this led to some strange issues when running Docker, where QEMU was acting up with segmentation faults. After some head- ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found