Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to compile a very simple less file which simply includes Bootstrap:

/* application.less: The most awesomely complicated file in the whole world. */
@import "bootstrap/bootstrap.less";

I'm on an Ubuntu 12.04 derivative and I've tried using the lessc compiler found in the node-less package:

$ sudo apt-get install node-less
$ ( cd /path/of/less/file/ && lessc application.less )
TypeError: Cannot call method 'charAt' of undefined
    at getLocation (/usr/lib/nodejs/less/parser.js:204:34)
    at new LessError (/usr/lib/nodejs/less/parser.js:213:19)
    at Object.toCSS (/usr/lib/nodejs/less/parser.js:379:31)
    at /usr/bin/lessc:103:28
    at /usr/lib/nodejs/less/parser.js:428:40
    at /usr/lib/nodejs/less/parser.js:94:48
    at /usr/lib/nodejs/less/index.js:113:15
    at /usr/lib/nodejs/less/parser.js:428:40
    at /usr/lib/nodejs/less/parser.js:94:48
    at /usr/lib/nodejs/less/index.js:113:15

Not easily deterred, I then tried using the Ruby version of lessc.

$ sudo apt-get remove --purge node-less
$ sudo gem install less
[WARNING] Please install gem 'therubyracer' to use Less.
/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require': no such file to load -- v8 (LoadError)
    from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
    from /var/lib/gems/1.8/gems/less-2.2.2/lib/less/java_script/v8_context.rb:2
    from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
    from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
    from /var/lib/gems/1.8/gems/less-2.2.2/lib/less/java_script.rb:9:in `default_context_wrapper'
    from /var/lib/gems/1.8/gems/less-2.2.2/lib/less/java_script.rb:17:in `context_wrapper'
    from /var/lib/gems/1.8/gems/less-2.2.2/lib/less/loader.rb:10:in `initialize'
    from /var/lib/gems/1.8/gems/less-2.2.2/lib/less.rb:14:in `new'
    from /var/lib/gems/1.8/gems/less-2.2.2/lib/less.rb:14
    from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
    from /usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:36:in `require'
    from /var/lib/gems/1.8/gems/less-2.2.2/bin/lessc:3
    from /usr/local/bin/lessc:19:in `load'
    from /usr/local/bin/lessc:19

Come on! Ruby doesn't know how to manage dependencies?! Whatever. Fine.

$ sudo gem install therubyracer
/usr/bin/ruby1.8 extconf.rb
checking for main() in -lpthread... yes
checking for v8.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
/var/lib/gems/1.8/gems/therubyracer-0.11.0/ext/v8/build.rb:42:in `build_with_system_libv8': unable to locate libv8. Please see output for details (RuntimeError)
    from extconf.rb:22
    The Ruby Racer requires libv8 ~> 3.11.8
    to be present on your system in order to compile
    and link, but it could not be found.

    In order to resolve this, you will either need to manually
    install an appropriate libv8 and make sure that this
    build process can find it. If you install it into the
    standard system path, then it should just be picked up
    automatically. Otherwise, you'll have to pass some extra
    flags to the build process as a hint.

    If you don't want to bother with all that, there is a
    rubygem that will do all this for you. You can add
    following line to your Gemfile:
        gem 'libv8', '~> 3.11.8'

    We hope that helps, and we apologize, but now we have
    to push the eject button on this install.

    The Mgmt.

And I'm done. Is there any easy way to get a working less compiler installed on my distribution? This is getting ridiculous.

share|improve this question

This side of the screen:

 $ node --version
 $ npm --version
 $ npm install less
 npm http GET https://registry.npmjs.org/less
 npm http 200 https://registry.npmjs.org/less
 npm http GET https://registry.npmjs.org/less/-/less-1.3.3.tgz
 npm http 200 https://registry.npmjs.org/less/-/less-1.3.3.tgz
 npm http GET https://registry.npmjs.org/ycssmin
 npm http 200 https://registry.npmjs.org/ycssmin
 npm http GET https://registry.npmjs.org/ycssmin/-/ycssmin-1.0.1.tgz
 npm http 200 https://registry.npmjs.org/ycssmin/-/ycssmin-1.0.1.tgz
 less@1.3.3 node_modules/less
 └── ycssmin@1.0.1
 $ ln --symbolic ~/node_modules/.bin/lessc ~/bin/lessc
 $ lessc --version
 lessc 1.3.3 (LESS Compiler) [JavaScript]

The installation works. Could not run your test.less file, though (no bootstrap installed). Summing it up: why don't you use npm? What version of node have you got installed?

share|improve this answer
up vote 1 down vote accepted

With a lot of help from @Deer Hunter, I got it up and running pretty quickly.

$ sudo apt-get install npm
$ sudo npm install --global less
$ sudo ln -s /usr/local/lib/node_modules/less/bin/lessc /usr/local/bin
share|improve this answer

Your Answer


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.