This is probably a newbie question but I get this error after install and setup less.

LESS error: load error: failed to find sites/all/themes/fresh_theme/css/less.less, sites/all/themes/fresh_theme/css/less.less

I'm not using omega ore some different engine, just drupal core.

I installed the module and added libraries. created a new file called less.less in fresh_theme/css folder, I added the stylesheets[all][] = example.css.less in .info

What am I doing wrong? Do I have to use Omega to use less properly?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

corey.aufang’s picture

Omega is not required at all to use the LESS module.

It looks like you have a path issue.

I used the less_demo module that is included with the LESS module to test and confirm the issue.

I was able to duplicate this by changing the relative path to the location of the .less file in the .info file.

stylesheets[all][] = styles/less_demo.info.css.less

to

stylesheets[all][] = less_demo.info.css.less

This cause the error as follows: LESS error: load error: failed to find sites/all/modules/less/less_demo/less_demo.info.css.less, sites/all/modules/less/less_demo/less_demo.info.css.less

Check to make sure that the path you have to the .less file in the .info file is relative to the root of the module/theme, which is the same folder as the .info file.

Check out the less_demo module included with the LESS module to see the correct way of referencing style sheets.

One more thing that you need to consider: When you make changes to the .info file, Drupal is not automatically aware of the changes and needs to be prompted to look again.

Follow this link for an explanation of what is required for the content of the .info file to be re-read: https://drupal.org/node/337176

RgnYLDZ’s picture

Thanks for your answer. It was a path issue like u said. I renamed and reordered my folders. Everything works fine now.

corey.aufang’s picture

Status: Active » Fixed
Countzero’s picture

Status: Fixed » Active

Sorry to re-open, but I have the exact same problem, with a Bootstrap installation.

I created a subtheme and placed the files like this :

basedir
basedir/base.info
basedir/less
basedir/less/style.less

and in the .info :
stylesheets[all][] = less/style.less

It seems OK to me (and in fact is in other subthemes on other sites). Everything seems to work OK, but now and then I get the error message :

LESS error: load error: failed to find http://xxxx/sites/all/themes/basedir/less/style.less, http://xxxx/sites/all/themes/basedir/less/style.less

It's not on every page and I have a hard time telling what are the conditions which trigger the message.

Any idea ?

RgnYLDZ’s picture

If you're sure that your path is right, do a Flush less files in admin/config/development/less.

Maby it will help.

If not check via firebug/chrome dev tools(F12) for errors. That can give you a hint about the problem.

Countzero’s picture

Did the flush several times to no avail.

No errors in Firebug (Console or Network tab).

Thanks for your input anyway.

Countzero’s picture

Still can't find where the problem is, and my deadline is coming. I'd be really pleased to have any hint on this.

corey.aufang’s picture

The only thing I would try is changing the file extension from '.less' to '.css.less'.

It shouldn't cause any differences, but its possible that there is a error with my handler code.

Wait, you're saying its not on every page?

Clear your browser cache, or disable caching in your browser through the dev tools.

Its possible that the page is being cached, error and all, in your browser so that you continue to see it.

Sometimes I've also had error messages get stuck in the session for the user, so clear your cookies for the domain you're using as well.

If you're still having issues, hit my contact form on my user profile here on drupal.org and I'll see what I can help you with.

malfist’s picture

I've noticed this happens when using wysiwyg and setting it to use "theme css" with less enabled.

Countzero’s picture

Stumbled on this problem on an entirely different project (different server, codebase, etc.).

I think that maybe it comes up when Bootstrap is defined as Admin theme, but the error is so erratic it's very difficult to tell.

malfist’s picture

Discovered my issue was adding less files with a file ending of css, converting these to less files fixed the issue.

irowboat’s picture

@Countzero did you ever get this resolved?

Seeing this issue also with Bootstrap theme. Some but not all page loads raise an error.

I'm using Bootstrap as admin theme. LESS developer mode on/off doesn't seem to have an effect. The LESS file isn't supposedly found, though the link on the logged error message works.

Countzero’s picture

Nope, never found a solution, and I'm sad to see the latest versions didn't solve this.

It only appears for the admin-ish roles though, if I remember correctly.

gunwald’s picture

I have the same problem using LESS with bootstrap. The odd thing is, that it does not occur on every page and that everything seems to work well.

LESS error: File `http://www.example.com/sites/all/themes/bootstrap_mysite/less/style.less` not found., http://www.example.com/sites/all/themes/bootstrap_mysite/less/style.less

