Turning a Mac into a Developer Machine based on Master branch without Installer

This short instruction explains how to get your Mac OS X machine to be a development platform for Frappe and ERPNext as well as showing how to install Frappe in Developer Mode based on Master branch on Mac OS X without the beta installer.

Attention, this gives you more control about what is happening but is harder than the installer. However this is setting up a development framework rather than a quick test of frappe framework. So if you want to try out ERPNext development maybe consider the vagrantfile or the automated setup, if you want a real development machine, consider this tutorial. You are highly recommended to start with a fresh machine here unless you are a mac wizz in which case you won’t need this instruction to begin with.

Prerequisites and Things a Developer Machine should have

XCode
Copy Paste to terminal:

xcode-select --install
When that’s done agree to the license by opening xcode or by typing
sudo xcodebuild -license

Homebrew
Copy Paste to terminal:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Usage:

brew install ‘package name’
brew list # See all installed pachages
brew doctor # Fix things
brew update # Update, suggestion once a day

Brew Cask
Copy Paste to terminal:

brew tap caskroom/cask

Usage: Install Mac Os applications
brew cask install ‘app_name’

Everything Else

  1. iTerm2 (an better terminal)
    brew cask install iterm2

  2. Atom (Github free editor)
    brew cask install atom

  3. ZSH (an better bash)
    sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

  4. Install python (via brew will update the allready installed python to brew links)
    brew install python
    brew install python3

  5. GIT
    brew install git

  6. node.js (will give you access to npm)
    brew install node
    brew install npm
    (installing npm will probably already have been done by installing node)

  7. redis
    brew install redis

  8. Mariadb
    brew install mariadb
    Please run mysql_secure_installation right after to secure and set root password (mandatory)

  9. Wkhtmltopdf
    brew cask install Caskroom/cask/wkhtmltopdf

  10. Installing Virtualenvwrapper
    pip install virtualenvwrapper

  11. Adding virtualenvwrapper to your ~/.zshrc ZSH config
    atom ~/.zshrc`` then find the line plugins(probably around 52) and change it toplugins=(git virtualenvwrapper)`

  12. Install ipython
    pip install ipython
    to do magical things like running “ls” from within python.

  13. Update pip for python 2.7 and 3
    pip install --upgrade pip
    pip3 install --upgrade pip

  14. Install an archiving program (probably a good idea)
    brew cask install the-unarchiver

  15. Install emmet and terminal plus packages in atom
    Go to Atom → Preferences → Install and install emmet
    Why? https://www.youtube.com/watch?v=Ufg7OKimjfM
    Also consider adding the plugin terminal plus and enjoy turning atom into an IDE.

  16. Cleaning up brew and brew cask
    brew cleanup --force
    brew cask cleanup
    this will clean up caches and free a lot of space

Setting up Frappe Bench

  1. Set up your development folder, typically in your user folder and clone the bench-repo into it

mkdir Dev
cd Dev
git clone https://github.com/frappe/bench bench-repo

  1. Install the bench-repo

sudo pip install -e bench-repo

  1. Install the master branch of frappe-bench

bench init frappe-bench --frappe-branch master

  1. Change into the frappe-bench folder and install the master branch of ERPNext

cd frappe-bench
bench get-app erpnext https://github.com/frappe/erpnext.git --branch master

  1. Open my.cnf with Atom and make sure to add the required code

atom /usr/local/etc/my.cnf

please add:

[mysqld]
innodb-file-format=barracuda
innodb-file-per-table=1
innodb-large-prefix=1
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci

[mysql]
default-character-set = utf8mb4
  1. Make sure you have run mysql_secure_installation
    if you havent already set a root password, which is mandatory for the following steps.

  2. Make sure your mariadb server is running by mysql.server start

  3. If you have a messed up setup from previous bench it is recommended you check out if there is a DB in mariadb that should be dropped before continuing.

  4. Install a new site

bench new-site site1.local

input mysql root password when prompted as set in mysql_secure_installation
input admin user password you wish to set for website (attention! user is actually called “Administrator”)

  1. Install the erpnext app for this new site

bench install-app erpnext

  1. Enable developer mode in site_config.json

atom sites/site1.local/site_config.json

Please add "developer_mode": 1 like this, the rest stays:

{
 "db_name": "1bd3e0294d", 
 "db_password": "jfhgsdfjgh35h34j",
 "developer_mode": 1
}
  1. Update Frappe Bench

bench update

  1. Run frappe bench

bench start

  1. Open your browser and enjoy
    Navigate to URL: http://localhost:8000/#login

  2. When you are done and before you start coding please type

python -c 'import this'and carefully read it.

10 Likes

Hey, it’d be awesome if you could put this into the Bench Wiki :slight_smile:

Here we go … ENJOY!

2 Likes

First of all, thank you very much @dominik for putting up such as detailed tutorial for noob like me here,however i run into some problem…

  1. Install the bench-repo

sudo pip install -e bench-repo

  1. Install the master branch of frappe-bench

bench init frappe-bench --frappe-branch master

i get this

Successfully installed bench-3.0.0
➜ Dev bench init frappe-bench --frappe-branch master
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 9, in
load_entry_point(‘bench’, ‘console_scripts’, ‘bench’)()
File “/usr/local/lib/python3.5/site-packages/pkg_resources/init.py”, line 549, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File “/usr/local/lib/python3.5/site-packages/pkg_resources/init.py”, line 2709, in load_entry_point
return ep.load()
File “/usr/local/lib/python3.5/site-packages/pkg_resources/init.py”, line 2369, in load
return self.resolve()
File “/usr/local/lib/python3.5/site-packages/pkg_resources/init.py”, line 2375, in resolve
module = import(self.module_name, fromlist=[‘name’], level=0)
File “/Users/wks/Dev/bench-repo/bench/cli.py”, line 29
print click.Context(bench_command).get_help()
^
SyntaxError: invalid syntax

@rmehta @anand ,Sorry for dragging you guys in,any suggestions?

@Jay you seem to have an edit in the bench/cli.py file. What is the branch of bench-repo and check if git status shows any un-staged changes?

git clone GitHub - frappe/bench: CLI to manage Multi-tenant deployments for Frappe apps bench-repo

@anand haven’t touched or edit anything,this is the first time setup on mac.

➜ bench-repo git:(master) git status
On branch master
Your branch is up-to-date with ‘origin/master’.
nothing to commit, working directory clean
➜ bench-repo git:(master)

Ah yes. You have used python3!

Which OS are you using?

Check the following:
which pip
which pip-2.7

@dominik we don’t need python3!

@vjFaLk can you remove everything related to python3 and pip3 from the wiki entry?

OSX el capitan
pyhton 3 was in the guide,so …

➜ Dev which pip
/usr/local/bin/pip
➜ Dev which pip-2.7
pip-2.7 not found

Check: pip --version

➜ Dev pip --version
pip 8.1.1 from /usr/local/lib/python3.5/site-packages (python 3.5)
➜ Dev

I think the brew install python3 replaced pip - Pip3 from Python3 upgrade will break Pip from Python · Issue #25752 · Homebrew/legacy-homebrew · GitHub

Try this:
pip2 install --upgrade --force-reinstall pip

➜ Dev pip2 install --upgrade --force-reinstall pip
Collecting pip
Using cached pip-8.1.1-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 8.1.1
Uninstalling pip-8.1.1:
Successfully uninstalled pip-8.1.1
Successfully installed pip-8.1.1
➜ Dev pip --version
pip 8.1.1 from /usr/local/lib/python2.7/site-packages (python 2.7)

So now you need to run sudo pip install -e bench-repo and then try doing bench init ...

@anand thank you that solved the issue

1 Like