Beginners Guide to Install Discourse on macOS for Development


(Jay Pfaffman) #152

I just did a

 rake admin:create 

On a site that I just rebuilt and it didn’t work. I thought that it was due to dns propagation (which didn’t really make sense), but it might be worth a look.

It was an existing user and it seemed that the password wasn’t reset, perhaps complicated by a password reset email.

(Arpit Jalan) #153

Updated (rebuild) my sandbox to latest version and the rake admin:create task worked just fine for Admin password reset.

root@techapj-box-app:/var/www/discourse# rake admin:create
User with this email already exists! Do you want to reset the password for this email? (Y/n)
Repeat password:

Ensuring account is active!

Account updated successfully!
Do you want to grant Admin privileges to this account? (Y/n)

Your account now has Admin privileges!

The login procedure with new password worked as expected.


I managed to successfully run the install script and set up the database, but when I run bundle install I have trouble installing the hiredis gem and get this error:

An error occurred while installing hiredis (0.6.1), and Bundler cannot continue.
Make sure that `gem install hiredis -v '0.6.1' --source ''` succeeds before bundling.

In Gemfile:
Bundler::InstallError: Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: /Users/tkng/.rvm/gems/ruby-2.5.1/gems/hiredis-0.6.1/ext/hiredis_ext
/usr/local/opt/ruby/bin/ruby -r ./siteconf20180525-71098-1paoljy.rb extconf.rb
checking for sys/socket.h... yes
cc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings 1 net.c
clang: error: no such file or directory: '1'
make: *** [net.o] Error 1
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.

This is what is in the mkmf.log file:
have_header: checking for sys/socket.h... -------------------- yes

"clang -o conftest -I/usr/local/Cellar/ruby/2.5.1/include/ruby-2.5.0/x86_64-darwin17 -I/usr/local/Cellar/ruby/2.5.1/include/ruby-2.5.0/ruby/backward -I/usr/local/Cellar/ruby/2.5.1/include/ruby-2.5.0 -I.  -I/usr/local/opt/libyaml/include -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -fno-common -pipe conftest.c  -L. -L/usr/local/Cellar/ruby/2.5.1/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib     -lruby.2.5.1  -lpthread -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

"clang -E -I/usr/local/Cellar/ruby/2.5.1/include/ruby-2.5.0/x86_64-darwin17 -I/usr/local/Cellar/ruby/2.5.1/include/ruby-2.5.0/ruby/backward -I/usr/local/Cellar/ruby/2.5.1/include/ruby-2.5.0 -I.  -I/usr/local/opt/libyaml/include -I/usr/local/opt/openssl/include -I/usr/local/opt/readline/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens  -fno-common -pipe  conftest.c -o conftest.i"
checked program was:
/* begin */
1: #include "ruby.h"
3: #include <sys/socket.h>
/* end */


I was thinking it could be my version of ruby (even though it should have already been set in the script), and when i run ruby -v it does give me ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17], but rbenv local gives me 2.3.4. I’m not familiar enough with ruby/rbenv/bundle to resolve this, any help would be appreciated. Thanks in advance!

(Dmitry Demenchuk) #155

Are all tests after running bundle exec rake autospec supposed to be green, right?

Most of the tests in my case are failing.

Finished in 4 minutes 49.1 seconds (files took 20.45 seconds to load)
9504 examples, 5111 failures, 2 pending, 2 errors occurred outside of examples

Osx: 10.13.5 (17F77)
ruby: 2.5.1p57
Rails: 5.2.0
ImageMagick: 6.9.10-6
Postgres: 10
Redis: 4.0.10
Discourse: latest from git

(David Taylor) #156

This could be caused by the database schema being out-of-sync. Try running

RAILS_ENV=test bundle exec rake db:drop db:create db:migrate

again, and see if that helps

(Dmitry Demenchuk) #158

It’s a fresh install. Just created a database and migrated.

Should it be all green? or you expect some test to fail.

(Dmitry Demenchuk) #159

I tried to run RAILS_ENV=test bundle exec rake db:drop db:create db:migrate as you suggested and it helped.

Before, I was doing this:

  • bundle exec rake db:drop to drop both databases test and development.
  • bundle exec rake db:create to create both databases test and development
  • bundle exec rake db:migrate to migrate development database schema. I was expecting - ENV=development to be a default.
  • RAILS_ENV=test bundle exec rake db:migrate to migrate only ENV=test schema.

What I didn’t realise is, if ENV is empty - a task runs for both environments test and development. And I probably applied a migration twice on the test.

The confusing bit is, why did it reapply already migrated schema? Anyway, the tests are green now. Thanks!

(David Taylor) #160

Migrating multiple times shouldn’t cause an issue, so I suspect there was something else causing it.

Glad to hear it :smiley:

(Sebastian) #162

Hey guys, maybe my question is a bit silly here but it seems like i cant get it to work:
This command: RAILS_ENV=test bundle exec rake db:create db:migrate throws this one -

No connection to db, unable to retrieve site settings! (normal when running db:create)

i know it says its normal, but when i follow up with: bundle exec rake autospec i get something like that:

No connection to db, unable to retrieve site settings! (normal when running db:create)
An error occurred while loading ./spec/components/scheduler/defer_spec.rb.
Failure/Error: SeedFu.seed
  FATAL:  sorry, too many clients already

Its running endless and have to stop it with ctrl c. I dont really know where the error is, but it seems pretty hard to set it up on High Sierra.

My specs:

High Sierra 10.13.6 
ruby 2.5.1p57 
Redis server v=4.0.11 
psql (PostgreSQL) 10.5

Is there a current guide for the set up with vagrant, which is not deprecated?
I would be very grateful for quick help, because I would like to develop plug ins for discourse in the future.

running the script also throws this error, dont know if that occurs cause i run it a second time or if it is part of the issue:

imagemagick@6 6.9.10-10 is already installed and up-to-date
To reinstall 6.9.10-10, run `brew reinstall imagemagick@6`
Linking /usr/local/Cellar/imagemagick@6/6.9.10-10... 
Error: Could not symlink bin/Magick++-config
Target /usr/local/bin/Magick++-config
is a symlink belonging to imagemagick. You can unlink it:brew unlink imagemagick

(Sam Saffron) #163

Easiest thing to do here is just to use the docker based dev env.

You need ImageMagick 7 for dev and it looks like PG needs a restart on your system.

(Arpit Jalan) #164

Updated the mac script to install ImageMagick 7.

(Angus McLeod) #165

Note that you now need the latest version of the xcode-tools and gcc when running Discourse natively on macOS, otherwise the mini_racer gem will throw an error when running bundle install.

xcode-select --install
brew install gcc

See further: Cannot build macOS < 10.14 with Xcode 10? · Issue #107 · discourse/mini_racer · GitHub

(Sam Saffron) #166

Not anymore ;p

(Lucas Nicodemus) #167

Almost every step in that script helped me get most specs passing, but I needed to additionally do yarn global add svgo as per discussion here: Beginners Guide to Install Discourse on Ubuntu for Development

I don’t know if these install guides could benefit from some love, but I felt friction here for sure.

Are there docs I’m missing here or something? The vagrant guide is deprecated but I found some interesting inclinations on the docker repo specifically that indicated you could use it to boot that environment.

But I’ve searched around on meta a bit and not found a canonical “here is the docker guide you should have found” in any immediate place compared to the frequency of links to this thread and the other two OS specific setup processes.

(Jeff Atwood) #168

@sam @rishabhn we should prioritize improving our “getting started” docs here based on any incoming Hacktober :jack_o_lantern: feedback.


The guide currently lives in this repo: discourse/bin/docker/

I agree that we should surface this on Meta. Since I’ve used the docker dev setup quite extensively, I can help with this if not too urgent.

(Rishabh Nambiar) #170

Okay, I can work through incoming issues and update the Windows 10 and Ubuntu guides and @xrav3nz can do the same for the Mac guide.

Sure, even I think we should have a new Meta post for the Docker dev setup that works for all 3 OS’s.
@sam should we have a new post for it? It works flawlessly on Ubuntu.

(Sam Saffron) #171

Sure make a new dev howto on meta

The key :key: here is only having 1 source of truth, so blank out the doco in Github and link to the source of truth here

(Kankuro) #172

I’ve ran into various issues with this and can’t seem to find a working solution.

The first issue was with xcode, so I installed that again. Then I ran into an issue with zlib and installed that manually, but now I’m stuck on insufficient write permissions for /usr/bin which sudo and chown won’t allow me to bypass.

I then tried installing the packages one by one as well which results in the same issues with write permissions when I get to the bundler package.

Any ideas?

OS: macOS Mojave 10.14 (18A391)

(Blake Erickson) #176

How are you installing things manually? Just want to make sure you are using homebrew to install things.