mindsphere / node-red-contrib-mindconnect

Node-RED Agent for the MindConnect API (community driven project)
https://opensource.mindsphere.io/docs/node-red-contrib-mindconnect/index.html
MIT License
49 stars 1 forks source link

DietPi 8.1.2, Node-red 2.2.2 #150

Closed na-am closed 2 years ago

na-am commented 2 years ago

if Node-red was installed via DietPi Launcher this error appears when deploying Node-red with a MCL node including an IAT: "Error: EACCES: permission denied, mkdir '//.mc/'" so i had to create it by myself:

sudo mkdir /.mc
sudo chown nodered:nodered /.mc

and it's working as usual

i know, DietPi is using a bit 'strange' directories for the software installed via launcher, but i'm wondering why the MCL node wants to create the directory in "/" because that isn't the home directory of the dietpi user, neither root's home

sn0wcat commented 2 years ago

@na-am This is happening because the default constructor of the mindconnect agent uses process.cwd() as the default location, and DietPi is for some reason launching node-red from there. Maybe we should add a configurable location for .mc files in the node in the future.

https://github.com/mindsphere/mindconnect-nodejs/blob/105ed883166619cbf12cc77f96e501736752b9e9/src/api/agent-auth.ts#L537

/**
     * Creates an instance of AgentAuth.
     * @param {IMindConnectConfiguration} _configuration
     * @param {number} [_tokenValidity=600] // this was required in previous versions of the implmentation , kept for compatibility.
     * @param {string} [_basePath=process.cwd() + "/.mc/"]
     * @memberof AgentAuth
     */
    constructor(
        configuration: IMindConnectConfiguration,
        protected _tokenValidity: number = 600,
        basePath: string | IConfigurationStorage = process.cwd() + "/.mc/"
    ) 
nehemiascr commented 1 year ago

I am also experiencing this issue on the IOT2050 Debian Example Image build V01.03.01, please look at #173, I cannot just create the .mc folder at /, because in this build of the IOT2050 Debian image, the root filesystem is read-only of type squashfs

sn0wcat commented 1 year ago

@nehemiascr the device builders really seem to enjoy putting node-red in strange places on strange filesystems ;)

I've seen that you have already found the solution as mentioned here:

https://github.com/mindsphere/node-red-contrib-mindconnect/issues/173#issuecomment-1368633741

We will add a configuration option for the file system location of the .mc directory, however until the setting is added, what you also could do is also just install node-red as a normal application and just run that instead of the pre-installed version of node red. (maybe stop the other one or run this one on a different port so that there is no clash between the instances.)

https://nodered.org/docs/getting-started/local