cyberdelia/django-pipeline — Issue #45: Less compiler not respecting relative paths with @import
Author: rfkrocktk
Created: 2011-11-17 03:30:31+00:00
State: open

I'm running django-pipeline version 1.1.22 (latest), and the following isn't working yet in .less files:

@import "bootstrap-1.4/bootstrap.less";

The reason one would do this would be to include the Less library and be able to predefine variables and be able to use the mixins exposed by the library in one's own Less code. For instance:

@basefont: 14px; /* in bootstrap, it's 13 by default, so we override it before it's imported */

@import "bootstrap-1.4/bootstrap.less";

.ghostly { /* we use bootstrap's defined .opacity mixin to create this effect. */
.opacity(90);
}

Currently, this doesn't work and yields:

Environment:

Request Method: GET
Request URL: http://localhost:8000/

Django Version: 1.3
Python Version: 2.7.1
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'django.contrib.admindocs',
'django.contrib.staticfiles',
'django_bcrypt',
'pipeline',
'reversion',
'south',
'myproject.web']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')

Template error:
In template /home/rfkrocktk/Desktop/myproject/src/myproject/web/templates/desktop/root.html, error at line 6
Caught CompilerError while rendering: /var/lib/gems/1.8/gems/less-2.0.7/lib/less/loader.rb:46:in `error': file 'bootstrap-1.4/bootstrap.less' wasn't found. (Less::ParseError)
from at Function.importer (/var/lib/gems/1.8/gems/less-2.0.7/lib/less/js/lib/less/index.js:114:13)
from at Object.push (/var/lib/gems/1.8/gems/less-2.0.7/lib/less/js/lib/less/parser.js:73:25)
from at Object. (/var/lib/gems/1.8/gems/less-2.0.7/lib/less/js/lib/less/tree/import.js:30:17)
from at Object.import (/var/lib/gems/1.8/gems/less-2.0.7/lib/less/js/lib/less/parser.js:953:28)
from at $ (/var/lib/gems/1.8/gems/less-2.0.7/lib/less/js/lib/less/parser.js:103:24)
from at Object.directive (/var/lib/gems/1.8/gems/less-2.0.7/lib/less/js/lib/less/parser.js:967:29)
from at $ (/var/lib/gems/1.8/gems/less-2.0.7/lib/less/js/lib/less/parser.js:103:24)
from at Object.primary (/var/lib/gems/1.8/gems/less-2.0.7/lib/less/js/lib/less/parser.js:428:80)
from at $ (/var/lib/gems/1.8/gems/less-2.0.7/lib/less/js/lib/less/parser.js:103:24)
from at Object.parse (/var/lib/gems/1.8/gems/less-2.0.7/lib/less/js/lib/less/parser.js:264:42)
from /var/lib/gems/1.8/gems/less-2.0.7/lib/less/parser.rb:65:in `parse'
from /var/lib/gems/1.8/gems/less-2.0.7/lib/less/parser.rb:13:in `calljs'
from /var/lib/gems/1.8/gems/less-2.0.7/lib/less/parser.rb:27:in `lock'
from /var/lib/gems/1.8/gems/less-2.0.7/lib/less/parser.rb:25:in `lock'
from /var/lib/gems/1.8/gems/less-2.0.7/lib/less/parser.rb:12:in `calljs'
from /var/lib/gems/1.8/gems/less-2.0.7/lib/less/parser.rb:63:in `parse'
from /var/lib/gems/1.8/gems/less-2.0.7/bin/lessc:22
from /usr/local/bin/lessc:19:in `load'
from /usr/local/bin/lessc:19

1 : {% load static %}

2 : {% load compressed %}

3 :

4 :

5 :

6 :	{% block stylesheets %} {% compressed_css 'all' %} {% endblock %}

7 :

{% block title %}{% endblock %} » myproject

8 :

9 :

10 :	{% block body %}{% endblock %}

11 :	{% block scripts %}{% compressed_js 'all' %}{% endblock %}

12 :

13 :

14 :

