facebook / idb

idb is a flexible command line interface for automating iOS simulators and devices
https://fbidb.io
MIT License
4.51k stars 432 forks source link

Wrong path being used for idb_companion #835

Open kmarple1 opened 1 year ago

kmarple1 commented 1 year ago

Description

I have installed idb_companion per the documentation. which idb_companion returns "/opt/homebrew/bin/idb_companion". However, I keep seeing this error in Flipper (full log entry below): "FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/bin/idb_companion'".

Reproduction

iOS log tailer stderr:  2023-05-24 10:04:32,718 [ERROR] - root - Exception thrown in main
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/idb/cli/[main.py](http://main.py/)", line 313, in gen_main
    await root_command.run(args)
  File "/opt/homebrew/lib/python3.11/site-packages/idb/common/[command.py](http://command.py/)", line 90, in run
    return await self.resolve_command_from_args(args).run(args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/idb/cli/__init__.py", line 106, in run
    await self._run_impl(args)
  File "/opt/homebrew/lib/python3.11/site-packages/idb/cli/__init__.py", line 126, in _run_impl
    async with _get_client(args=args, logger=self.logger) as client:
  File "/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/[contextlib.py](http://contextlib.py/)", line 204, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/idb/cli/__init__.py", line 63, in _get_client
    async with GrpcClientManager(
  File "/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/[contextlib.py](http://contextlib.py/)", line 204, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/idb/grpc/[management.py](http://management.py/)", line 166, in from_udid
    companion = await self._spawn_companion_server(udid=udid)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/idb/grpc/[management.py](http://management.py/)", line 122, in _spawn_companion_server
    target_type = await _local_target_type(companion=companion, udid=udid)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/idb/grpc/[management.py](http://management.py/)", line 37, in _local_target_type
    target.udid: target for target in await companion.list_targets(only=None)
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/idb/common/[logging.py](http://logging.py/)", line 113, in _async_wrapper
    raise ex
  File "/opt/homebrew/lib/python3.11/site-packages/idb/common/[logging.py](http://logging.py/)", line 88, in _async_wrapper
    value = await function(*args, **kwargs)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/idb/common/[companion.py](http://companion.py/)", line 383, in list_targets
    output = await self._run_companion_command(arguments=arguments, timeout=timeout)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/idb/common/[companion.py](http://companion.py/)", line 161, in _run_companion_command
    async with self._start_companion_command(arguments=arguments) as process:
  File "/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/[contextlib.py](http://contextlib.py/)", line 204, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/idb/common/[companion.py](http://companion.py/)", line 137, in _start_companion_command
    process = await asyncio.create_subprocess_exec(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/[subprocess.py](http://subprocess.py/)", line 218, in create_subprocess_exec
    transport, protocol = await loop.subprocess_exec(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 1694, in subprocess_exec
    transport = await self._make_subprocess_transport(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/unix_events.py", line 207, in _make_subprocess_transport
    transp = _UnixSubprocessTransport(self, protocol, args, shell,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_[subprocess.py](http://subprocess.py/)", line 36, in __init__
    self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
  File "/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/unix_events.py", line 810, in _start
    self._proc = subprocess.Popen(
                 ^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/[subprocess.py](http://subprocess.py/)", line 1024, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/opt/homebrew/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/subprocess.py", line 1901, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/bin/idb_companion'

Additional Information

heath-clink commented 12 months ago

See https://github.com/facebook/idb/pull/851

However, that ~may~ will not get merged because I'm not willing to try to get my employer to sign the CLA.

Perhaps someone who does have a CLA might be willing to duplicate the change in the PR into their own PR.

heath-clink commented 12 months ago

this appears to work as a workaround:


sudo ln -s /opt/homebrew/bin/idb_companion /usr/local/bin
Mansouri147 commented 4 months ago

For me I literally changed the path in the file throwing the error, this is the file path ~/Library/Python/3.9/lib/python/site-packages/idb/cli/main.py line number 313 which is await root_command.run(args) just added one line before it args.companion_path="/opt/homebrew/bin/idb_companion"

tnson1307 commented 3 months ago

this appears to work as a workaround:

sudo ln -s /opt/homebrew/bin/idb_companion /usr/local/bin

thanks, it's worked for me

KyeAtkinson commented 3 months ago

this appears to work as a workaround:

sudo ln -s /opt/homebrew/bin/idb_companion /usr/local/bin

Thankyou so much. I've been debugging this issue for about 4 hours now I can now sleep.

zerotower69 commented 1 month ago
sudo ln -s /opt/homebrew/bin/idb_companion /usr/local/bin

Thanks! It works for me.