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: