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 am not even sure where to start debugging this. Months ago, I could happily compile my CSS from my LESS files. Today, I run either recess --compile test.less or lessc test.less and I just get a blank output. No errors. lessc test.less > test.css just creates a blank file. The twitter-bootstrap Makefile for LESS errors, all be it not helpfully.

I'm using the following simple test.less to debug:

@color: #4D926F;
#header {
  color: @color;
}
h2 {
   color: @color;
}

I'm on ubuntu 12.10, I used sudo apt-get install node-less to provide lessc, and installed recess from the directions on github (npm). Both just give me empty output.

Even lessc --version returns nothing.

 which lessc

shows

/usr/local/bin/lessc

and the file isn't empty.

Something must have happened to my node installation perhaps, but no idea how to debug this. apt-get remove --purge node-less and reinstalling didn't help.

Many thanks for the help or any tips on debugging!

share|improve this question
    
Yeah, /usr/local/bin/lessc is not the correct location when it's from the official repo: packages.ubuntu.com/quantal/all/node-less/filelist ... I guess you installed it in the system path using sudo npm ... which is a really bad idea. –  dAnjou Dec 27 '12 at 19:13

2 Answers 2

up vote 4 down vote accepted
+50

In Ubuntu and other distributions, you should prefer the distribution packages instead of manually installing packages. So, first of all, you should remove the recess installed via npm:

sudo npm uninstall recess -g

Also remove the node-less package installed via apt-get, so that we can start with a clean environment:

sudo apt-get remove node-less

After issuing these two commands, ensure that the following files do not exist, and if they exist delete them:

/usr/bin/lessc
/usr/local/bin/lessc

Also check the following directories (and remove them if they exist):

/node_modules/less
/usr/bin/node_modules/less
/usr/node_modules/less
/usr/local/bin/node_modules/less
/usr/local/node_modules/less
~/.node_modules/less
~/.node_libraries/less

All that files and directories may be generated in various ways. Different installation methods lead to different directories used. Removing all that files is important to ensure that nothing conflicts: you should always have one, and just one, version of a software installed on your system. The only exception is when the distribution itself provides different versions of the same software (in this case, package are made so that they don't conflict with each other).

Now you have a clean environment and can install node-less:

sudo apt-get install node-less

Note that the node-less package does not ship /usr/bin/recess, just /usr/bin/lessc, so it's perfectly OK if recess --compile fails (or, better, it must fail).

If lessc still does not work, please check the output of which lessc. Remember: if it does return something different than /usr/bin/lessc, it means that you are not using lessc from the distribution package, but something else.

share|improve this answer
    
You don't need to prefer distro packages, but mixing distro and compiled packages that provide similar binaries is really a recipe for problems. –  Javier Rivera Dec 27 '12 at 19:56
    
@Javier: hi. Surely you don't need to choose only distribution packages, but we are on Ask Ubuntu and I think the most appropriate solution is one that tells you how to use the distribution packages. :-) –  Andrea Corbellini Dec 27 '12 at 20:04
    
Just a brilliant answer, thanks for the careful explanation. Everything is working now as it should. Not sure how I managed to get a dud version of the npm less installed, but I caution on not mixing similar distro & compiled packages is well noted. It is a pity that it's often not possible to rely only on distro packages though, particularly in with ruby, etc. –  cboettig Dec 27 '12 at 20:23
1  
@cboettig: thanks for your feedback, it's really appreciated. As Javier pointed out, you are not forced to use distribution packages. But when you install third-party software, remember to not install it system wide. For example, I use Python Virtualenv, chroots, Linux Containers (LXC) and Qemu virtual machines when I need to run software not provided by the distribution (or when I need special system configurations). All these technologies (and many others) help you isolate the software, avoiding the pain. –  Andrea Corbellini Dec 27 '12 at 20:31
    
Running lessc gives /usr/local/bin/lessc no such file or directory, but running which lessc gives /usr/bin/lessc. How do I tell it to use the lessc from which lessc? –  Jacob Valenta Apr 24 at 7:15

After following the steps from Andrea's answer you may have to run source ~/.bashrc if you're getting bash: /usr/local/bin/lessc: No such file or directory when you run lessc and when which lessc shows /usr/bin/lessc. This is to update your $PATH environment variable.

share|improve this answer

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.