The I had an increasingly frustrating/disastrous/whatever circle of upgrade attempts with Frappé and ERPNext with (default, as it seems) develop branch in production mode. Everything went fine initially, with some frappe_io code to be overwritten using bench upgrade --reset. All went well for about two weeks till yesterday, when a proposed database migration (I guess) did not work.
Background: I am not using the single-minded install script, run ERPNext in its virtual environment as non-privileged user in a FreeBSD jail. I only noted recently that the default branch is develop - ouch! I do definitely do not want this in a production environment.
This, and the aforesaid erratic issues with the develop branch (fair enough: it is the develop branch!), have let me to the following installation procedure (which worked with the develop branch, save for the git-specific instructions to go for the master branch):
Create Users and Groups for the ERPNext Instance
Enter the jail, and create a non-privileged user for each ERPNext instance with correct locales for Python3 as follows:
ezjail-admin console [jail name]
setenv APP frappe
setenv ENVIRONMENT [prd]
setenv INSTANCE ${APP}_${ENVIRONMENT}
setenv INSTANCE_UID_GID [3600]
pw groupadd ${INSTANCE} -g ${INSTANCE_UID_GID}
pw useradd -c "${INSTANCE} user" -d /usr/local/${INSTANCE} -n ${INSTANCE} -s /bin/csh -u ${INSTANCE_UID_GID} -w no
echo 'setenv LC_ALL en_US.UTF-8' > /usr/local/${INSTANCE}/.cshrc
echo 'setenv LANG en_US.UTF-8' >> /usr/local/${INSTANCE}/.cshrc
passwd ${INSTANCE}
Replace placeholders in [brackets] with their appropriate values.
Enter the new instance user password as required.
Give the [instance] user access to cron by issuing the following as root from within the jail:
echo “${INSTANCE}” >> /var/cron/cron.allow
/etc/rc.d/cron restart
Install Frappé Bench in a Virtual Environment
Issue the following as root for each ERPNext instance from within the jail:
setenv APP frappe
setenv ENVIRONMENT [prd]
setenv INSTANCE ${APP}${ENVIRONMENT}
Replace placeholders in [brackets] with their appropriate values. The database and user name [app][site_id][environment] must not exceed 16 letters, or MariaDB will throw an error.
cd /usr/local
virtualenv --system-site-packages ${INSTANCE}
chown -R ${INSTANCE}:www /usr/local/${INSTANCE}
chmod -R o-rwx /usr/local/${INSTANCE}
cd /usr/local/${INSTANCE}
su - ${INSTANCE}
setenv APP frappe
setenv ENVIRONMENT [prd]
setenv INSTANCE ${APP}${ENVIRONMENT}
source bin/activate.csh
rm -rf /usr/local/${INSTANCE}/.cache/pip
rm -rf /usr/local/${INSTANCE}/.cache/yarn
pip install --global-option=build_ext --global-option=“-I/usr/local/include/” --global-option=“-L/usr/local/lib” python-ldap
git clone GitHub - frappe/bench: CLI to manage Multi-tenant deployments for Frappe apps bench-repo
pip install -e bench-repo
deactivate
exit
chown -R ${INSTANCE}:www /usr/local/${INSTANCE}
chmod -R o-rwx /usr/local/${INSTANCE}
rm -rf /usr/local/${INSTANCE}/.cache/pip
rm -rf /usr/local/${INSTANCE}/.cache/yarn
cd /usr/local/${INSTANCE}
su - ${INSTANCE}
setenv APP frappe
setenv ENVIRONMENT [prd]
setenv INSTANCE ${APP}_${ENVIRONMENT}
setenv SITE_ID [organisation acronym]
setenv VIRTUAL_DOMAIN [my.domain]
setenv SUBDOMAIN erpnext
source bin/activate.csh
bench init frappe-bench
cd frappe-bench
bench switch-to-master
bench update --patch
Replace placeholders in [brackets] with their appropriate values.
Due to a bug in ERPNext master, we still have to install a few npm packages manually. Issue the following:
cd /usr/local/${INSTANCE}/frappe-bench
npm install babel-core chokidar less babel-preset-es2015 babel-preset-es2016 babel-preset-es2017 babel-preset-babili
Provide database server details:
cd /usr/local/${INSTANCE}/frappe-bench
bench set-mariadb-host mysql.jail.vlan
Install ERPNext to a New Site
In a second window, enter the strong textjail and issue the following as root from within:
ezjail-admin console www_py
setenv APP frappe
setenv ENVIRONMENT [prd]
setenv INSTANCE ${APP}_${ENVIRONMENT}
su - ${INSTANCE}
source bin/activate.csh
cd frappe-bench
setenv LC_ALL en_US.UTF-8
setenv LANG en_US.UTF-8
bench start
Replace placeholders in [brackets] with their appropriate values.
Back in the first window, create a new site [subdomain].[virtual.domain] within Frappe:
bench new-site --db-name ${APP}_${SITE_ID}_${ENVIRONMENT} --force --verbose ${SUBDOMAIN}.${VIRTUAL_DOMAIN}
Provide the MariaDB root password as prompted.
Set administrator password as prompted.
Get the ERPNext application and install it into the newly created site:
bench get-app --branch master erpnext GitHub - frappe/erpnext: Free and Open Source Enterprise Resource Planning (ERP)
bench --site ${SUBDOMAIN}.${VIRTUAL_DOMAIN} install-app erpnext
rm -rf /usr/local/${INSTANCE}/.cache/pip
rm -rf /usr/local/${INSTANCE}/.cache/yarn
Make sure Frappé is running in the second window during the above commands.
Close the second window.
bench get-app --branch master erpnext https://github.com/frappe/erpnext fails with:
ReferenceError: Unknown plugin “transform-object-rest-spread” specified in “base” at 0, attempted to resolve relative to “/usr/local/frappe_prd/frappe-bench/sites”
at /usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/options/option-manager.js:180:17
at Array.map ()
at Function.normalisePlugins (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
at OptionManager.mergeOptions (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
at OptionManager.init (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
at File.initOptions (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/index.js:212:65)
at new File (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/index.js:135:24)
at Pipeline.transform (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
at babelify (/usr/local/frappe_prd/frappe-bench/apps/frappe/frappe/build.js:161:16)
at get_compiled_file (/usr/local/frappe_prd/frappe-bench/apps/frappe/frappe/build.js:148:18)
Cannot babelify /usr/local/frappe_prd/frappe-bench/apps/erpnext/erpnext/public/js/agriculture/ternary_plot.js
ReferenceError: Unknown plugin “transform-object-rest-spread” specified in “base” at 0, attempted to resolve relative to “/usr/local/frappe_prd/frappe-bench/sites”
at /usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/options/option-manager.js:180:17
at Array.map ()
at Function.normalisePlugins (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
at OptionManager.mergeOptions (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
at OptionManager.init (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
at File.initOptions (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/index.js:212:65)
at new File (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/index.js:135:24)
at Pipeline.transform (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
at babelify (/usr/local/frappe_prd/frappe-bench/apps/frappe/frappe/build.js:161:16)
at get_compiled_file (/usr/local/frappe_prd/frappe-bench/apps/frappe/frappe/build.js:148:18)
Cannot babelify /usr/local/frappe_prd/frappe-bench/apps/erpnext/erpnext/public/js/utils/item_quick_entry.js
ReferenceError: Unknown plugin “transform-object-rest-spread” specified in “base” at 0, attempted to resolve relative to “/usr/local/frappe_prd/frappe-bench/sites”
at /usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/options/option-manager.js:180:17
at Array.map ()
at Function.normalisePlugins (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
at OptionManager.mergeOptions (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
at OptionManager.init (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
at File.initOptions (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/index.js:212:65)
at new File (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/index.js:135:24)
at Pipeline.transform (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
at babelify (/usr/local/frappe_prd/frappe-bench/apps/frappe/frappe/build.js:161:16)
at get_compiled_file (/usr/local/frappe_prd/frappe-bench/apps/frappe/frappe/build.js:148:18)
Cannot babelify /usr/local/frappe_prd/frappe-bench/apps/erpnext/erpnext/public/js/utils/customer_quick_entry.js
ReferenceError: Unknown plugin “transform-object-rest-spread” specified in “base” at 0, attempted to resolve relative to “/usr/local/frappe_prd/frappe-bench/sites”
at /usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/options/option-manager.js:180:17
at Array.map ()
at Function.normalisePlugins (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
at OptionManager.mergeOptions (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
at OptionManager.init (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
at File.initOptions (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/index.js:212:65)
at new File (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/index.js:135:24)
at Pipeline.transform (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
at babelify (/usr/local/frappe_prd/frappe-bench/apps/frappe/frappe/build.js:161:16)
at get_compiled_file (/usr/local/frappe_prd/frappe-bench/apps/frappe/frappe/build.js:148:18)
Wrote js/erpnext.min.js - 168.1 KB
Cannot babelify /usr/local/frappe_prd/frappe-bench/apps/erpnext/erpnext/stock/dashboard/item_dashboard.js
ReferenceError: Unknown plugin “transform-object-rest-spread” specified in “base” at 0, attempted to resolve relative to “/usr/local/frappe_prd/frappe-bench/sites”
at /usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/options/option-manager.js:180:17
at Array.map ()
at Function.normalisePlugins (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
at OptionManager.mergeOptions (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
at OptionManager.init (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
at File.initOptions (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/index.js:212:65)
at new File (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/file/index.js:135:24)
at Pipeline.transform (/usr/local/frappe_prd/frappe-bench/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
at babelify (/usr/local/frappe_prd/frappe-bench/apps/frappe/frappe/build.js:161:16)
at get_compiled_file (/usr/local/frappe_prd/frappe-bench/apps/frappe/frappe/build.js:148:18)
Wrote js/item-dashboard.min.js - 8.2 KB
I am therefore stuck with a clean install procedure off the master branch, which should be stable.
I feel that although there is a treasure trove of good tips within the forum, there is no standard operating procedure for a decent setup mode (master or branch | production or develop), while the code advances very quickly. This is, as I have said many times before, not good for a both complex and involving piece of software as ERPNext.
The above is an attempt to tame this issue (and forgetting the rather limited install script, which does not float in my BSD jail environment).
Any thoughts on how to fix the above issue? This is the fourth time I have a - IMHO quite professional go at ERPNext - but I am about to give up - again. Pity!
Chris