Flushing cashes does not help and it occurs for admin and normal users. Could not find any hint, where this comes from.

corey.aufang’s picture

@gunwald Are you using bootstrap as your Admin Theme?

gunwald’s picture

No, I'm not. But I am using it as standard theme. That means, using the admin overlay, sometimes both themes are loaded: Standard admin theme for the admin overlay and bootstrap for the normal pages (behind the admin overlay). So I cant tell which one is causing the errors.

corey.aufang’s picture

When the admin is loaded through the overlay, it's actually being loaded in a transparent iframe so there shouldn't be any interference between the two.

Since you're not using bootstrap as an admin theme, it must mean that the problem lies elsewhere.

Are you using 7.x-4.0 of the Less module?

gunwald’s picture

Yes, I am using 7.x-4.0 of the Less module.

argiope’s picture

I'm getting this issue only on pages that have the WYSIWYG editor on them. It looks like some of the stylesheets attaches are not relative to drupal root but have the full url prepended. I ended up adding the if statement after line 36 of the less.wysiwyg.inc file and it cleared it up there is probably more going on there though.

    foreach ($stylesheets as $stylesheet) {
      if (!preg_match('/^http/', $stylesheet)) {
        $styles['#items'][$stylesheet] = array(
          // Paths are expected to be relative to DRUPAL_ROOT.
          'data' => trim($stylesheet, '/'),
        );
      }
    }
corey.aufang’s picture

@argiope It appears that you are using the 7.x-3.x version of the module. Your issue should be resolved in the 7.x-4.0 release.

The related code has been changed to the following, which should remove any URL css path issues:


foreach ($stylesheets as $stylesheet) {

  // Might contain ?query portion, separate parts.
  $parts = drupal_parse_url($stylesheet);

  // Paths are expected to be relative to DRUPAL_ROOT, trim leading '/'.
  $path = trim($parts['path'], '/');

  $styles['#items'][$path] = array(
    'data' => $path,
  );
}


argiope’s picture

Oh oops your right I am.

argiope’s picture

Even in version 4.0 I'm still getting these errors on edit pages.
I have to strip out the $base_url from the path for these to disappear.

<?php
    foreach ($stylesheets as $stylesheet) {

      // Might contain ?query portion, separate parts.
      $parts = drupal_parse_url($stylesheet);

      // Paths are expected to be relative to DRUPAL_ROOT, trim leading '/' and base url.
      $path = str_replace($base_url, '', $parts['path']);
      $path = trim($path, '/');
      $styles['#items'][$path] = array(
        'data' => $path,
      );
    }
?>
argiope’s picture

adding a patch for the dev branch

medhatayar’s picture

Updated less module:
1. Paste less module in module folder (online path: 7.x-4.0 https://www.drupal.org/project/less )
2. Paste libraries in /sites/all/libraries folder. Rename folder name to lessphp so that path will be /sites/all/libraries/lessphp. ( online library path:
https://github.com/oyejorge/less.php#transitioning-from-leafolessphp )
3. Enable module.
4. Flush all cache.
5. If you find error: LESS error: load error: failed to find sites/all/themes/fresh_theme/css/less.less, sites/all/themes/fresh_theme/css/less.less
- Open \sites\all\modules\contrib\less\less_demo\less_demo.info file
- cut stylesheets[all][] = styles/less_demo.info.css.less and paste below less[sheets][] = styles/less_demo.drupal_add_css.css.less
- Flush all cache.
6. click on configurations of LESS CSS Preprocessor (less) module
7. This will take you to /admin/config/development/less
8. Select following less engine
- less.php - http://lessphp.gpeasy.com/
9. Flush all cache
10. Done

gmaltoni’s picture

Component: Documentation » Code
Status: Active » Needs review
Issue tags: +#ciandt-contrib
FileSize
536 bytes

@medhatayar,

Your solution solved my less loading problem (module version: 7.x-3.0).
I created a patch for this.

Best regards.

Status: Needs review » Needs work

The last submitted patch, 25: fixing_less_load_error-2214125-25.patch, failed testing.

gmaltoni’s picture

Status: Needs work » Needs review

Analyzing the build error, I found the following message:

14:40:31 ERROR: No valid tests were specified.

The code didn't cause this problem. The module has already been tested with the patch applied.

The last submitted patch, 23: less-less-load-error-2214125-22.patch, failed testing.