Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux Error installing sharp #1627

Closed
EFXPROMedia opened this issue Mar 26, 2019 · 9 comments
Closed

Linux Error installing sharp #1627

EFXPROMedia opened this issue Mar 26, 2019 · 9 comments
Labels

Comments

@EFXPROMedia
Copy link

I have been working on development on the mac and it seems to be working fine so I thought on deployment things could be just fine since the docs are pretty much similar for installation.

Unfortunately, I am getting the following error log:

info sharp Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.7.4/libvips-8.7.4-linux-x64.tar.gz
ERR! sharp EACCES: permission denied, open '/home/ricardo/_app/node_modules/sharp/9986-libvips-8.7.4-linux-x64.tar.gz'
info sharp Attempting to build from source via node-gyp but this may fail due to the above error
info sharp Please see https://sharp.pixelplumbing.com/page/install for required dependencies
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/ricardo/_app/node_modules/sharp/build'
gyp ERR! System Linux 4.4.0-127-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/ricardo/_app/node_modules/sharp
gyp ERR! node -v v10.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN la-therapy@1.0.2 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sharp@0.22.0 install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the sharp@0.22.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

is the building mainly failing because of the Linux version no being drawing or something else is happening here?

I am currently using Ubuntu 16.04 and I tried installing using sudo npm install --save sharp I also tried using npm install --build-from-source

@lovell
Copy link
Owner

lovell commented Mar 27, 2019

The salient part of this error is:

ERR! sharp EACCES: permission denied, open '/home/ricardo/_app/node_modules/sharp/9986-libvips-8.7.4-linux-x64.tar.gz'

You'll need to ensure whatever user is running npm install has the relevant filesystem permissions. Avoid using sudo/root if possible. If you have to, pass the npm install --unsafe-perm flag.

@EFXPROMedia
Copy link
Author

Strange thing is that the user I tried the install has is not the root user but it has sudo privileges and would install about anything without any problem also I tried using the service terminal and it had the same issue.

At the end your solution worked using npm install --unsafe-perm I am not sure about this flag capability I could not find it as a reference on npm but thanks for all

@lovell
Copy link
Owner

lovell commented Mar 27, 2019

@EFXPROMedia
Copy link
Author

Sorry but I thought things were fine but they are not...

I managed to install sharp and I tried running it with my pipe scripts but its not working so I tried installing everything again to make sure the installation was correct but I get a different warning now about libvips

> sharp@0.22.0 install /home/ricardo/_app/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)

info sharp Using cached /home/ricardo/.npm/_libvips/libvips-8.7.4-linux-x64.tar.gz
npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN la-therapy@1.1.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

correct if I am wrong but it says in the docs: libvips and its dependencies are fetched and stored within node_modules/sharp/vendor during npm install

I am not understanding where this libvips should live, globally or within the app module folder in the sharp directory, nevertheless, none of these attempts worked so far.

and whats these peer dependencies?

@EFXPROMedia EFXPROMedia reopened this Mar 30, 2019
@lovell
Copy link
Owner

lovell commented Mar 31, 2019

The warnings are unrelated to sharp and probably come from other dependencies. Run npm ls ajv-keywords etc. to discover more about these.

Please can you provide more details about what "but its not working" means. For example, are there any error messages?

@EFXPROMedia
Copy link
Author

EFXPROMedia commented Mar 31, 2019

Hi Lovell, before sharp was added to my package file things were installing just fine that’s why I thought the errors were coming from the sharp bundler installation on my Ubuntu server, after all the struggle getting it to work I cleared all the server and started from scratch and it worked just fine no need to use sudo or unsafe flag for install and sharp is now working.

Performance is better than I expected too 👏🏻

@manel00
Copy link

manel00 commented Jul 2, 2019

Thank you so much @EFXPROMedia, if it wasnt because of you i didnt finish my app ;) you saved my life ;)

@arnotixe
Copy link

arnotixe commented Sep 3, 2019

#metoo I had to run sudo npm install -g --unsafe-perm sharp and after sudo npm install -g --unsafe-perm cordova-res
Seems the problem is related to the sharp setup picking the wrong user, because I get prompted for a password for 'nobody' (even if I su-do it). Key was --unsafe-perm although I admit I didn't read up on what that does.

@lovell
Copy link
Owner

lovell commented Sep 4, 2019

I recommend avoiding the use of sudo/root when installing via npm, but if you do, npm's --unsafe-perm flag is required, as is the case for all native modules and not just sharp.

Repository owner locked and limited conversation to collaborators Sep 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants