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

"./mach clean" fails in case of symlinks. #24985

Open
kunalmohan opened this issue Dec 2, 2019 · 6 comments
Open

"./mach clean" fails in case of symlinks. #24985

kunalmohan opened this issue Dec 2, 2019 · 6 comments

Comments

@kunalmohan
Copy link
Collaborator

@kunalmohan kunalmohan commented Dec 2, 2019

if the build fails, Running ./mach clean gives the following error:

Removing virtualenv directory: /mnt/sda1/Documents/webpages/rust/servo/python/_virtualenv
Error running mach:

    ['clean']

The error occurred in code that was called by the mach command. This is either
a bug in the called code itself or in the way that mach is calling it.

You should consider filing a bug for this issue.

If filing a bug, please include the full output of mach, including this error
message.

The details of the failure are as follows:

OSError: [Errno 39] Directory not empty: '/mnt/sda1/Documents/webpages/rust/servo/python/_virtualenv/lib/python2.7/site-packages/.libs_cffi_backend'

  File "/mnt/sda1/Documents/webpages/rust/servo/python/servo/build_commands.py", line 762, in clean
    shutil.rmtree(virtualenv_path)
  File "/usr/lib/python2.7/shutil.py", line 270, in rmtree
    rmtree(fullname, ignore_errors, onerror)
  File "/usr/lib/python2.7/shutil.py", line 270, in rmtree
    rmtree(fullname, ignore_errors, onerror)
  File "/usr/lib/python2.7/shutil.py", line 270, in rmtree
    rmtree(fullname, ignore_errors, onerror)
  File "/usr/lib/python2.7/shutil.py", line 270, in rmtree
    rmtree(fullname, ignore_errors, onerror)
  File "/usr/lib/python2.7/shutil.py", line 279, in rmtree
    onerror(os.rmdir, path, sys.exc_info())
  File "/usr/lib/python2.7/shutil.py", line 277, in rmtree
    os.rmdir(path)

Environment: Linux (Ubuntu 19.04)

@SimonSapin
Copy link
Member

@SimonSapin SimonSapin commented Dec 2, 2019

I’m not sure this happens because compilation with Cargo failed. Removing the python/_virtualenv directory should get you "unstuck". If you see this happen again, could you provide steps to reproduce?

@kunalmohan
Copy link
Collaborator Author

@kunalmohan kunalmohan commented Dec 2, 2019

removing the python/_virtualenv and then ./mach clean again recreates the directory and gives the same error.
Here's what happened from the start:

  1. I ran ./mach build -d
  2. There was an error during the build of one of the modules so I stopped the further build with keyboard interrupt.
  3. Now on running ./mach clean gives the above error.
@SimonSapin
Copy link
Member

@SimonSapin SimonSapin commented Dec 2, 2019

This doesn’t reproduce on my machine.

./mach clean calls Python’s shutil.rmtree("python/_virtualenv"):

virtualenv_path = path.join(self.get_top_dir(), 'python', '_virtualenv')
if path.exists(virtualenv_path):
print('Removing virtualenv directory: %s' % virtualenv_path)
shutil.rmtree(virtualenv_path)

Either there’s a bug in Python, or something is (re) creating the file python/_virtualenv/lib/python2.7/site-packages/.libs_cffi_backend before shutil.rmtree calls os.rmdir to remove a directory that is then supposed to be empty, and either after it called os.listdir to find the files and sub-directories to remove or after it called os.remove to remove that file.

Do you have something running in another terminal that could be interfering?

@kunalmohan
Copy link
Collaborator Author

@kunalmohan kunalmohan commented Dec 2, 2019

Nope. Only one terminal is running.

@kunalmohan kunalmohan mentioned this issue Dec 17, 2019
4 of 4 tasks complete
@kunalmohan
Copy link
Collaborator Author

@kunalmohan kunalmohan commented Mar 2, 2020

@SimonSapin I guess I found the reason for this behaviour- Symlinks. My OS is in my SSD and the documents folder (in which this repository exists locally on my system) is a symlink to a folder in my HDD. It looks like shutil.rmtree does not work well with symlinks (https://bugs.python.org/issue1669). This is indeed bug in python.

@highfive
Copy link

@highfive highfive commented Mar 2, 2020

@kunalmohan kunalmohan changed the title "./mach clean" fails if build fails. "./mach clean" fails in case of symlinks. Mar 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.