facebook / idb

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

I've the following error with idb list-targets #675

Open khanhduy62 opened 3 years ago

khanhduy62 commented 3 years ago

Please help me, I've the following error with idb list-targets node: v10.13.0 macOS Big Sur version 11.4 (Macbook Pro 2018) xcode 12.5

➜  ~ idb list-targets
2021-05-30 14:59:17,558 [ERROR] - root - Exception thrown in main
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/idb/common/companion.py", line 71, in parse_json_line
    return json.loads(decoded_line)
  File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/idb/common/companion_spawner.py", line 153, in spawn_notifier
    await self._read_notifier_output(stream=none_throws(process.stdout))
  File "/usr/local/lib/python3.9/site-packages/idb/common/companion_spawner.py", line 166, in _read_notifier_output
    update = parse_json_line(line)
  File "/usr/local/lib/python3.9/site-packages/idb/common/companion.py", line 73, in parse_json_line
    raise IdbJsonException(f"Failed to parse json from: {decoded_line}")
idb.common.companion.IdbJsonException: Failed to parse json from: 

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/idb/cli/main.py", line 287, in gen_main
    await root_command.run(args)
  File "/usr/local/lib/python3.9/site-packages/idb/common/command.py", line 90, in run
    return await self.resolve_command_from_args(args).run(args)
  File "/usr/local/lib/python3.9/site-packages/idb/cli/__init__.py", line 106, in run
    await self._run_impl(args)
  File "/usr/local/lib/python3.9/site-packages/idb/cli/__init__.py", line 149, in _run_impl
    await self.run_with_manager(
  File "/usr/local/lib/python3.9/site-packages/idb/cli/commands/target.py", line 171, in run_with_manager
    targets = await manager.list_targets()
  File "/usr/local/lib/python3.9/site-packages/idb/common/logging.py", line 113, in _async_wrapper
    raise ex
  File "/usr/local/lib/python3.9/site-packages/idb/common/logging.py", line 88, in _async_wrapper
    value = await function(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/idb/grpc/management.py", line 135, in list_targets
    await self._spawn_notifier()
  File "/usr/local/lib/python3.9/site-packages/idb/grpc/management.py", line 57, in _spawn_notifier
    await companion_spawner.spawn_notifier()
  File "/usr/local/lib/python3.9/site-packages/idb/common/companion_spawner.py", line 156, in spawn_notifier
    raise CompanionSpawnerException(
idb.common.companion_spawner.CompanionSpawnerException: Failed to spawn the idb notifier. Stderr: dyld: Library not loaded: /usr/local/opt/grpc/lib/libgrpc.15.dylib

  Referenced from: /usr/local/bin/idb_companion

  Reason: image not found

dyld: Library not loaded: /usr/local/opt/grpc/lib/libgrpc.15.dylib

  Referenced from: /usr/local/bin/idb_companion

  Reason: image not found

dyld: Library not loaded: /usr/local/opt/grpc/lib/libgrpc.15.dylib

  Referenced from: /usr/local/bin/idb_companion

  Reason: image not found

dyld: Library not loaded: /usr/local/opt/grpc/lib/libgrpc.15.dylib

  Referenced from: /usr/local/bin/idb_companion

  Reason: image not found
ZeroCho commented 3 years ago

Same issue for me. I navigated to /usr/local/opt/grpc/lib and found out that I have libgrpc.16.dylib instead of libgrpc.15.dylib. How can I match the version of libgrpc?

khanhduy62 commented 3 years ago

@ZeroCho so weird. to be honest, I don't know how to fix it sorry my mate :'(

ZeroCho commented 3 years ago

@khanhduy62 Do you also have different version of libgrpc in /usr/local/opt/grpc/lib?

khanhduy62 commented 3 years ago

@ZeroCho yes, same with you so sad

sachinhr10 commented 3 years ago

@ZeroCho #671 has the fix for it.

khanhduy62 commented 3 years ago

@sachinhr10 Another issue happens. Could you help me fix it? Thanks in advance :D

➜  ~ idb list-targets
2021-06-01 21:39:11,146 [ERROR] - root - Exception thrown in main
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/idb/common/companion.py", line 71, in parse_json_line
    return json.loads(decoded_line)
  File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/Cellar/python@3.9/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/idb/common/companion_spawner.py", line 153, in spawn_notifier
    await self._read_notifier_output(stream=none_throws(process.stdout))
  File "/usr/local/lib/python3.9/site-packages/idb/common/companion_spawner.py", line 166, in _read_notifier_output
    update = parse_json_line(line)
  File "/usr/local/lib/python3.9/site-packages/idb/common/companion.py", line 73, in parse_json_line
    raise IdbJsonException(f"Failed to parse json from: {decoded_line}")
idb.common.companion.IdbJsonException: Failed to parse json from: 

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/idb/cli/main.py", line 287, in gen_main
    await root_command.run(args)
  File "/usr/local/lib/python3.9/site-packages/idb/common/command.py", line 90, in run
    return await self.resolve_command_from_args(args).run(args)
  File "/usr/local/lib/python3.9/site-packages/idb/cli/__init__.py", line 106, in run
    await self._run_impl(args)
  File "/usr/local/lib/python3.9/site-packages/idb/cli/__init__.py", line 149, in _run_impl
    await self.run_with_manager(
  File "/usr/local/lib/python3.9/site-packages/idb/cli/commands/target.py", line 171, in run_with_manager
    targets = await manager.list_targets()
  File "/usr/local/lib/python3.9/site-packages/idb/common/logging.py", line 113, in _async_wrapper
    raise ex
  File "/usr/local/lib/python3.9/site-packages/idb/common/logging.py", line 88, in _async_wrapper
    value = await function(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/idb/grpc/management.py", line 135, in list_targets
    await self._spawn_notifier()
  File "/usr/local/lib/python3.9/site-packages/idb/grpc/management.py", line 57, in _spawn_notifier
    await companion_spawner.spawn_notifier()
  File "/usr/local/lib/python3.9/site-packages/idb/common/companion_spawner.py", line 156, in spawn_notifier
    raise CompanionSpawnerException(
idb.common.companion_spawner.CompanionSpawnerException: Failed to spawn the idb notifier. Stderr: dyld: Library not loaded: /usr/local/opt/grpc/lib/libgrpc.15.dylib

  Referenced from: /usr/local/bin/idb_companion

  Reason: image not found

dyld: Library not loaded: /usr/local/opt/grpc/lib/libgrpc.15.dylib

  Referenced from: /usr/local/bin/idb_companion

  Reason: image not found

dyld: Library not loaded: /usr/local/opt/grpc/lib/libgrpc.15.dylib

  Referenced from: /usr/local/bin/idb_companion

  Reason: image not found

dyld: Library not loaded: /usr/local/opt/grpc/lib/libgrpc.15.dylib

  Referenced from: /usr/local/bin/idb_companion

  Reason: image not found

➜  ~ 
tmirun commented 3 years ago

same issue here

sachinhr10 commented 3 years ago

@khanhduy62 I was facing the same error, It appears with bigsur and xcode 12.5 and above. I built and archived idb-companion separately. https://github.com/facebook/idb/issues/671#issuecomment-847537443 https://github.com/facebook/idb/issues/671#issuecomment-847699190 helped me to build idb-companion.

tmirun commented 3 years ago

will idb team fix this error?

c-ryan747 commented 3 years ago

I'm working on changing the idb companion to build grpc/... from source rather than dynamically linking the version installed by homebrew. This should solve most of the linking woes

tmirun commented 3 years ago

with last update solved for me the issue 👍

khanhduy62 commented 3 years ago

@sachinhr10 Could you describe more detail about how to archived idb-companion ?

ZeroCho commented 3 years ago

Yes, just re-install it again

brew tap facebook/fb
brew install idb-companion
twboc commented 2 months ago

As suggested in the error message:

Referenced from: /usr/local/bin/idb_companion
Reason: image not found

In my case the error was caused by

not having the idb_companion inside /usr/local/bin/idb_companion.

Installed by brew. I installed the companion with brew and it ended up being inside /opt/homebrew/Cellar/idb-companion/1.1.8/bin/idb_companion. I created a symlink and flipper immediately worked.

sudo ln -s /opt/homebrew/Cellar/idb-companion/1.1.8/bin/idb_companion /usr/local/bin/idb_companion

For your information Flipper client could not find my idb as well for the same reason. Instead of changing the path to idb in settings I created a symlink as well and it worked!

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

For the love of all of you I hope that this helps because I wasted a whole day because of this.

Harkindey commented 1 month ago

@twboc Thank you soo much.

Yall can check (https://github.com/facebook/flipper/issues/3497) Also.