1

I recently upgraded from the community edition 2.4.6 to 2.4.8.

Since updating, when running bin/magento setup:static-content:deploy I'm getting the following LESS compilation errors

Compilation from source: /vendor/magento/theme-frontend-blank/web/css/styles-l.less
error evaluating function `unit` The first argument to unit must be a number. Have you forgotten parenthesis? index: 488 in _typography.less on line 35, column 1
33| @font-size-unit-convert: true; // Controls whether font-size values are conv
erted to the specified font-size unit
34|
35| @font-size__base: unit(@font-size-unit-ratio * @font-size-ratio__base, px);
// Base font size value in <b>px</b>
36| @font-size__xl: ceil(1.5 * @font-size__base); // 21px
37| @font-size__l: ceil(1.25 * @font-size__base); // 18px
38| @font-size__s: ceil(.85 * @font-size__base); // 12px

I have tried:

  • Amending the parenthesis e.g. @font-size__base: unit(@font-size-unit-ratio * @font-size-ratio__base, px); to @font-size__base: unit((@font-size-unit-ratio * @font-size-ratio__base), px);
  • Tested the code standalone to see if a standard LESS compiler would error, and everything works and is calculated correctly.
  • Also, when using Grunt to compile the LESS files, it completes without error.

Since Grunt compiles it correctly, I'm wondering if this is due to the change to the required composer package wikimedia/less.php as this same setup worked fine before the upgrade.

asked Apr 24 at 16:27
2
  • I am facing the same issue from Magento 2.4.7-p4 to Magento 2.4.8 ``` error evaluating function unit The first argument to unit must be a number. Have you forgotten parenthesis? index: 1088 in _typography.less on line 32, column 1 30| 31| @font-size-unit: rem; // The unit to which most typography values will be converted by default 32| @font-size-unit-ratio: unit(@root__font-size * 16/100); // Ratio of the root font-size to the font-size unit 33| @font-size-unit-convert: true; // Controls whether font-size values are converted to the specified font-size unit 34| 35| @font-size__base: unit(@f Commented May 9 at 13:55
  • I am also getting the same issue. Deploy using quick strategy frontend/Magento/blank/en_AU 631/2063 ========>------------------- 30% 1 sec Compilation from source: /var/www/magento_current/lib/web/mage/gallery/gallery.less error evaluating function unit The first argument to unit must be a number. Have you forgotten parenthesis? index: 1085 in _typography.less on line 32, column 1 30| 31| @font-size-unit: rem; // The unit to which most typography values will be converted by default 32| @font-size-unit-ratio: unit(@root__font-size * 16/100); // Ratio of the root font-size to the font-size uni Commented May 20 at 10:45

1 Answer 1

0
35| @font-size__base: unit((@font-size-unit-ratio * @font-size-ratio__base), px);
// Base font size value in <b>px</b>
36| @font-size__xl: ceil((1.5 * @font-size__base)); // 21px
37| @font-size__l: ceil((1.25 * @font-size__base)); // 18px
38| @font-size__s: ceil((.85 * @font-size__base)); // 12px

Try enclose your math operations to a () as shown above.

Sumit
5,0482 gold badges22 silver badges36 bronze badges
answered Jul 29 at 3:05
2
  • Unfortunately this does not work. As I put in my original question, this was the first thing that was tried Amending the parenthesis e.g. @font-size__base: unit(@font-size-unit-ratio * @font-size-ratio__base, px); to @font-size__base: unit((@font-size-unit-ratio * @font-size-ratio__base), px); Commented Jul 30 at 8:16
  • Sorry it didn't help. I assume you have cleared the static and var/view_processed files befor running static-content deploy again? This solution works on my end and it took me a lifetime identifying this errors. Commented Aug 4 at 3:47

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.