PaulWieland / node-red-contrib-saprfc

A node-red node for making Remote Function Calls to an SAP system
16 stars 5 forks source link

Installing on Suse Linux #1

Closed nygma2004 closed 4 years ago

nygma2004 commented 4 years ago

Hi Paul,

I have probably messed up some installation steps on the way, but I am not very experience in Linux and the fact that I am doing this in Suse makes it bit worse (I am using to Raspbian on a PI when it comes to Linux).

The server I am installing in x86 on Suse Linux, so I ran into issues installing node-rfc itself, but after cloning it I think I managed to install it after all.

Next I tried adding the your module from within the palette manager and it failed. I am seeing this at the end of the log file:

38 verbose stack Error: /root/snap/node-red/538/node_modules/node-rfc: Appears to be a git repo or submodule. 38 verbose stack at /snap/node-red/538/lib/node_modules/npm/node_modules/npm-install-checks/index.js:138:15 38 verbose stack at callback (/snap/node-red/538/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:295:20) 38 verbose stack at FSReqWrap.oncomplete (fs.js:154:5) 39 verbose cwd /root/snap/node-red/538 40 verbose Linux 4.12.14-122.17-default 41 verbose argv "/snap/node-red/538/bin/node" "/snap/node-red/538/bin/npm" "install" "--no-audit" "--no-update-notifier" "--save" "--save-prefix=\"~\"" "--production" "node-red-contrib-saprfc@1.2.3" 42 verbose node v10.19.0 43 verbose npm v6.13.4 44 error code EISGIT 45 error path /root/snap/node-red/538/node_modules/node-rfc 46 error git /root/snap/node-red/538/node_modules/node-rfc: Appears to be a git repo or submodule. 47 error git /root/snap/node-red/538/node_modules/node-rfc 48 error git Refusing to remove it. Update manually, 48 error git or move it out of the way first. 49 verbose exit [ 1, true ]

Did I install node-rfc in the wrong place? I don't really understand what these messages mean.

Thanks, Csongor

PaulWieland commented 4 years ago

Hi @nygma2004 what happens if you install it with npm?

cd into the nodered directory and npm install node-red-contrib-saprfc

nygma2004 commented 4 years ago

It is the same. Complains about the node-rfc folder already there. Should I have done the git and npm install outside the node_modules folder? Or it would have been the same?

PaulWieland commented 4 years ago

I haven't seen this error before, but it appears to be something wrong with your node-rfc install. Googling "appears to be a git repo" turned up this stackexchange discussion. Apparently npm doesn't like anything which has a .git folder inside of it.

Does /root/snap/node-red/538/node_modules/node-rfc/.git exist? If so, try deleting it.

nygma2004 commented 4 years ago

That made the difference. But I am still puzzled as what is going on. So yesterday I cloned the node-rfc project, and in the node.rfc folder and installed is using:

node-red.npm install

Before that I also installed gcc as it had to be complied for Suse. Now I want to install sap-rfc using:

node-red.npm install node-red-contrib-saprfc

And still complaining about C compiler missing. And wants to re-compile node-rfc again? This is what I get in the command line. And after this my node-rfc folder is deleted:

dkadev-nre:~/snap/node-red/538/node_modules # node-red.npm install node-red-contrib-saprfc

node-rfc@1.0.0-rc11 preinstall /root/snap/node-red/538/node_modules/node-rfc npm install cmake-js prebuild-install prebuild node-addon-api

npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm notice created a lockfile as package-lock.json. You should commit this file.

  • prebuild-install@5.3.3
  • node-addon-api@1.7.1
  • cmake-js@5.3.2
  • prebuild@9.1.1 added 245 packages from 208 contributors and audited 1205 packages in 9.821s

2 packages are looking for funding run npm fund for details

found 0 vulnerabilities

node-rfc@1.0.0-rc11 install /root/snap/node-red/538/node_modules/node-rfc prebuild-install --tag-prefix -r napi || npm run prebuild

prebuild-install WARN install EPERM: operation not permitted, chown 'lib/binding/sapnwrfc.node'

