Skip to content

Unable to compile less file. #162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
swastkk opened this issue May 20, 2023 · 3 comments
Open

Unable to compile less file. #162

swastkk opened this issue May 20, 2023 · 3 comments

Comments

@swastkk
Copy link

swastkk commented May 20, 2023

Used the python manage.py compilestatic command to compile the card.less file which is in the static folder of django project, getting this error

(venv) [swastik@manjaro eduBOT]$ python manage.py compilestatic
Traceback (most recent call last):
  File "/home/swastik/Desktop/Projects/eduBOT/manage.py", line 22, in <module>
    main()
  File "/home/swastik/Desktop/Projects/eduBOT/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/home/swastik/Desktop/Projects/eduBOT/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/home/swastik/Desktop/Projects/eduBOT/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/swastik/Desktop/Projects/eduBOT/venv/lib/python3.10/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/swastik/Desktop/Projects/eduBOT/venv/lib/python3.10/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/home/swastik/Desktop/Projects/eduBOT/venv/lib/python3.10/site-packages/static_precompiler/management/commands/compilestatic.py", line 116, in handle
    compiled_files.add(compiler.compile(path, from_management=True, verbosity=verbosity))
  File "/home/swastik/Desktop/Projects/eduBOT/venv/lib/python3.10/site-packages/static_precompiler/compilers/base.py", line 161, in compile
    compiled_path = self.compile_file(source_path)
  File "/home/swastik/Desktop/Projects/eduBOT/venv/lib/python3.10/site-packages/static_precompiler/compilers/less.py", line 66, in compile_file
    return_code, out, errors = utils.run_command(args, cwd=cwd)
  File "/home/swastik/Desktop/Projects/eduBOT/venv/lib/python3.10/site-packages/static_precompiler/utils.py", line 66, in run_command
    p = subprocess.Popen(args, **popen_kwargs)
  File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1847, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'lessc'

Also my html was not rendering as well
Used in this manner <link rel="stylesheet" href="{% static 'card.less'|compile %}" />
Getting this in browser
image
Please help.

@swastkk
Copy link
Author

swastkk commented May 20, 2023

Now getting this error

(venv) [swastik@manjaro eduBOT]$ python manage.py compilestatic
Traceback (most recent call last):
  File "/home/swastik/Desktop/Projects/eduBOT/manage.py", line 22, in <module>
    main()
  File "/home/swastik/Desktop/Projects/eduBOT/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/home/swastik/Desktop/Projects/eduBOT/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/home/swastik/Desktop/Projects/eduBOT/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/swastik/Desktop/Projects/eduBOT/venv/lib/python3.10/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/swastik/Desktop/Projects/eduBOT/venv/lib/python3.10/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/home/swastik/Desktop/Projects/eduBOT/venv/lib/python3.10/site-packages/static_precompiler/management/commands/compilestatic.py", line 116, in handle
    compiled_files.add(compiler.compile(path, from_management=True, verbosity=verbosity))
  File "/home/swastik/Desktop/Projects/eduBOT/venv/lib/python3.10/site-packages/static_precompiler/compilers/base.py", line 161, in compile
    compiled_path = self.compile_file(source_path)
  File "/home/swastik/Desktop/Projects/eduBOT/venv/lib/python3.10/site-packages/static_precompiler/compilers/less.py", line 66, in compile_file
    return_code, out, errors = utils.run_command(args, cwd=cwd)
  File "/home/swastik/Desktop/Projects/eduBOT/venv/lib/python3.10/site-packages/static_precompiler/utils.py", line 66, in run_command
    p = subprocess.Popen(args, **popen_kwargs)
  File "/usr/lib/python3.10/subprocess.py", line 971, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1847, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/lessc'

@swastkk
Copy link
Author

swastkk commented May 20, 2023

It is compling now, but don't provide the complete CSS like colors are not showing up and other things as well.

@korverdev
Copy link

@swastkk I ran into the same issue. I believe this boils down to the location of the Less compiler changing, but I was able to work around this by setting an explicit executable setting in my settings.py:

STATIC_PRECOMPILER_COMPILERS = (
    (
        "static_precompiler.compilers.LESS",
        {
            "executable": BASE_DIR / "node_modules/less/bin/lessc",
        },
    ),
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants