How to fix less error while compiling bootstrap?

2019-07-24 19:38发布

问题:

Attached is a trace while compiling using grunt dist

(webmaker)Anils-MacBook-Pro:bootstrap anil$ grunt dist
Running "clean:dist" (clean) task

Running "less:compileCore" (less) task
>> ArgumentError: error evaluating function `ceil`: argument must be a number in less/variables.less on line 48, column 27:
>> 47 @font-size-base:          15px;
>> 48 @font-size-large:         ceil(@font-size-base * 1.25); // ~18px
>> 49 @font-size-small:         ceil(@font-size-base * 0.85); // ~12px
Warning: Error compiling less/bootstrap.less Use --force to continue.

Aborted due to warnings.

The grunt-contrib-less is the latest version and as can be seen, the variable @font-size-base is defined just above and it works.

A similar thread I found https://groups.google.com/forum/#!topic/brackets-dev/ZpBOFqDc3H8 but no solutions yet.

回答1:

The solution is probably to add extra parentheses to the @font-size-large and @font-size-small lines.

Before:

@font-size-large:         ceil(@font-size-base * 1.25); // ~18px
@font-size-small:         ceil(@font-size-base * 0.85); // ~12px

After:

@font-size-large:         ceil((@font-size-base * 1.25)); // ~18px
@font-size-small:         ceil((@font-size-base * 0.85)); // ~12px

I'm guessing this has happened because you, like me, changed @font-size-base, and a bad merge for some reason protected that line, but also the following two lines. (Something changed between 3.0 and 3.1 that means those lines need double parentheses--see @font-size-h1, @font-size-h2, etc.)