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.

Failure to uninstall egg-link on windows

See original GitHub issue

Hey there!

For the past few days I’ve been struggling with a bug in pydocstyle, which is described in this long and tedious SOVF question. To sum it up, when I was running in a pypy environment and tried to test setup.py develop and setup.py develop --uninstall, windows raised error 32 saying that the egg-link file can’t be removed for it is being used by another process.

I came across this bug report, and in particular:

> The problem is that there's no reason to believe anything
> he did here _does_ leave files open.

Except that he's hitting the file system quite heavily, and
asyncronously.  My guess is that Windows simply gets behind
(a quick filemon test indicates that this is indeed the
case; just before a crash, I see the events CREATE/SUCCESS,
QUERY/SUCCESS, QUERY/SUCCESS, WRITE/SUCCESS, and
OPEN/SHARING VIOLATION for the failing file, with lots of
requests for other files interleaved).

Unless someone wants to fix Windows, a simple workaround
would be to retry the os.remove a few times before giving up
(with a time.sleep(0.1) in between).

I opened setuptools\command\develop.py and in uninstall_links (line 152) I saw this:

egg_link_file = open(self.egg_link)
contents = [line.rstrip() for line in egg_link_file]
egg_link_file.close()
...
if not self.dry_run:
    os.unlink(self.egg_link)

So I thought to myself, “maybe the file is being held by the same process? perhaps windows doesn’t clear the resources fast enough?”. So I added this bit of code to it:

if not self.dry_run:
    for i in range(5):
        try:
            os.unlink(self.egg_link)
            break
        except Exception:
            import time
            time.sleep(0.1)

And… voila.

(pypy) C:\Users\shach\code\bla\funniest>pypy setup.py develop --uninstall
running develop
Removing c:\users\shach\code\bla\funniest\.tox\pypy\site-packages\funniest.egg-link (link to .)
Removing funniest 0.1 from easy-install.pth file

I’d open a PR, but I seriously doubt that that’s the way to go about it. I’m open to suggestions and will happily send a PR to fix it 😃

Shachar.

EDIT:

Well, obviously I had to emberrass myself an write a bug in my fix 😊

The error still happens after changing “fixing” the “fix” to:

if not self.dry_run:
    for i in range(5):
        try:
            os.unlink(self.egg_link)
            break
        except Exception:
            import time
            time.sleep(0.1)
            if i == 4:
                raise

Any ideas?

Shachar.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
jaracocommented, Sep 29, 2017

@FarmerSez : That’s really surprising that an attempt to remove a file immediately after closing it would fail. That sounds like a bug in PyPy to me. Can you try replicating the failure and if you can with a simple Python script file the issue upstream with PyPy? I’d be happy to fix it here except that the behavior of Setuptools as I understand it is correct.

0reactions
shacharoocommented, Sep 29, 2017

@jaraco sure, I’ll look into it 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot uninstall a game - Microsoft Community
I can't delete a game called taz wanted at all,it's says the specified module could not be found. ... Catastrophic failure.Please help me....
Read more >
pip uninstall: "No files were found to uninstall." - Stack Overflow
I was so confused how pip knew that my package existed despite manually deleting the package's egg link in the site-packages folder. Deleting ......
Read more >
Changelog - pip documentation v22.3.1
Fix uninstall editable from Windows junction link. ... Instead of failing on index pages that use non-compliant HTML 5, print a deprecation warning...
Read more >
Installing scikit-learn — scikit-learn 0.16.1 documentation
Upgrading with pip install -U scikit-learn or uninstalling pip uninstall scikit-learn is likely fail to properly remove files installed by the conda command ......
Read more >
e) after installing before restart due to .egg-link and new ...
FYI when I install my package with pip install . without the -e it works. If I later set the environment path using...
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