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.