Compile Less in Production?

I’ve been working on a dev machine, and following the structure of the erpNext app, I created a folder under public called less, added all my less files to that directory and then updated my build.json to reflect the files.

On the dev box, every-time I update and save the less files, they get compiled to valid CSS. However, I just built a production box, installed my app, and the Less files, are being updated in the CSS folder, but they are not being compiled to CSS. Its just the less code. I tried to do a “bench build” and “bench clear-cache” but the files are staying as less files.

Is there a command I am suppose to execute on production, to get the less files to compile and ready to serve?

try “bench restart” to see if it works

Im logged in as root, and trying to run ‘bench restart’ and it is prompting me for a sudo password for frappe.

If I’m root, and its prompting me for sudo password for frappe, do I need to create a password and add Frappe to the sudoers?

Im confused on how production is suppose to run. I assumed, when I installed my app, upon bench build or restart of the server all the files would be/get built.

Yes the recommended way to install and run ERPNext is from a non-root user account such as frappe that has been assigned sudo privileges.

So using the easy install:

I used this command: sudo python --production

after the install finishes, I need to set a password for “frappe” and then add “frappe” to the sudoers list?

Yes then from the frappe user account, access and run ERPNext from this directory /home/frappe/frappe-bench via bench commands for eg ‘bench --help’

Disable root access at the 1st instance. Create new user frappe and use it as su for any update. Follow this guide to create new sudo user.

Thank you for the replies. I will rebuild tonight and report back.

I rebuilt my droplet at DigitalOceans and proceeded with the suggestions above. I forgot to mention I’m using Ubuntu 16.04.4 x64 (DigitalOceans stock image)

Revoked SSH login for root
Created a user frappe
added user frappe to sudoers
executed su frappe
then cd ~

I proceeded with the easy install script and all went well. Created my new site. Installed my custom app and, same result :disappointed_relieved:

I tried bench restart and even tried to reboot the server. All that shows in my apps stylesheet is LESS code. I went to my terminal on the production server and typed:

frappe@erp:~/frappe-bench$ less
Missing filename ("less --help" for help)

So apparently LESS compiler is installed.

The only odd or error message I see when I install my app is:

/home/frappe/frappe-bench/apps/frappe/frappe/ UserWarning: Source /home/frappe/frappe-bench/apps/custom_styles/custom_styles/docs does not exists.

Does the above Warning have anything to do with LESS compiling?

Since LESS ‘less’ is a unix command to view a file, I don’t see a relation.

The error message you indicate, is a UserWarning and not an error per se. So there must be another error message somewhere indicated. You need to review all messages.

Learned a new Unix command today at least :slight_smile:

I’ll try and see if I can find any other errors. Thank you.

Still can not find any errors… So the quick work around, is after I install the app in production, and it goes through the process of installing and compiling the JS and LESS, I go back to my app in the apps directory and do a git reset (since the LESS code has been placed in the CSS Directory), and a git pull and it syncs back the CSS files in the CSS folder that was compiled on the DEV box and submitted to teh repo.

This is a quick fix, of course, I have to worry about at some point the LESS getting rebuilt at any time if I have to run certain bench commands.

So as of now, the production app/site mirrors DEV, but only due to the stated above band aid.

Can anyone steer me in the direction of a place to start looking. I’ve grep’d the frappe_bech/logs directory for errors and only errors I see are related to:


Which I’m assuming/guessing is not related, and will revisit that error after this css issue is resolved.

What compiler is used to compile less into CSS?

I tried bench - help from the directory /home/ frappe/frappe-bench and i get error . any solution ? thank you

Welcome to ERPNext -

To run ‘bench’ with no arguments you should see this response:

frappe@ubuntu:~/frappe-bench$ bench
Usage: bench [OPTIONS] COMMAND [ARGS]…

Bench manager for Frappe

–help Show this message and exit.

backup backup site
backup-all-sites backup all sites

Instead you get the DistributionNotFound GitPython error so best to resolve that missing package problem.

What do you get for this:

frappe@ubuntu:~/frappe-bench$ pip show gitpython
Name: GitPython
Summary: Python Git Library

A search turned up this that may help you with pointers Error updating to V7 (Solved) - #3 by gvargas

Please include what install instructions you followed and what OS you are running…

You have posted the same error here Run bench in Production - #4 by sagar