Skip to content

“Error: The libsass binding was not found…” in 4.2.4-wheezy. #88

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

Closed
philiiiiiipp opened this issue Jan 18, 2016 · 9 comments
Closed

Comments

@philiiiiiipp
Copy link

Hey,

I posted a question on stackoverflow regarding a problem I have with node-sass using the 4.2.4-wheezy image. I am wondering right now if this has something to do with the image itself as I am perfectly capable of building it on my machine running node 4.2.4 and on the 5.4.1-wheezy image on docker.

@chorrell
Copy link
Contributor

Hi,

I can't seem to reproduce the issue your are having.

Grabbed the latest wheezy 4.2 image:

docker run --rm -it node:4.2.4-wheezy bash

And from within the container I did this:

root@793c84e5e60e:/# npm install -g node-sass

And it installed:

root@793c84e5e60e:/# npm list -g --depth 0
npm info it worked if it ends with ok
npm info using [email protected]
npm info using [email protected]
/usr/local/lib
├── [email protected]
└── [email protected]

npm info ok 
root@793c84e5e60e:/# 

That's using the latest version of node-sass

@philiiiiiipp
Copy link
Author

Yes, that works for me too. I investigated a bit further and the problem seems to lay in the node-sass-middleware module used by express. Try:

npm install express-generator -g &&
express -c sass --hbs --git myapp &&
cd myapp &&
npm install &&
npm start

The problem seems to be these lines here:

npm WARN cannot run in wd [email protected] node scripts/install.js (wd=/srv/www/myapp/node_modules/node-sass-middleware/node_modules/node-sass)
npm info postinstall [email protected]
npm WARN cannot run in wd [email protected] node scripts/build.js (wd=/srv/www/myapp/node_modules/node-sass-middleware/node_modules/node-sass)

substituting

npm install 

with

npm --unsafe-perm install

fixes the issue which I don't have to do if I install it on my mac using 4.2.4, as well as when I use the 5.4.1 image.

@pesho
Copy link
Contributor

pesho commented Jan 18, 2016

Indeed, npm 2.x will not execute scripts when run as root, unless called with --unsafe-perm. This can cause some packages to not install properly, without printing a clear error. Maybe this behaviour has changed with npm 3.x, which the Node 5.x image is using.

@philiiiiiipp
Copy link
Author

Okay, that makes sense. Changing the directory owner on my mac to root and running sudo npm install gives the same warning.

npm WARN cannot run in wd [email protected] node scripts/install.js (wd=/Users/philipp/node/docker_test/myapp/node_modules/node-sass-middleware/node_modules/node-sass)
npm WARN cannot run in wd [email protected] node scripts/build.js (wd=/Users/philipp/node/docker_test/myapp/node_modules/node-sass-middleware/node_modules/node-sass)

Leading to the same error

Error: The `libsass` binding was not found in ...

I guess the proper way to go would be to create a user which owns the directory the app runs within, basically the way Starefossen suggested in his best practices guide ?

@pesho
Copy link
Contributor

pesho commented Jan 18, 2016

I guess the proper way to go would be to create a user which owns the directory the app runs within, basically the way Starefossen suggested in his best practices guide ?

Yes.

Alternatively, you could just run npm with --unsafe-perm as root, but given that there are known ways to escape the Docker sandbox, malicious packages could cause greater damage when run as root.

@philiiiiiipp
Copy link
Author

Cool, thanks for your help!

@Starefossen
Copy link
Member

Running with another --user would also work.

@iDVB
Copy link

iDVB commented Mar 6, 2019

@Starefossen I know this is an old issue, but we're trying to find a resolution other than running with --unsafe-perm. How do you run under a different user?

@nschonni
Copy link
Member

nschonni commented Mar 6, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants