From 63528ce8f32b9546ccf2a9655f0e929ae4ff955c Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Tue, 14 Nov 2017 13:00:01 -0400 Subject: [PATCH] fix(SDK): disable usbboot adapter on GNU/Linux (#1841) Various GNU/Linux distributions require root access to be able to open USB devices. This means that Etcher would need to be ran as root, which is now not possible on Wayland based systems. We declare usbboot as unsupported on GNU/Linux from the time being, but we are currently working on a solution. Change-Type: patch Signed-off-by: Juan Cruz Viotti --- lib/shared/sdk/index.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/shared/sdk/index.js b/lib/shared/sdk/index.js index 5e1151c2..50caae19 100644 --- a/lib/shared/sdk/index.js +++ b/lib/shared/sdk/index.js @@ -20,6 +20,7 @@ const EventEmitter = require('events') const _ = require('lodash') const SDK = module.exports const debug = require('debug')('sdk') +const os = require('os') debug.enabled = true @@ -29,10 +30,16 @@ debug.enabled = true * @constant */ const ADAPTERS = [ - require('./standard'), - require('./usbboot') + require('./standard') ] +// We don't support usbboot on GNU/Linux yet, given +// that some distributions require root permissions +// to open USB devices. +if (os.platform() !== 'linux') { + ADAPTERS.push(require('./usbboot')) +} + /** * @summary Initialised adapters * @type {Object} @@ -90,7 +97,8 @@ SDK.Scanner = class Scanner extends EventEmitter { _.get(this.options, [ 'adapters', adapterId ]) if (_.isNil(adapter)) { - throw new Error(`Unknown adapter "${adapterId}"`) + console.warn(`Unknown adapter "${adapterId}"`) + return } this.subscribe(adapter)