Traceback:
File "/home/rfkrocktk/Desktop/myproject/eggs/Django-1.3-py2.7.egg/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/home/rfkrocktk/Desktop/myproject/eggs/Django-1.3-py2.7.egg/django/views/generic/simple.py" in direct_to_template
28. return HttpResponse(t.render(c), mimetype=mimetype)
File "/home/rfkrocktk/Desktop/myproject/eggs/Django-1.3-py2.7.egg/django/template/base.py" in render
123. return self._render(context)
File "/home/rfkrocktk/Desktop/myproject/eggs/Django-1.3-py2.7.egg/django/template/base.py" in _render
117. return self.nodelist.render(context)
File "/home/rfkrocktk/Desktop/myproject/eggs/Django-1.3-py2.7.egg/django/template/base.py" in render
744. bits.append(self.render_node(node, context))
File "/home/rfkrocktk/Desktop/myproject/eggs/Django-1.3-py2.7.egg/django/template/debug.py" in render_node
73. result = node.render(context)
File "/home/rfkrocktk/Desktop/myproject/eggs/Django-1.3-py2.7.egg/django/template/loader_tags.py" in render
127. return compiled_parent._render(context)
File "/home/rfkrocktk/Desktop/myproject/eggs/Django-1.3-py2.7.egg/django/template/base.py" in _render
117. return self.nodelist.render(context)
File "/home/rfkrocktk/Desktop/myproject/eggs/Django-1.3-py2.7.egg/django/template/base.py" in render
744. bits.append(self.render_node(node, context))
File "/home/rfkrocktk/Desktop/myproject/eggs/Django-1.3-py2.7.egg/django/template/debug.py" in render_node
73. result = node.render(context)
File "/home/rfkrocktk/Desktop/myproject/eggs/Django-1.3-py2.7.egg/django/template/loader_tags.py" in render
127. return compiled_parent._render(context)
File "/home/rfkrocktk/Desktop/myproject/eggs/Django-1.3-py2.7.egg/django/template/base.py" in _render
117. return self.nodelist.render(context)
File "/home/rfkrocktk/Desktop/myproject/eggs/Django-1.3-py2.7.egg/django/template/base.py" in render
744. bits.append(self.render_node(node, context))
File "/home/rfkrocktk/Desktop/myproject/eggs/Django-1.3-py2.7.egg/django/template/debug.py" in render_node
73. result = node.render(context)
File "/home/rfkrocktk/Desktop/myproject/eggs/Django-1.3-py2.7.egg/django/template/loader_tags.py" in render
64. result = block.nodelist.render(context)
File "/home/rfkrocktk/Desktop/myproject/eggs/Django-1.3-py2.7.egg/django/template/base.py" in render
744. bits.append(self.render_node(node, context))
File "/home/rfkrocktk/Desktop/myproject/eggs/Django-1.3-py2.7.egg/django/template/debug.py" in render_node
73. result = node.render(context)
File "/home/rfkrocktk/Desktop/myproject/eggs/django_pipeline-1.1.22-py2.7.egg/pipeline/templatetags/compressed.py" in render
30. package['paths'] = self.packager.compile(package['paths'])
File "/home/rfkrocktk/Desktop/myproject/eggs/django_pipeline-1.1.22-py2.7.egg/pipeline/packager.py" in compile
50. return self.compiler.compile(paths)
File "/home/rfkrocktk/Desktop/myproject/eggs/django_pipeline-1.1.22-py2.7.egg/pipeline/compilers/__init__.py" in compile
25. compiled_content = compiler.compile_file(content, storage.path(path))
File "/home/rfkrocktk/Desktop/myproject/eggs/django_pipeline-1.1.22-py2.7.egg/pipeline/compilers/less/__init__.py" in compile_file
17. content = self.execute_command(command)
File "/home/rfkrocktk/Desktop/myproject/eggs/django_pipeline-1.1.22-py2.7.egg/pipeline/compilers/__init__.py" in execute_command
88. raise CompilerError(error)

Exception Type: TemplateSyntaxError at /
Exception Value: Caught CompilerError while rendering: /var/lib/gems/1.8/gems/less-2.0.7/lib/less/loader.rb:46:in `error': file 'bootstrap-1.4/bootstrap.less' wasn't found. (Less::ParseError)
from at Function.importer (/var/lib/gems/1.8/gems/less-2.0.7/lib/less/js/lib/less/index.js:114:13)
from at Object.push (/var/lib/gems/1.8/gems/less-2.0.7/lib/less/js/lib/less/parser.js:73:25)
from at Object. (/var/lib/gems/1.8/gems/less-2.0.7/lib/less/js/lib/less/tree/import.js:30:17)
from at Object.import (/var/lib/gems/1.8/gems/less-2.0.7/lib/less/js/lib/less/parser.js:953:28)
from at $ (/var/lib/gems/1.8/gems/less-2.0.7/lib/less/js/lib/less/parser.js:103:24)
from at Object.directive (/var/lib/gems/1.8/gems/less-2.0.7/lib/less/js/lib/less/parser.js:967:29)
from at $ (/var/lib/gems/1.8/gems/less-2.0.7/lib/less/js/lib/less/parser.js:103:24)
from at Object.primary (/var/lib/gems/1.8/gems/less-2.0.7/lib/less/js/lib/less/parser.js:428:80)
from at $ (/var/lib/gems/1.8/gems/less-2.0.7/lib/less/js/lib/less/parser.js:103:24)
from at Object.parse (/var/lib/gems/1.8/gems/less-2.0.7/lib/less/js/lib/less/parser.js:264:42)
from /var/lib/gems/1.8/gems/less-2.0.7/lib/less/parser.rb:65:in `parse'
from /var/lib/gems/1.8/gems/less-2.0.7/lib/less/parser.rb:13:in `calljs'
from /var/lib/gems/1.8/gems/less-2.0.7/lib/less/parser.rb:27:in `lock'
from /var/lib/gems/1.8/gems/less-2.0.7/lib/less/parser.rb:25:in `lock'
from /var/lib/gems/1.8/gems/less-2.0.7/lib/less/parser.rb:12:in `calljs'
from /var/lib/gems/1.8/gems/less-2.0.7/lib/less/parser.rb:63:in `parse'
from /var/lib/gems/1.8/gems/less-2.0.7/bin/lessc:22
from /usr/local/bin/lessc:19:in `load'
from /usr/local/bin/lessc:19