Beginners Guide to Install Discourse on macOS for Development

dev-install

(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
PG::ConnectionBad:
  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.


#169

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

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.


(Kankuro) #177

Yea I’m using homebrew.

I just tried another go at it and am stuck at installing rails. Below is the error I’m receiving.

ERROR:  Error installing rails:
	ERROR: Failed to build gem native extension.

    /Users/{hidden}/.rbenv/versions/2.5.1/bin/ruby extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
Using mini_portile version 2.3.0
checking for iconv.h... yes
checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** 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.

Looking around the web didn’t give me any luck, I’ve tried updating --system but that resulted in the same type of issue.


(Blake Erickson) #178

I think this is a new Mojave thing that zlib is missing. Can you try this:

sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

which is from a new answer on this question:


(Kankuro) #179

That resulted in this error:

installer: Error - the package path specified was invalid: '/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg'.

EDIT: I may have found the issue by reinstalling xcode-select. I will report back in a bit.


(Kankuro) #180

Still no luck, resulting in the same errors as mentioned above.

That package above installed properly, but it’s still saying that zlib is missing when trying to install Raile sudo gem install rails and giving that undefined method 'source_paths' error when running sudo gem update --system

EDIT: Also when doing the full package install it gets stuck on updating rubygems and spits out this error

ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied @ rb_sysopen - /Users/{hidden}/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/rubygems-update-2.7.7/.autotest
failed

(Sam Saffron) #181

Looks like you have a permission issue in your .rbenv dir, maybe you ran sudo bundle install instead of bundle install. Maybe nuke your rbenv and start from scratch or sudo chown the directory.


(Kankuro) #182

I ended up just doing this through Docker instead, but wanted to do your suggestion to possibly help others down the road and it didn’t seem to work either. I deleted the directory manually, then uninstalled the package via CLI and ran the script again, which resulted in another failure when it hit ruby-build ( The Ruby zlib extension was not compiled. ERROR: Ruby install aborted due to missing extensions ).

Then I proceeded to try to manually install each dependency and got down to Rails, but when running brew install rails it threw this error:

ERROR:  Error installing rails:
	ERROR: Failed to build gem native extension.

    current directory: /usr/local/lib/ruby/gems/2.5.0/gems/nokogiri-1.8.5/ext/nokogiri
/usr/local/opt/ruby/bin/ruby -r ./siteconf20181030-42813-1agwry.rb extconf.rb
checking if the C compiler accepts ... yes
checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no
Building nokogiri using packaged libraries.
Using mini_portile version 2.3.0
checking for iconv.h... yes
checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** 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.

(MengyuLi) #183

Thanks so much for this guide. I really like Discourse.

When I run rspec in my macOS, I have the following ‘F’.

 Search include_diacritics allows strips correctly
 Failure/Error: expect(results.posts.length).to eq(1)

   expected: 1
        got: 0
# ./spec/components/search_spec.rb:1071:in `block (3 levels) in <main>'

I think it is because of this one:

let!(:post1) { Fabricate(:post, raw: ‘สวัสดี Rágis hello’) }

it ('allows strips correctly') do
  results = Search.execute('สวัสดี', type_filter: 'topic')
    expect(results.posts.length).to eq(1)

macOS Mojave, Version 10.14.1
Ruby: 2.5.3
psql: psql (PostgreSQL) 10.5


(Noah Dolph) #184

Following this guide I’ve run into the following…

 1) FileStore::LocalStore#remove_upload moves the file to the tombstone
     Failure/Error: expect(File.mtime(tombstone_path)).to_not eq(mtime)
     
       expected: value != 2018-11-11 22:43:22.000000000 -0600
            got: 2018-11-11 22:43:22.000000000 -0600
     
       (compared using ==)
     
       Diff:
       
     # ./spec/components/file_store/local_store_spec.rb:53:in `block (3 levels) in <main>'

  2) UserNotifications watching first post email building has a username
     Failure/Error:
       html = UserNotificationRenderer.new(Rails.configuration.paths["app/views"]).render(
         template: 'email/invite',
         format: :html,
         locals: { message: PrettyText.cook(message, sanitize: false).html_safe,
                   classes: Rtl.new(user).css_class
         }
       )
     
     Errno::EMFILE:
       Too many open files - getcwd
     Shared Example Group: "notification email building" called from ./spec/mailers/user_notifications_spec.rb:788
     # ./app/mailers/user_notifications.rb:560:in `new'
     # ./app/mailers/user_notifications.rb:560:in `send_notification_email'
     # ./app/mailers/user_notifications.rb:431:in `notification_email'
     # ./app/mailers/user_notifications.rb:322:in `user_invited_to_topic'
     # ./spec/mailers/user_notifications_spec.rb:555:in `expects_build_with'
     # ./spec/mailers/user_notifications_spec.rb:621:in `block (4 levels) in <main>'

  3) Search include_diacritics allows strips correctly
     Failure/Error: expect(results.posts.length).to eq(1)
     
       expected: 1
            got: 0
     
       (compared using ==)
     # ./spec/components/search_spec.rb:1071:in `block (3 levels) in <main>'

  4) Search ignore_diacritics allows strips correctly
     Failure/Error: expect(results.posts.length).to eq(1)
     
       expected: 1
            got: 0
     
       (compared using ==)
     # ./spec/components/search_spec.rb:1050:in `block (3 levels) in <main>'

Not sure what to do here…

macOS Sierra 10.12.6