Notes for Discourse Development on macOS Catalina
Ruby Gems & Catalina
macOS Catalina runs on a dedicated, read-only system volume and so we cannot install various Ruby binaries in the /usr/bin directory. One good solution to this is to change your environmental variables as follows (using your own home directory, of course):
export GEM_HOME=/Users/Tim/bin
export GEM_PATH=/Users/Tim/bin
You also need to make sure you are running rbenv
so it is a good idea to run this before running bundle install
rbenv init
export PATH=~/.rbenv/shims:$PATH
This should solve most of the problems with Ruby gems for Discourse on macOS, and you should be able to run bundle install
.
However, this often fails regarding cppjieba_rb
so you might need to manually install cppjieba_rb
.
See Also NoBugsBunny post #15 here:
Gem Documents
You might save yourself a lot of time by instructing gem not to download any gem docs:
You just add the following line to your local ~/.gemrc
file before installing gems manually
or running bundle install
.
gem: --no-document
If that does not work for any reason, you can append --no-document
to any gem instruction, like so:
gem install <gemname> --no-document
Real world example:
gem install cppjieba_rb -v '0.3.3' --source 'https://rubygems.org/ --no-document'
After you get all your gems figured out and discourse is installed, you may need to manually start unicorn and the rails server:
bundle exec rails server
bundle exec unicorn
It is good to run both of the commands in two different terminal windows so you can see what is going on all the time with unicorn and rails.
I recommend you append this to your shell start resource file, something like this in your .bashrc
file (quick example only):
$ cat /Users/Tim/.bashrc
export GEM_HOME=/Users/Tim/bin
export GEM_PATH=/Users/Tim/bin
export RAILS_ENV=development
# load rbenv
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init - --no-rehash)"
Reference Document:
If you have any issues, please let me know as I am currently fully setup on macOS Catalina for Discourse plugin development. In fact, I used the macOS dev setup to fix a bug in my first Discourse plugin this morning: