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

AttributeError: module 'os' has no attribute 'geteuid' #889

Open
matthewolckers opened this issue May 8, 2020 · 7 comments
Open

AttributeError: module 'os' has no attribute 'geteuid' #889

matthewolckers opened this issue May 8, 2020 · 7 comments

Comments

@matthewolckers
Copy link

matthewolckers commented May 8, 2020

Bug description

Expected behaviour

Expect to produce docker image.

Actual behaviour

Traceback (most recent call last):
  File "c:\appdata\local\continuum\anaconda3\lib\site-packages\traitlets\traitlets.py", line 528, in get
    value = obj._trait_values[self.name]
KeyError: 'user_id'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\appdata\local\continuum\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\appdata\local\continuum\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\AppData\Local\Continuum\anaconda3\Scripts\repo2docker.exe\__main__.py", line 9, in <module>
  File "c:\appdata\local\continuum\anaconda3\lib\site-packages\repo2docker\__main__.py", line 345, in main
    r2d = make_r2d()
  File "c:\appdata\local\continuum\anaconda3\lib\site-packages\repo2docker\__main__.py", line 300, in make_r2d
    if r2d.user_id == 0 and not r2d.dry_run:
  File "c:\appdata\local\continuum\anaconda3\lib\site-packages\traitlets\traitlets.py", line 556, in __get__
    return self.get(obj, cls)
  File "c:\appdata\local\continuum\anaconda3\lib\site-packages\traitlets\traitlets.py", line 535, in get
    value = self._validate(obj, dynamic_default())
  File "c:\appdata\local\continuum\anaconda3\lib\site-packages\repo2docker\app.py", line 206, in _user_id_default
    return os.geteuid()
AttributeError: module 'os' has no attribute 'geteuid'

How to reproduce

  1. On a Windows 10 PC, open the Anaconda Command Prompt
  2. Run repo2docker https://github.com/matthewolckers/fbr2020
  • OS: Windows 10
  • Docker version: 19.03.8,
  • repo2docker version 0.11.0
@betatim
Copy link
Member

betatim commented May 11, 2020

geteuid() is only available on unix like systems. This explains why it doesn't work on Windows. I am not sure if we could easily add an alternative that would work on Windows and leave the current behaviour the same on unix-like systems.

Windows support in repo2docker is "low", mostly because it is hard and because none of the devs have access to a windows machine. If you have some time and spare brain cycles to look into this that would be great.

@manics
Copy link
Member

manics commented Sep 18, 2020

geteuid() is used to set the default UID inside the Docker container:

@default("user_id")
def _user_id_default(self):
"""
Default user_id to current running user.
"""
return os.geteuid()

A reasonable workaround for windows could be to detect the OS and return an error message requiring --user-id to be specified.

@ivergara
Copy link

As a workaround, WSL2 can be used without problems.

I might try to fix this issue for Windows in general. Are there more known possible solutions besides the one mentioned by @manics ?

@manics
Copy link
Member

manics commented Dec 10, 2020

AFAIK the only reason to make the UID inside the Docker image match the user's UID is so that if you mount the user's home directory into the container it'll be writeable. Is that possible on Windows and if so, how are UIDs mapped, since that might lead to a good solution?

@ivergara
Copy link

Doing a cursory search I found something that might be relevant in pip

Reproducing here the beginning of the referenced function

def check_path_owner(path):
    # type: (str) -> bool
    # If we don't have a way to check the effective uid of this process, then
    # we'll just assume that we own the directory.
    if sys.platform == "win32" or not hasattr(os, "geteuid"):
        return True

Perhaps a similar approach would be sufficient?

@ivergara
Copy link

I got to move from the original issue by forcing to run with a given GUID in the _user_id_default method.

    @default("user_id")
    def _user_id_default(self):
        """
        Default user_id to current running user.
        """
        if sys.platform == "win32" or not hasattr(os, "geteuid"):
            return 1001
        return os.geteuid()

With this change, the execution then stops working in step 31 when trying to execute install-miniforge.bash.

Step 30/50 : USER root
 ---> Using cache
 ---> 394ba1fe367c
Step 31/50 : RUN TIMEFORMAT='time: %3R' bash -c 'time /tmp/install-miniforge.bash' && rm /tmp/install-miniforge.bash /tmp/environment.yml
 ---> Running in cf91e3dafa9a
bash: /tmp/install-miniforge.bash: Permission denied
time: 0.001

My docker knowledge at this moment doesn't go too deep as to know how to start digging deeper into this error/issue. Anyone here has a hint on how to progress here to diagnose the problem in an effective way?

@rmcrae
Copy link

rmcrae commented Apr 12, 2024

In other words, repo2docker is useless on Windows. great

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

No branches or pull requests

5 participants