node-rfc@1.0.0-rc11 prebuild /root/snap/node-red/538/node_modules/node-rfc prebuild --backend cmake-js -r napi --force --strip --verbose --tag-prefix

prebuild info begin Prebuild version 9.1.1 prebuild info build Preparing to prebuild node-rfc@1.0.0-rc11 for napi 3 on linux-x64 using cmake-js prebuild verb starting build process cmake-js [ '/snap/node-red/538/bin/node', '/root/snap/node-red/538/node_modules/node-rfc/node_modules/.bin/cmake-js', 'rebuild', '--arch=x64', '--CDnapi_build_version=3' ] ERR! OMG C++ Compiler toolset is not available. Install proper compiler toolset with your package manager, eg. 'sudo apt-get install g++'. ERR! OMG C++ Compiler toolset is not available. Install proper compiler toolset with your package manager, eg. 'sudo apt-get install g++'. prebuild ERR! build Error: Failed to build cmake with exit code 1 prebuild ERR! build at ChildProcess. (/root/snap/node-red/538/node_modules/node-rfc/node_modules/prebuild/cmakebuild.js:32:19) prebuild ERR! build at ChildProcess.emit (events.js:198:13) prebuild ERR! build at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12) npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! node-rfc@1.0.0-rc11 prebuild: prebuild --backend cmake-js -r napi --force --strip --verbose --tag-prefix npm ERR! Exit status 2 npm ERR! npm ERR! Failed at the node-rfc@1.0.0-rc11 prebuild script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /root/snap/node-red/538/.npm/_logs/2020-03-11T14_44_20_592Z-debug.log npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! node-rfc@1.0.0-rc11 install: prebuild-install --tag-prefix -r napi || npm run prebuild npm ERR! Exit status 2 npm ERR! npm ERR! Failed at the node-rfc@1.0.0-rc11 install script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /root/snap/node-red/538/.npm/_logs/2020-03-11T14_44_21_108Z-debug.log

My installation of the node-rfc was wrong in the beginning?

PaulWieland commented 4 years ago

When I install node-rfc, I do so with npm -g install node-rfc. I am not cloning the repo. I only clone from github and npm install when I am developing a new feature in a fork for that project.

nygma2004 commented 4 years ago

I ran into the same issue when installing node-rfc itself. I was told that I need to clone the repo, as the prebuilt libraries are usually for Ubuntu and since I am running Suse linux, I need to build the library myself. And it seem to have worked for node-rfc, but not this time for some reason.

PaulWieland commented 4 years ago

Yeah, I guess that makes sense. This problem you are having is just part of the joy of working with NPM I suppose.

So now that the .git directory is gone, did the install of the node-red-contrib-saprfc work?

nygma2004 commented 4 years ago

No, with the git directory gone, I was getting the error I pasted above. Which looks like it is trying to re-build the node-rfc and failing.

PaulWieland commented 4 years ago

What if you clone the git repo it and npm install locally?

nygma2004 commented 4 years ago

Let me show you the entire process.

This is what I get when I npm install node-rfc locally:

dkadev-nre:~/snap/node-red/538/node_modules/node-rfc # node-red.npm install npm WARN lifecycle node-rfc@1.0.5~preinstall: cannot run in wd node-rfc@1.0.5 npm install cmake-js prebuild-install prebuild node-addon-api (wd=/root/snap/node-red/538/node_modules/node-rfc) npm WARN lifecycle node-rfc@1.0.5~install: cannot run in wd node-rfc@1.0.5 prebuild-install --tag-prefix -r napi || npm run prebuild (wd=/root/snap/node-red/538/node_modules/node-rfc) npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 669 packages from 510 contributors and audited 877815 packages in 18.842s

2 packages are looking for funding run npm fund for details

found 37196 vulnerabilities (37180 low, 14 moderate, 2 high) run npm audit fix to fix them, or npm audit for details

I think this is OK, there are a few warning, but nothing else. Next, I clone yours:

dkadev-nre:~/snap/node-red/538/node_modules # git clone https://github.com/PaulWieland/node-red-contrib-saprfc.git Cloning into 'node-red-contrib-saprfc'... remote: Enumerating objects: 81, done. remote: Counting objects: 100% (81/81), done. remote: Compressing objects: 100% (51/51), done. remote: Total 81 (delta 41), reused 54 (delta 25), pack-reused 0 Unpacking objects: 100% (81/81), done.

So far so good. And finally I npm install this as well:

dkadev-nre:~/snap/node-red/538/node_modules/node-red-contrib-saprfc # node-red.npm install

node-rfc@1.0.0-rc11 preinstall /root/snap/node-red/538/node_modules/node-red-contrib-saprfc/node_modules/node-rfc npm install cmake-js prebuild-install prebuild node-addon-api

npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm notice created a lockfile as package-lock.json. You should commit this file.

  • node-addon-api@1.7.1
  • prebuild-install@5.3.3
  • cmake-js@5.3.2
  • prebuild@9.1.1 added 245 packages from 208 contributors and audited 1205 packages in 14.381s

2 packages are looking for funding run npm fund for details

found 0 vulnerabilities

node-rfc@1.0.0-rc11 install /root/snap/node-red/538/node_modules/node-red-contrib-saprfc/node_modules/node-rfc prebuild-install --tag-prefix -r napi || npm run prebuild

prebuild-install WARN install EPERM: operation not permitted, chown 'lib/binding/sapnwrfc.node'

node-rfc@1.0.0-rc11 prebuild /root/snap/node-red/538/node_modules/node-red-contrib-saprfc/node_modules/node-rfc prebuild --backend cmake-js -r napi --force --strip --verbose --tag-prefix

prebuild info begin Prebuild version 9.1.1 prebuild info build Preparing to prebuild node-rfc@1.0.0-rc11 for napi 3 on linux-x64 using cmake-js prebuild verb starting build process cmake-js [ '/snap/node-red/538/bin/node', '/root/snap/node-red/538/node_modules/node-red-contrib-saprfc/node_modules/node-rfc/node_modules/.bin/cmake-js', 'rebuild', '--arch=x64', '--CDnapi_build_version=3' ] ERR! OMG C++ Compiler toolset is not available. Install proper compiler toolset with your package manager, eg. 'sudo apt-get install g++'. ERR! OMG C++ Compiler toolset is not available. Install proper compiler toolset with your package manager, eg. 'sudo apt-get install g++'. prebuild ERR! build Error: Failed to build cmake with exit code 1 prebuild ERR! build at ChildProcess. (/root/snap/node-red/538/node_modules/node-red-contrib-saprfc/node_modules/node-rfc/node_modules/prebuild/cmakebuild.js:32:19) prebuild ERR! build at ChildProcess.emit (events.js:198:13) prebuild ERR! build at Process.ChildProcess._handle.onexit (internal/child_process.js:248:12) npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! node-rfc@1.0.0-rc11 prebuild: prebuild --backend cmake-js -r napi --force --strip --verbose --tag-prefix npm ERR! Exit status 2 npm ERR! npm ERR! Failed at the node-rfc@1.0.0-rc11 prebuild script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /root/snap/node-red/538/.npm/_logs/2020-03-11T18_16_50_575Z-debug.log npm WARN node-red-contrib-saprfc@1.2.3 No repository field.

npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! node-rfc@1.0.0-rc11 install: prebuild-install --tag-prefix -r napi || npm run prebuild npm ERR! Exit status 2 npm ERR! npm ERR! Failed at the node-rfc@1.0.0-rc11 install script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /root/snap/node-red/538/.npm/_logs/2020-03-11T18_16_51_477Z-debug.log

I am not sure if I understand the logs correctly. I am not sure why the two are different. node-rfc was also built, why is the issues with saprfc and the missing C++ compiler. I received similar errors just a few days ago when I built node-rfc and I have installed C++ using 'sudo zypper in gcc-c++' which is the command in Suse.

PaulWieland commented 4 years ago

So it seems that when you npm install the cloned version of this repo, npm is trying to also install all dependencies, including node-rfc.

What happens if you npm -g install inside the cloned node-rfc directory?

The -g option should make it a global install - I am hoping by doing that, npm will see that node-rfc exists and won't try to compile it again.

