balena-os / resin-device-toolbox

[DEPRECATED] The official Resin Device Toolbox CLI for resinOS
Apache License 2.0
14 stars 3 forks source link

rdt flash error: Cannot assign to read only property 'name' #31

Open pcarranzav opened 7 years ago

pcarranzav commented 7 years ago

Trying to flash the OS:

pablo@pablo-laptop:~$ rdt flash ~/Downloads/resin.img
Cannot assign to read only property 'name' of function createError(opts) {
        var result = new Error();

        Object.defineProperty(result, 'type', {...<omitted>... }

If you need help, or just want to say hi, don't hesitate in reaching out at:

    GitHub: https://github.com/resin-os/resin-device-toolbox/issues/new
    Gitter: https://gitter.im/resin-io/chat

I'm on Ubuntu 15.10. Had previously used rdt configure to configure the image.

lekkas commented 7 years ago

@jviotti any ideas on this?

jviotti commented 7 years ago

@pcarranzav Can you reliably reproduce? If so, any change we can get a stack trace somehow? @lekkas Does this CLI accepts a DEBUG environment variable as the Resin CLI?

lekkas commented 7 years ago

@jviotti yeap:

https://github.com/resin-os/resin-device-toolbox/blob/master/lib/utils/errors.coffee#L29

compliments of resin-cli

pcarranzav commented 7 years ago

@jviotti yeah, it happens every time. Indeed setting DEBUG works:

pablo@pablo-laptop:~$ DEBUG=* rdt flash ~/Downloads/resin.img
TypeError: Cannot assign to read only property 'name' of function createError(opts) {
        var result = new Error();

        Object.defineProperty(result, 'type', {...<omitted>... }
    at extend (/usr/lib/node_modules/resin-device-toolbox/node_modules/etcher-image-write/node_modules/error/node_modules/xtend/mutable.js:11:17)
    at TypedError (/usr/lib/node_modules/resin-device-toolbox/node_modules/etcher-image-write/node_modules/error/typed.js:25:5)
    at Object.<anonymous> (/usr/lib/node_modules/resin-device-toolbox/node_modules/etcher-image-write/lib/errors.js:26:27)
    at Module._compile (module.js:435:26)
    at loader (/usr/lib/node_modules/resin-device-toolbox/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/usr/lib/node_modules/resin-device-toolbox/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/usr/lib/node_modules/resin-device-toolbox/node_modules/etcher-image-write/lib/validate.js:24:16)
    at Module._compile (module.js:435:26)
    at loader (/usr/lib/node_modules/resin-device-toolbox/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/usr/lib/node_modules/resin-device-toolbox/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/usr/lib/node_modules/resin-device-toolbox/node_modules/etcher-image-write/lib/index.js:26:16)
    at Module._compile (module.js:435:26)
    at loader (/usr/lib/node_modules/resin-device-toolbox/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/usr/lib/node_modules/resin-device-toolbox/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Command.module.exports.action (/usr/lib/node_modules/resin-device-toolbox/build/actions/flash.js:61:18)
    at /usr/lib/node_modules/resin-device-toolbox/node_modules/capitano/build/command.js:96:21
    at Command.module.exports.Command.applyPermissions (/usr/lib/node_modules/resin-device-toolbox/node_modules/capitano/build/command.js:41:14)
    at /usr/lib/node_modules/resin-device-toolbox/node_modules/capitano/build/command.js:90:24
    at Command.module.exports.Command._checkElevation (/usr/lib/node_modules/resin-device-toolbox/node_modules/capitano/build/command.js:61:14)
    at /usr/lib/node_modules/resin-device-toolbox/node_modules/capitano/build/command.js:74:22
    at /usr/lib/node_modules/resin-device-toolbox/node_modules/capitano/build/signature.js:174:14
    at /usr/lib/node_modules/resin-device-toolbox/node_modules/capitano/node_modules/async/lib/async.js:52:16
    at /usr/lib/node_modules/resin-device-toolbox/node_modules/capitano/node_modules/async/lib/async.js:269:32
    at /usr/lib/node_modules/resin-device-toolbox/node_modules/capitano/node_modules/async/lib/async.js:44:16
    at /usr/lib/node_modules/resin-device-toolbox/node_modules/capitano/build/signature.js:168:16
    at /usr/lib/node_modules/resin-device-toolbox/node_modules/capitano/node_modules/async/lib/async.js:181:20
    at Immediate.iterate [as _onImmediate] (/usr/lib/node_modules/resin-device-toolbox/node_modules/capitano/node_modules/async/lib/async.js:262:13)
    at processImmediate [as _immediateCallback] (timers.js:383:17)

If you need help, or just want to say hi, don't hesitate in reaching out at:

    GitHub: https://github.com/resin-os/resin-device-toolbox/issues/new
    Gitter: https://gitter.im/resin-io/chat
jviotti commented 7 years ago

@pcarranzav What NodeJS version are you running this in?

pcarranzav commented 7 years ago
pablo@pablo-laptop:~$ node --version
v4.2.2

good point, I should probably upgrade

jviotti commented 7 years ago

@pcarranzav Let me know if v6 works for you. If so, please open an issue in https://github.com/resin-io-modules/etcher-image-write and I'll investigate after I return from vacations.

alexiri commented 7 years ago

@jviotti I opened the https://github.com/resin-io-modules/etcher-image-write/issues/72 against etcher-image-write because that's what I had understood you wanted. :)

Anyway, it doesn't look like the root user's nodejs is different:

~ > sudo node --version
[sudo] password for alex: 
v6.9.1
jviotti commented 7 years ago

@jviotti I opened the resin-io-modules/etcher-image-write#72 against etcher-image-write because that's what I had understood you wanted. :)

lol, sorry about that. It looks like it has to do with the fact that rdt is loading etcher-image-write using Babel at runtime (see https://github.com/resin-os/resin-device-toolbox/blob/master/lib/actions/flash.coffee#L54), although I'm still unable to reproduce here for some reason (same OS and exact same NodeJS version).

Can you find where the resin-device-toolbox module was installed in your system (probably /usr/local/lib/node_modules), and manually remove the Babel line from build/actions/flash.sh?

Remove this bit:

require('babel-register')({
    only: /etcher-image-write|bmapflash/,
    presets: ['es2015']
});

I believe it should work afterwards. If so, lets put some time to properly transpire ES6 to ES5 in this module.

alexiri commented 7 years ago

Remove this bit:

That seems to fix it, although I don't have a drive to flash right now so I couldn't complete the whole process.

MelvinLoos commented 7 years ago

I also had the same issue, old node version, after updating node I also had to rerun the install command for resin-device-toolbox. I think this updated resin to a newer version or maybe installed some missing dependencies... In any case it is working now and maybe this helps others!