Beginners Guide to Install Discourse on macOS for Development

dev-install

(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