Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have installed lessc via npm, Node.js Package Manager, and when I run lessc from terminal using

lessc /var/www/less/style.less /var/www/css/style.css

it works perfectly.
However, when I put this exact same command in a bash script, less.sh, it returns the error

lessc : command not found.

Also, I need to run this command from a bash script, because incron, a program which I am using to re-compile my less script each time they are modified, is unable to run the command mentioned above, which I believe may be caused by weird methods for handling white-space in the command.

share|improve this question
    
The non-working script is run in the same terminal where lessc works, or in some other ways (cron, a launcher, Alt-F2, other)? –  enzotib Sep 26 '11 at 16:12
    
There's a backtick at the end of your command. Is this typo only here or is it also in your less.sh? –  elmicha Sep 26 '11 at 17:33
    
yes the backtick was a typo. @enzotib does it matter where the script is being run from, and would it change anything that could cause the error mentioned above? –  slang800 Sep 26 '11 at 18:41
    
Yes, it matters. In different situation you can have different PATHs. –  enzotib Sep 26 '11 at 19:05
    
Thanks, after researching the $PATH variable I found that lessc was in "/opt/lessc/bin/lessc", which needed to be added to $PATH. –  slang800 Sep 27 '11 at 0:02
add comment

2 Answers

up vote 3 down vote accepted

Where is the "lessc" executable? Do:

type -p lessc

and take note of the directory, and figure out where that directory is added to your PATH. I think that bash and incron do not source your setup files (.bashrc, etc) the same way. Reading the Bash man page, the INVOCATION section describes how bash finds its startup files. A quick grep through the incron source shows that it doesn't mention .bashrc or .bash_profile.

You could change the "lessc" command in your script to:

/actual/path/to/lessc

that you found via

type -p lessc
share|improve this answer
    
Or add the "/actual/path/to/lessc/" to $PATH, by using the command "PATH=$PATH:/actual/path/to/lessc/" in the bash file. And thanks for posting that as a answer (not a comment). –  slang800 Sep 27 '11 at 19:01
add comment
npm install -g less

That installs Less.js globally. Maybe you tried this already but it's not in the documentation on http://lesscss.org/; I had to ask around in #node.js on FreeNode.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.