Beginners Guide to Install Discourse on macOS for Development

Hi!

How i can install plugins without docker? I add git link to app.yml file, but don’t work command ./launcher rebuild app

Thank’s!

EDIT: In my case, trying to get this running on Mac Catalina has led to a number of issues.

This seems to have been the key for me:

For Mac OS, if people are having problems, this is an important solution to run after running the bash command in the original post. I recommend these commands be included in the original post.

With that upgrade, I was able to get bundle exec rails server to work and get Discourse running on my local host. (Still haven’t gotten bundle exec rake autospec to work however).

I also had to install Mailcatcher to set up email functionality, so I ran:

sudo gem install mailcatcher

In case helpful to others, I’ll leave in my earlier notes of errors and fixes I encountered (note these were prior to running the brew update postgres command I quoted above).

On Mac OS Catalina (10.15.4), I got the following errors, and fixed them with the following steps:


After running the steps in the original post, including these:
cd ~/discourse
bundle install

I got this error:
Error loading RubyGems plugin "/Users/.../.rvm/gems/ruby-2.3.0@global/gems/executable-hooks-1.3.2/lib/rubygems_plugin.rb":
dlopen(/Users/.../.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/openssl.bundle, 9):
Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib

Referenced from: /Users/.../.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/openssl.bundle
  
Reason: image not found - /Users/s.../.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/x86_64-darwin15/openssl.bundle (LoadError)

To fix:
Followed advice from here

brew uninstall postgres
brew install postgres

gem uninstall pg
bundle install

Then I got the error:
Symbol not found: _SSLv3_client_method

To fix I followed the advice here to update my ruby version:

rvm --default 'ruby-version'


Got a traceback message:
Could not find 'bundler' (2.1.4) required by your /Users/.../discourse/Gemfile.lock. (Gem::GemNotFoundException)

Ran:
gem install bundler:2.1.4

2 Likes

Here ya go @Varhall

/var/discourse/launcher enter app
cd plugins
git clone "URL of your favorite plugin"

plugin (basically) installed …

Hope this helps…

3 Likes

I have a discourse instance running without error locally on my Mac (with Catalina)–I recently followed the above instructions, so AFAIK everything is the most recent version. But the app runs slow. It can take 10 to 15 seconds to start up initially with bundle exec rails server, and then often if I make changes and reload it takes an additional 10 seconds.

This may be an issue with my local machine, but I haven’t experienced slow performance running other (non-discourse/non-rails) apps locally.

Are there any ways that people have found helpful for speeding up discourse running locally?

3 Likes

How much RAM and what CPU are you running?

1 Like

That’s probably a big part of the issue. Ram is 4GB and processor is 1.3 GHz Dual-Core Intel Core i5.

I’m sure if my computer had more RAM and power that would help. The reason I asked, though, is that, like I said, when running other apps locally I have not experienced the issue. Though that could also be bc the Discourse instance is fairly large.

Still, was hoping there might be ways of speeding things up.

BTW, here is a related question: Do you need to be running the Redis server locally to run the local Discourse instance? In my experience, the answer is yes–I have to run redis-server prior to starting the app with bundle exec rails server in order for it to run (otherwise it gives me errors about the Redis server not running). But I did not see mention of this in the original post.

2 Likes

The OP includes redis in the list of things installed

I think my collegue @merefield has an interesting remote setup with removes the burden off your system for a couple bucks a month.

1 Like

Actually it’s a bit more than a couple of bucks (it’s a 4GB 8 core VPS - probably overkill) but allows me to develop from anywhere on any platform. Pretty performant but there will always be a few seconds delay if you restart the web server.

4 Likes

For me to have the app work locally, I don’t just need Redis installed, I need it actively running (using command redis-server)

For now I’m moving off using the local instance for testing–it’s just too slow on my computer, and also is too inefficient bc it’s basically a separate app from the live app I care about, meaning it has separate API keys, users, etc.

Instead, I’m testing on my live site using the following:

  1. Create a theme, add it to my app, and watch it–using the very cool theme cli
  2. But don’t activate the theme during testing. Rather, view the results of the theme using the Preview button on the theme dashboard.
  3. Once the theme is fully tested, activate on the app.
  4. Create a new version of the theme for testing additional changes from there, and repeat steps 1-3.

That’s my current method. Happy to hear if anyone else has suggestions for how to test out changes to your app before pushing them live (other than testing locally).

Yes, you need to have redis running. Why install it if it doesn’t need to run?

If you are not developing plugins, then, as you suggest, you don’t need a development environment, production is easier and faster

1 Like

Is there a way to test a plugin on a real site without pushing it live? (similar to how you can test a theme by hitting the “Preview” button on the admin dashboard)

No unfortunately there is not. It has to be “live” on the site, whether a development, staging or production install. That’s because it loads Rails code that needs to be present at app boot.

4 Likes

Hmm. It seems that ./bin/unicorn works once, but if I ^C and then start it again, it doesn’t crank up and nothing is answering port 3000. Then I do a ./bin/rails s and it works again.

Is there some secret to how to restart?

Is this reproducible after a clean boot? May be a bug in MacOS? Did you upgrade to Big Sur (you will probably end up with different bugs … but who knows)

Oh. Sorry, I hadn’t realized this was in the MacOS topic. I’m Ubuntu, but I’d guess that the unicorn vs rails -s recommendation recommendation would be the same. I rebooted a few days ago because there was a power outage and I hadn’t rebooted since I got the UPS. I’ll give it another go in the next day or two.

1 Like

OK, so I’m at it again. And this time, looking at the logs from ./bin/unicorn I see that it’s binding to port 9292, which explains why I couldn’t find it at 3000.

I also tried ./bin/unicorn -l 0.0.0.0 -p 3000, but it failed trying to bind to port 80. Looking at unicorn(1) — unicorn — Debian testing — Debian Manpages suggests that -p 3000 should adjust the port.

Just a quick macOS Rails dev note.

Because of the various roadblocks and system security issues regarding macOS Catalina and above, I have found it best to bundle like this:

bundle install --path vendor/bundle

Since I started bundle’ing with the path switch above, getting all my Rails development apps up and running on macOS has been much easier, including Discourse.

1 Like

Finally!

I have a complete copy of our production server (DB and all uploads) running on macOS in the dev environment on my desktop, yay!


For some of the postgres production to dev DB migration details, see:

6 Likes

When trying to run bundle exec rake db:migrate I’m getting the following error:

dyld: Symbol not found: __ZN2v82V813InitializeICUEPKc
  Referenced from: /Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/mini_racer-0.3.1/lib/mini_racer_extension.bundle
  Expected in: flat namespace

I’ve tried uninstalling and reinstalling mini_racer with no luck. Any thoughts? Running on Big Sur.

Edit: Actually the original error I was getting was:

briansawicki@Brians-MacBook-Air-2 discourse % bin/bundle exec rails db:migrate
rails aborted!
LoadError: cannot load such file -- mini_racer
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:89:in `register'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:324:in `block in require'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:291:in `load_dependency'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:324:in `require'
/Users/briansawicki/git/discourse/lib/discourse_js_processor.rb:3:in `<main>'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:324:in `block in require'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:291:in `load_dependency'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/activesupport-6.0.3.5/lib/active_support/dependencies.rb:324:in `require'
/Users/briansawicki/git/discourse/config/application.rb:265:in `<class:Application>'
/Users/briansawicki/git/discourse/config/application.rb:73:in `<module:Discourse>'
/Users/briansawicki/git/discourse/config/application.rb:72:in `<main>'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
/Users/briansawicki/git/discourse/Rakefile:7:in `<main>'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:59:in `load'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/commands/rake/rake_command.rb:22:in `block in perform'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/command.rb:48:in `invoke'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/railties-6.0.3.5/lib/rails/commands.rb:18:in `<main>'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
/Users/briansawicki/git/discourse/vendor/bundle/ruby/2.7.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
bin/rails:17:in `<main>'
(See full trace by running task with --trace)

I got it past that but clearly something is still wrong so I wanted to point to the original error.

Edit 2: I am running on an M1 chip machine

1 Like