Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I installed less.js on my machine, but the module still reports less.js as missing.
The existing documentation is a bit thin in this area.
When I check on my console, it looks like the lessc file can be found.
Imac kevin$ which lessc
/usr/local/bin//lessc
So probably what I'm is missing is "Thus is it required that you configure your PATH for the user that your PHP installation runs under to ensure that these programs can be run by name without the full path."
How could I check / achieve this?
Comments
Comment #1
asimag CreditAttribution: asimag commentedTo get less.js (lessc) working in OS X
Visit http://nodejs.org and click on Install
After installation, you need to create symbolic link or set path.
First make sure that lessc is working in your terminal.
Create a Symbolic link:
and you are ready to go.
Comment #2
corey.aufang CreditAttribution: corey.aufang commentedYou need to make sure that this is available for the user that is running PHP, usually the user that your web server process runs under.
In Ubuntu, Apache runs under the user "www-data". So you would need to make sure that "lessc" can be run by that user without using the full path to the binary.
Creating a symbolic link to the binary might help, but you need to ensure that it works for the user account in question.
Comment #3
sylvaticus CreditAttribution: sylvaticus commentedSame here, on Ubuntu 14.04.
I just tested php with this script:
and it works only when I specify the full path of lessc, meaning that, differently than normal users, www-user don't have /usr/bin in path.
I believe that the fact that /usr/bin is NOT in www-data path is to increase security. So, is there a way to add only lessc in path ? I guess simlinking it to an other directory and putting the path of that directory for www-data.. is this the right approach? How to add path to www-data ?
I know that this question is not strictly related with the module itself, but I guess it would help lot of users..
Comment #4
corey.aufang CreditAttribution: corey.aufang commentedWhen you installed less.js did you use the '-g' command line switch?
The '-g' switch as documented here and specified for less.js here installs less.js with the 'lessc' command available globally. I believe it does this by adding 'lessc' to global PATH.
On Ubuntu I found that it was simpler to use 'su' and install as root. Attempting to install as a regular user, even with 'sudo', caused many issues beyond not having 'lessc' available to the www-data user. I found this issue with any node.js module installed with npm.
I want to make this clear: I had issues installing on my system, which is my dev system and not a real server. I most likely had permissions issues, but it was too convoluted for me to diagnose and fix. You use 'su' at your own risk.
So if you're on Ubuntu, you can try using 'su' and then following the command line install instructions linked above. Make sure you use the '-g' option so that all users have access to the command.
You might need to purge any previously installed versions of less.js before proceeding.
You might also be able to switch to the www-data user and install under that user, but I don't know how well that would work.
Comment #5
K3vin_nl CreditAttribution: K3vin_nl commentedProbably has to with my MAMP configuration, but on the command line I get these results:
When I run the same lines from a php file inside my drupal directory
So it is correct that lessc can't be found. However it looks like MAMP is running onder my user name and should be able to find it.
Comment #6
corey.aufang CreditAttribution: corey.aufang commentedYeah, that is odd.
I won't be able to provide any help with OS X, sorry.