<commit_before>const { prompt } = require('../app/ui');
const { getDevice, isDeviceId } = require('./device-util');

const { getDevices, openDeviceById, NotFoundError, NotAllowedError } = require('particle-usb');

const chalk = require('chalk');
const when = require('when');
const VError = require('verror');
const fs = require('fs');
const childProcess = require('child_process');

const UDEV_RULES_SYSTEM_PATH = '/etc/udev/rules.d';
const UDEV_RULES_FILE_NAME = '50-particle.rules';

const UDEV_RULES_SYSTEM_FILE = `${UDEV_RULES_SYSTEM_PATH}/${UDEV_RULES_FILE_NAME}`;
const UDEV_RULES_ASSET_FILE = `${__dirname}/../../assets/${UDEV_RULES_FILE_NAME}`;

let _systemSupportsUdev = undefined;
let _udevRulesInstalled = undefined;

function handleDeviceOpenError(err) {
	if (err instanceof NotAllowedError) {
		err = new Error('Missing permissions to access the USB device');
		if (systemSupportsUdev()) {
			return promptAndInstallUdevRules(err);<commit_msg>Recommend reinstalling the CLI if particle-usb cannot be loaded<commit_after>const { prompt } = require('../app/ui');
const { getDevice, isDeviceId } = require('./device-util');
const log = require('../lib/log');

const chalk = require('chalk');
const when = require('when');
const VError = require('verror');
const fs = require('fs');
const childProcess = require('child_process');

let particleUsb = null;
try {
	particleUsb = require('particle-usb');
} catch (e) {
	log.error(`Please reinstall the CLI again using ${chalk.bold('npm install -g particle-cli')}`);
	throw e;
}
const { getDevices, openDeviceById, NotFoundError, NotAllowedError } = particleUsb;

const UDEV_RULES_SYSTEM_PATH = '/etc/udev/rules.d';
const UDEV_RULES_FILE_NAME = '50-particle.rules';

const UDEV_RULES_SYSTEM_FILE = `${UDEV_RULES_SYSTEM_PATH}/${UDEV_RULES_FILE_NAME}`;
const UDEV_RULES_ASSET_FILE = `${__dirname}/../../assets/${UDEV_RULES_FILE_NAME}`;

let _systemSupportsUdev = undefined;
let _udevRulesInstalled = undefined;

function handleDeviceOpenError(err) {
	if (err instanceof NotAllowedError) {
		err = new Error('Missing permissions to access the USB device');
		if (systemSupportsUdev()) {
			return promptAndInstallUdevRules(err);
{'fraction_non_alphanumeric': 0.14220183486238533, 'fraction_numerical': 0.001834862385321101, 'mean_word_length': 6.245847176079734, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1506104', 'n_tokens_mistral': 730, 'n_tokens_neox': 722, 'n_words': 161}