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

Getting psutil.AccessDenied error on each and every run #992

Closed
fedor-ivn opened this issue Mar 16, 2021 · 8 comments · Fixed by #995
Closed

Getting psutil.AccessDenied error on each and every run #992

fedor-ivn opened this issue Mar 16, 2021 · 8 comments · Fixed by #995
Labels
bug Something isn't working

Comments

@fedor-ivn
Copy link

Environment information

  • brownie Version: 1.13.4
  • ganache-cli Version: latest (runs in docker container with standard parameters)
  • solc Version: doesn't really matter
  • Python Version: 3.9
  • OS: osx (Catalina)

What was wrong?

I'm getting this error on each and every run of any brownie command. I've googled it, but haven't found any solutions. I suppose it's a trouble of MacOS, but I am not sure.

I am running brownie only with sudo know, but this approach has some limitations and cannot be considered as a solution.

Brownie v1.13.4 - Python development framework for Ethereum

ContractsProject is the active project.
  File "brownie/_cli/__main__.py", line 64, in main
    importlib.import_module(f"brownie._cli.{cmd}").main()
  File "brownie/_cli/run.py", line 43, in main
    network.connect(CONFIG.argv["network"])
  File "brownie/network/main.py", line 48, in connect
    rpc.attach(host)
  File "brownie/network/rpc.py", line 156, in attach
    pid = _find_rpc_process_pid(resolved_addr)
  File "brownie/network/rpc.py", line 264, in _find_rpc_process_pid
    i for i in psutil.net_connections(kind="tcp") if _check_net_connections(i, laddr)
  File "psutil/__init__.py", line 2153, in net_connections
    return _psplatform.net_connections(kind)
  File "psutil/_psosx.py", line 249, in net_connections
    cons = Process(pid).connections(kind)
  File "psutil/_psosx.py", line 351, in wrapper
    raise AccessDenied(self.pid, self._name)
AccessDenied: psutil.AccessDenied (pid=43460)

How can it be fixed?

I would like to know :) I've checked the issues, but haven't found any corresponding.
Maybe someone faced the same problem?

@iamdefinitelyahuman iamdefinitelyahuman added the bug Something isn't working label Mar 16, 2021
@iamdefinitelyahuman
Copy link
Member

Related to #972 - seems there's an issue with using psutil.net_connections on OSX. Not sure immediately what the solution is.

@mariuspod
Copy link
Contributor

hey, just looked into the docs and found this: giampaolo/psutil#1219

It seems on OSX privileged connections can't be queried atm.
The author of psutil says lsof on OSX does the same :-/

Maybe it's possible to try-catch around it and if we're lucky the pid of the docker container runs in unprivileged scope.
The known workaround is to run:

sudo brownie

I'll try to find a test OSX machine 😅

@mariuspod
Copy link
Contributor

@iamdefinitelyahuman
here's a draft PR fixing the issue on OSX: #995
Need to make it a bit more clean and try to add some tests. 😅

Basically, the actual docker process can be queried for connections. The exception occurs only while other privileged processes are queried which have nothing to do with the dockerized ganache.

@iamdefinitelyahuman
Copy link
Member

Awesome, thank you for solving this!

@fedor-ivn
Copy link
Author

Hey there! Thanks for paying attention to my problem, I appreciate that.

I've updated eth-brownie package through pip, but unfortunately, I still have the same problem.

Here's the traceback:

  File "brownie/_cli/__main__.py", line 64, in main
    importlib.import_module(f"brownie._cli.{cmd}").main()
  File "brownie/_cli/run.py", line 43, in main
    network.connect(CONFIG.argv["network"])
  File "brownie/network/main.py", line 48, in connect
    rpc.attach(host)
  File "brownie/network/rpc/__init__.py", line 114, in attach
    pid = _find_rpc_process_pid(resolved_addr)
  File "brownie/network/rpc/__init__.py", line 195, in _find_rpc_process_pid
    i for i in psutil.net_connections(kind="tcp") if _check_net_connections(i, laddr)
  File "psutil/__init__.py", line 2153, in net_connections
    return _psplatform.net_connections(kind)
  File "psutil/_psosx.py", line 249, in net_connections
    cons = Process(pid).connections(kind)
  File "psutil/_psosx.py", line 351, in wrapper
    raise AccessDenied(self.pid, self._name)
AccessDenied: psutil.AccessDenied (pid=93950)

@iamdefinitelyahuman
Copy link
Member

Unless you install directly from master here on github, the fix isn't available just yet. Once #1006 merges, hopefully will be a different story :)

@fedor-ivn
Copy link
Author

Oh, sure, thanks. I'll be waiting :)

@mariuspod
Copy link
Contributor

@fedor-ivn
if you want to test the fix and install master branch of brownie via pip you can try:

pip3 install git+https://github.com/eth-brownie/brownie

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants