LedgerHQ / ledger-live-desktop

⛔️ DEPRECATED - Ledger Live (Desktop)
https://www.ledger.com/live
MIT License
953 stars 301 forks source link

[Ubuntu appImage] Device detected but connection failed. Please try again or contact us if the problem persists. (cannot open device with path /dev/hidraw4) #2873

Closed camillebernier closed 4 years ago

camillebernier commented 4 years ago

Ledger Live Version and Operating System

Expected behavior

Synchronizing Ledger Live with my Ledger Nano S.

Actual behavior

Device detected but connection failed. Please try again or contact us if the problem persists. image

==> I think it's a bug because I can synchronize my Ledger with Windows 10 without any problem <==

Steps to reproduce the behavior

I launch Ledger live (the .appImage), I connect my ledger nano s, I enter the pin, then I have the error "Device detected but connection failed. Please try again or contact us if the problem persists."

I tried to clic "Repair" and I tried to remove my personnal config in ~/.config/Ledger\ Live but I'm still unable to synchronize..

I will let the full log below, there is a message : "cannot open device with path /dev/hidraw4" (sometime it's on /dev/hidraw6) so I assume this is a usb problem with Ubuntu, If you guys got an Idea about my problem ?

Here is the complete log I got :


{
   "type":"db",
   "level":"debug",
   "message":"📁  read app:user",
   "pname":"main",
   "timestamp":"2020-04-21T09:21:05.999Z"
},
{   "type":"cmd.ERROR",
   "data":{
      "name":"CantOpenDevice",
      "message":"cannot open device with path /dev/hidraw4",
      "stack":"Error\n    at new CustomError (/tmp/.mount_ledgercJMXHs/resources/app.asar/node_modules/@ledgerhq/errors/dist/index.cjs.js:18:22)\n    at /tmp/.mount_ledgercJMXHs/resources/app.asar/node_modules/@ledgerhq/live-common/lib/hw/deviceAccess.js:107:11"

},
   "level":"warn",
   "message":"✖ CMD connectManager error",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:59.477Z"
},
{   "error":{
      "name":"CantOpenDevice",
      "message":"cannot open device with path /dev/hidraw4",
      "stack":"Error\n    at new CustomError (/tmp/.mount_ledgercJMXHs/resources/app.asar/node_modules/@ledgerhq/errors/dist/index.cjs.js:18:22)\n    at /tmp/.mount_ledgercJMXHs/resources/app.asar/node_modules/@ledgerhq/live-common/lib/hw/deviceAccess.js:107:11"

},
   "level":"warn",
   "message":"Command error:",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:59.476Z"
},
{
   "type":"hid-verbose",
   "message":"new HID transport",
   "level":"debug",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:59.468Z"
},
{
   "type":"promise-retry",
   "message":" failed. 1 retry remain. Error: cannot open device with path /dev/hidraw4",
   "level":"debug",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:58.443Z"
},
{
   "type":"hid-verbose",
   "message":"new HID transport",
   "level":"debug",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:58.442Z"
},
{
   "type":"promise-retry",
   "message":" failed. 2 retry remain. Error: cannot open device with path /dev/hidraw4",
   "level":"debug",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:57.760Z"
},
{
   "type":"hid-verbose",
   "message":"new HID transport",
   "level":"debug",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:57.760Z"
},
{
   "type":"promise-retry",
   "message":" failed. 3 retry remain. Error: cannot open device with path /dev/hidraw4",
   "level":"debug",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:57.308Z"
},
{
   "type":"hid-verbose",
   "message":"new HID transport",
   "level":"debug",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:57.308Z"
},
{
   "type":"promise-retry",
   "message":" failed. 4 retry remain. Error: cannot open device with path /dev/hidraw4",
   "level":"debug",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:57.003Z"
},
{
   "type":"hid-verbose",
   "message":"new HID transport",
   "level":"debug",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:57.001Z"
},
{   "type":"cmd.START",
   "data":{

},
   "level":"info",
   "message":"CMD connectManager.send()",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:56.996Z"
},
{   "type":"cmd.NEXT",
   "data":{      "type":"add",
      "descriptor":"",
      "deviceModel":{
         "id":"nanoS",
         "productName":"Ledger Nano S",
         "productIdMM":16,
         "legacyUsbProductId":1,
         "usbOnly":true,
         "memorySize":327680,
         "blockSize":4096

},
      "device":{
         "name":"Nano_S"

}

},
   "level":"info",
   "message":"● CMD listenDevices",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:55.903Z"
},
{
   "type":"usb-detection",
   "message":"add: productId=4113 locationId=0 deviceAddress=0",
   "level":"debug",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:54.901Z"
},
{
   "type":"db",
   "level":"debug",
   "message":"📁  write app:accounts",
   "pname":"main",
   "timestamp":"2020-04-21T09:20:21.671Z"
},
{
   "type":"db",
   "level":"debug",
   "message":"📁  read app:accounts",
   "pname":"main",
   "timestamp":"2020-04-21T09:20:20.594Z"
},
{
   "type":"db/crypto",
   "message":"decryptData. full data length = 33",
   "level":"debug",
   "pname":"main",
   "timestamp":"2020-04-21T09:20:20.030Z"
},
{
   "type":"db",
   "level":"debug",
   "message":"📁  read app:accounts",
   "pname":"main",
   "timestamp":"2020-04-21T09:20:20.028Z"
},
{
   "type":"db",
   "level":"debug",
   "message":"📁  read app:accounts",
   "pname":"main",
   "timestamp":"2020-04-21T09:20:20.026Z"
},
{
   "type":"libcore/access",
   "message":"flush end",
   "level":"debug",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:14.551Z"
},
{
   "type":"libcore/access",
   "message":"flush",
   "level":"debug",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:14.549Z"
},
{
   "type":"cmd.COMPLETE",
   "level":"info",
   "message":"✔ CMD libcoreGetVersion finished in 26ms",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:13.549Z"
},
{   "type":"cmd.NEXT",
   "data":{
      "stringVersion":"3.3.0",
      "intVersion":197376

},
   "level":"info",
   "message":"● CMD libcoreGetVersion",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:13.547Z"
},
{
   "type":"cmd.START",
   "level":"info",
   "message":"CMD listenDevices.send()",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:13.530Z"
},
{
   "type":"libcore",
   "message":"using array of bytes = false",
   "level":"debug",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:13.526Z"
},
{
   "type":"libcore/access",
   "message":"load core impl",
   "level":"debug",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:13.524Z"
},
{
   "type":"cmd.START",
   "level":"info",
   "message":"CMD libcoreGetVersion.send()",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:13.524Z"
},
{
   "type":"init",
   "message":"hydrate currencies ",
   "level":"debug",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:13.523Z"
},
{
   "type":"internal",
   "message":"Internal process is up!",
   "level":"debug",
   "pname":"internal",
   "timestamp":"2020-04-21T09:20:13.520Z"
},
{
   "type":"db",
   "level":"debug",
   "message":"📁  write app:settings",
   "pname":"main",
   "timestamp":"2020-04-21T09:20:11.858Z"
},
{
   "type":"db",
   "level":"debug",
   "message":"📁  write windowParams:MainWindow.positions",
   "pname":"main",
   "timestamp":"2020-04-21T09:20:11.692Z"
},
{
   "level":"info",
   "message":"spawned internal process 946",
   "pname":"main",
   "timestamp":"2020-04-21T09:20:11.309Z"
},
{
   "level":"info",
   "message":"cleaning processes on demand",
   "pname":"main",
   "timestamp":"2020-04-21T09:20:11.298Z"
},
{
   "type":"db",
   "level":"debug",
   "message":"📁  read app:accounts",
   "pname":"main",
   "timestamp":"2020-04-21T09:20:10.950Z"
},
{
   "type":"db",
   "level":"debug",
   "message":"📁  read app:user",
   "pname":"main",
   "timestamp":"2020-04-21T09:20:10.947Z"
},
{
   "type":"db",
   "level":"debug",
   "message":"📁  read app:countervalues",
   "pname":"main",
   "timestamp":"2020-04-21T09:20:10.859Z"
},
{
   "type":"db",
   "level":"debug",
   "message":"📁  read app:user",
   "pname":"main",
   "timestamp":"2020-04-21T09:20:10.858Z"
},
{
   "type":"db",
   "level":"debug",
   "message":"📁  read app:settings",
   "pname":"main",
   "timestamp":"2020-04-21T09:20:10.822Z"
},
{
   "type":"system-info",
   "level":"info",
   "message":"System locale: fr-FR",
   "pname":"main",
   "timestamp":"2020-04-21T09:20:08.730Z"
},
{
   "type":"system-info",
   "level":"info",
   "message":"OS: Ubuntu Linux 19.10 (codename: eoan)",
   "pname":"main",
   "timestamp":"2020-04-21T09:20:08.730Z"
},
{
   "type":"system-info",
   "level":"info",
   "message":"Ledger Live version: 2.2.4",
   "pname":"main",
   "timestamp":"2020-04-21T09:20:08.730Z"
},
{
   "type":"db",
   "level":"debug",
   "message":"📁  read app:settings",
   "pname":"main",
   "timestamp":"2020-04-21T09:20:08.667Z"
},
{   "type":"db",
   "level":"debug",
   "message":"📁  read windowParams:MainWindow",
   "pname":"main",
   "timestamp":"2020-04-21T09:20:08.655Z"
camillebernier commented 4 years ago

I've managed to solve my problem. There was a problem with permissions :

Before

$ ll /dev/hidraw4 crw------- 1 root root 242, 4 avril 22 14:53 /dev/hidraw4

So, when I launched my Ledger app as a simple user I didn't have enought rights to open and manage this device.

I tried to launch Ledger Live app with sudo/root but there is a security protection :

$ sudo ./ledger-live-desktop-2.2.4-linux-x86_64.AppImage [29334:0422/144804.342370:FATAL:electron_main_delegate.cc(211)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.

The solution

$ sudo chmod 666 /dev/hidraw4

And this "workaround" solves my problem. I don't know where this problem come from Ubuntu, Hidraw, or Ledger Live App...?

lamafab commented 4 years ago

Solution above didn't work for me. But this support site from Ledger offers a fix: https://support.ledger.com/hc/en-us/articles/115005165269-Fix-connection-issues

$ wget -q -O - https://raw.githubusercontent.com/LedgerHQ/udev-rules/master/add_udev_rules.sh | sudo bash
Primate411 commented 3 years ago

Keep in mind if you fix the ledger issue by changing the permissions on /dev/hidraw and you try to update the firmware, the update will not work until you give permissions to the new hidraw device, otherwise the update will be stuck on the "updating" screen.

piby180 commented 3 years ago

Solution above didn't work for me. But this support site from Ledger offers a fix: https://support.ledger.com/hc/en-us/articles/115005165269-Fix-connection-issues

$ wget -q -O - https://raw.githubusercontent.com/LedgerHQ/udev-rules/master/add_udev_rules.sh | sudo bash

This worked for me with Ubuntu 20.04

tacerus commented 2 years ago

Thank you @Camiyo for pointing to the HID device permissions. Whilst your solution is on the right track and certainly is helpful, I recommend against granting global read access, especially if using a shared computer. Instead of granting global read access, I suggest using chown to grant read access to your personal user instead. This however only works temporarily - especially since the Ledger device frequently reconnects when switching between Leder applications.

To have the system grant device read permissions to my user automatically every time my Ledger devices connect, I added an OWNER option to the udev rules:

# Nano S
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2c97", ATTRS{idProduct}=="0001|1000|1001|1002|1003|1004|1005|1006|1007|1008|1009|100a|100b|100c|100d|100e|100f|1010|1011|1012|1013|1014|1015|1016|1017|1018|1019|101a|101b|101c|101d|101e|101f", TAG+="uaccess", TAG+="udev-acl", OWNER="georg"
# Nano X
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2c97", ATTRS{idProduct}=="0004|4000|4001|4002|4003|4004|4005|4006|4007|4008|4009|400a|400b|400c|400d|400e|400f|4010|4011|4012|4013|4014|4015|4016|4017|4018|4019|401a|401b|401c|401d|401e|401f", TAG+="uaccess", TAG+="udev-acl", OWNER="georg"

This results in:

$ dmesg |grep hidraw
...
[818405.886172] hid-generic 0003:2C97:0004.0008: hiddev97,hidraw1: USB HID v1.11 Device [Ledger Nano X] on usb-0000:00:14.0-1/input0
...

$ ls -l /dev/hidraw*
...
crw------- 1 georg root 245, 1 Feb  5 17:21 /dev/hidraw1
...
Karocyt commented 2 years ago

Thanks @piby180 and @tacerus ! And to build on top of everybody, this is the scripted version, passing the current username ($USER) to the updated bash script:

$ wget -q -O - https://raw.githubusercontent.com/Karocyt/udev-rules/Karocyt-patch-1/add_udev_rules_with_user.sh | sudo bash -s $USER
thall commented 2 years ago

For Ledger Nano S Plus i added me as OWNER to

# Ledger Test, Nano S Plus (idProduct=5011)
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2c97", ATTRS{idProduct}=="0005|5000|5001|5002|5003|5004|5005|5006|5007|5008|5009|500a|500b|500c|500d|500e|500f|5010|5011|5012|5013|5014|5015|5016|5017|5018|5019|501a|501b|501c|501d|501e|501f", TAG+="uaccess", TAG+="udev-acl", OWNER="thall"