I'm no npm expert, so I apologize for the trial and error...

nygma2004 commented 4 years ago

I appreciate the time you spend with me on this.

If I try to install global, I get the following error:

dkadev-nre:~/snap/node-red/538/node_modules/node-rfc # node-red.npm -g install npm WARN checkPermissions Missing write access to /snap/node-red/538/lib/node_modules/ext/node_modules npm WARN checkPermissions Missing write access to /snap/node-red/538/lib/node_modules npm ERR! code EROFS npm ERR! syscall access npm ERR! path /snap/node-red/538/lib/node_modules/ext/node_modules npm ERR! errno -30 npm ERR! rofs EROFS: read-only file system, access '/snap/node-red/538/lib/node_modules/ext/node_modules' npm ERR! rofs Often virtualized file systems, or other file systems npm ERR! rofs that don't support symlinks, give this error.

npm ERR! A complete log of this run can be found in: npm ERR! /root/snap/node-red/538/.npm/_logs/2020-03-11T20_25_37_071Z-debug.log

In my lib folder, there is only a flow folder, and all my modules are in the .../538/node_modules. So this takes me less than where I was before...

Can I somehow remove the dependencies after I cloned your project? Just to avoid recompiling node-rfc?

PaulWieland commented 4 years ago

Your user does not have permission to install globally.

So, next idea is to try and link the locally installed node-rfc into the node-red-contrib-rfc folder before doing the npm install.

I think there is an npm link function but I’m away from my computer and can’t verify for you right now.

nygma2004 commented 4 years ago

Thanks for this tip. So I was looking this up, and after compiling node-rfc i should node-red.npm link in the node-rfc dir. But it looks like it leads to the same permission problem as the global install:

dkadev-nre:~/snap/node-red/538/node_modules/node-rfc # node-red.npm link npm ERR! code EROFS npm ERR! syscall symlink npm ERR! path /root/snap/node-red/538/node_modules/node-rfc npm ERR! dest /snap/node-red/538/lib/node_modules/node-rfc npm ERR! errno -30 npm ERR! rofs EROFS: read-only file system, symlink '/root/snap/node-red/538/node_modules/node-rfc' -> '/snap/node-red/538/lib/node_modules/node-rfc' npm ERR! rofs Often virtualized file systems, or other file systems npm ERR! rofs that don't support symlinks, give this error.

npm ERR! A complete log of this run can be found in: npm ERR! /root/snap/node-red/538/.npm/_logs/2020-03-11T21_33_14_766Z-debug.log

But I think not everything is lost, if this is about access, I can go and temporarily get more privileges. I think that should be possible.

ghost commented 4 years ago

From what it looks like, you are running within a snap packages. So more privilege will not help you much, since it is running within a virtual read only filesystem. This might also be why the gcc tools are not registered, as these might not be mapped inside your snap package. (One of the downsides of snap)

PaulWieland commented 4 years ago

@dkanhakl I have no experience with snap, so thank you for pointing that out.

If node-red was installed with snap (and its read only) how does the flows.json file get deployed/updated? How do you install other nodes? There must be some part of the file system that allows writing?

ghost commented 4 years ago

If node-red was installed with snap (and its read only) how does the flows.json file get deployed/updated? How do you install other nodes? There must be some part of the file system that allows writing?

Yes there are. Usually the /home/<user> is passed through, but that depends on the package. Snap is meant as an abstraction/container-ish layer, which allows you to package all dependencies to your program, which allows easy deployments without dependency hell, as you can deploy "batteries included", but this does come with the down side that it mounts most root based folders, e.g. /bin, /usr/bin, and such, to read only mounts. This can hinder the use of some development tools deployed as snap packages. Most of the behaviour (if I remember correctly) can be configured to not be read only.

But sorry if my information is not a 100% correct, it has been a few years since I played with snap last.

PaulWieland commented 4 years ago

Ahh, ok it sounds a lot like docker. Docker containers are also read only, but you can mount a volume on the host which is read/write. This volume is where node-red puts all of it's data (including the node_modules directory where you would run NPM to install new packages).