Install Discourse on macOS for development

In development you don’t perform upgrades here.

Hi Robert, thanks for your replying. Is ‘git pull’ enough to perform an upgrade? (in development)

1 Like

Yes, but don’t forget the gems and the migrations:

git pull
bundle install
rake db:migrate
2 Likes

Looks like something is awry with the script, it fails to install brew.
(this is on a brand-new Mac Air M2)

Everything went fine after installing brew myself :slight_smile:

Note that the script installs Ruby version 3.1.3 and then bundle exec gets angry that you don’t use 3.2.1 :smiley:

[Warning] Discourse recommends developing using Ruby v3.2.1 or above. You are using v3.1.3.

2 Likes

No longer true! :partying_face:
https://github.com/discourse/install-rails/pull/40

3 Likes

It won’t install Ruby for some reason. I keep getting this:

BUILD FAILED (macOS 12.5.1 using ruby-build 20230309)

Inspect or clean up the working tree at /var/folders/f6/95l6wylj4d11_jyvyp7r9yd40000gn/T/ruby-build.20230320012216.80048.RdOmWC
Results logged to /var/folders/f6/95l6wylj4d11_jyvyp7r9yd40000gn/T/ruby-build.20230320012216.80048.log

Last 10 log lines:
	Check ext/psych/mkmf.log for more details.
*** Fix the problems, then remove these directories and try again if you want.
Generating RDoc documentation
/private/var/folders/f6/95l6wylj4d11_jyvyp7r9yd40000gn/T/ruby-build.20230320012216.80048.RdOmWC/ruby-3.2.1/lib/yaml.rb:3: warning: It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
uh-oh! RDoc had a problem:
cannot load such file -- psych

run with --debug for full backtrace
make: *** [rdoc] Error 1
failed

Could someone please help me with this?

1 Like

I have the same issue on MacOS 13.2.1.

This page is the only result from Google when searching for (parts of) this error message, so in case someone else hits this error again:

I was facing this today when running rails s after upgrading to the current version of Ruby (3.2.1), Rails (7.0.4.3) and all Gemfile dependencies, including mini_racer (0.6.3).

It was fixed after following a suggestion from this GitHub comment: running make inside
.../3.2.0/gems/mini_racer-0.6.3/ext/mini_racer_extension
and copying the resulting mini_racer_extension.bundle to .../3.2.0/extensions/x86_64-darwin-22/3.2.0/mini_racer-0.6.3.

I finally managed to successfully pass the build error somehow (I didn’t keep track of what I did…), but now I’m stuck on:

An error occurred while installing pg (1.4.6), and Bundler cannot continue

During bundle install. :thinking:

edit:
It was resolved following the instructions given above the error:

If you need to have postgresql@13 first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/postgresql@13/bin:$PATH"' >> ~/.zshrc

For compilers to find postgresql@13 you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/postgresql@13/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/postgresql@13/include"

For pkg-config to find postgresql@13 you may need to set:
  export PKG_CONFIG_PATH="/opt/homebrew/opt/postgresql@13/lib/pkgconfig"

I’m not sure which one though! :sweat_smile:

1 Like

Because of permissions issues on a company laptop, I’m having to go through the install script manually to handle each item one at a time. When tring to run gem update --system, I get the following error:

sh-3.2# gem update --system
Updating rubygems-update
Fetching rubygems-update-3.4.12.gem
Successfully installed rubygems-update-3.4.12
Parsing documentation for rubygems-update-3.4.12
Installing ri documentation for rubygems-update-3.4.12
Installing darkfish documentation for rubygems-update-3.4.12
Done installing documentation for rubygems-update after 158 seconds
Parsing documentation for rubygems-update-3.4.12
Done installing documentation for rubygems-update after 0 seconds
Installing RubyGems 3.4.12
ERROR:  While executing gem ... (Errno::EPERM)
    Operation not permitted @ rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/gem
	/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1387:in `initialize'
	/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1387:in `open'
	/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1387:in `block in copy_file'
	/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1386:in `open'
	/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1386:in `copy_file'
	/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:492:in `copy_file'
	/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:860:in `block in install'
	/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1558:in `block in fu_each_src_dest'
	/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1574:in `fu_each_src_dest0'
	/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:1556:in `fu_each_src_dest'
	/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/fileutils.rb:856:in `install'
	/Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.12/lib/rubygems/commands/setup_command.rb:267:in `block (2 levels) in install_executables'
	/Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.12/lib/rubygems/commands/setup_command.rb:251:in `chdir'
	/Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.12/lib/rubygems/commands/setup_command.rb:251:in `block in install_executables'
	/Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.12/lib/rubygems/commands/setup_command.rb:248:in `each'
	/Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.12/lib/rubygems/commands/setup_command.rb:248:in `install_executables'
	/Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.12/lib/rubygems/commands/setup_command.rb:165:in `execute'
	/Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.12/lib/rubygems/command.rb:327:in `invoke_with_build_args'
	/Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.12/lib/rubygems/command_manager.rb:252:in `invoke_command'
	/Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.12/lib/rubygems/command_manager.rb:192:in `process_args'
	/Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.12/lib/rubygems/command_manager.rb:150:in `run'
	/Library/Ruby/Gems/2.6.0/gems/rubygems-update-3.4.12/lib/rubygems/gem_runner.rb:51:in `run'
	setup.rb:33:in `<main>'

Any ideas on how to get through this one?

1 Like

Did you use M1/M2 Apple ? I think make sure that you have Ruby 3.2.x as the system default by brew install it firstly.Then for apple silicon you can do

  if [ -d "/opt/homebrew/opt/ruby/bin" ]; then
     export PATH=/opt/homebrew/opt/ruby/bin:$PATH
     export PATH=`gem environment gemdir`/bin:$PATH
  fi

in your .zshrc

Because the Mac OS X came with the system Ruby 2.x that will mess up the environment installation script.

Also if you have problem of starting the service do something like:

  brew services restart postgresql@13
  brew services restart redis

it works for me now.

2 Likes

Hi All! I have been following the installation post here and most of the tips shared helped me a lot to overcome some issues that I was facing during my MacOS M1 installation.

I’m now stuck in the last Bootstrap part:

bundle exec rails server

The command above worked for me, I was able to see something at localhost:3000 and also register the admin user but after running bin/ember-cli the following exception was presented:

$ bin/ember-cli
warning Resolution field "unset-value@2.0.1" is incompatible with requested version "unset-value@^1.0.0"
patch-package 8.0.0
Applying patches...
@ember/jquery@2.0.0 ✔
babel-plugin-debug-macros@0.3.4 ✔
content-tag@1.1.2 ✔
ember-source@3.28.12 ✔
ember-this-fallback@0.4.0 (1 deprecation-name) ✔
ember-this-fallback@0.4.0 (2 themes) ✔
virtual-dom@2.1.1 ✔
WARNING: Ember CLI v5.0.0 is not tested against Node v21.0.0. See "https://github.com/ember-cli/ember-cli/blob/master/docs/node-support.md" to find out which version of Node is best to use.
(node:22167) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Could not `import('file:///Users/myuser/discourse/app/assets/javascripts/discourse/ember-cli-build.js')`: Cannot read properties of undefined (reading 'indexOf')

Stack Trace and Error Report: /var/folders/4l/ksznzcp17sg1wjyq7mmfzfkc0000gn/T/error.dump.b499a1d1d9b275ada33629ea1a84760d.log

am I missing anything?

I was able to run bin/ember-cli after uninstalling the current node and installing node@20 via brew.

1 Like

Seeing this error at this step.

Error: Could not symlink bin/c_rehash
Target /opt/homebrew/bin/c_rehash
is a symlink belonging to openssl@3. You can unlink it:
  brew unlink openssl@3

To force the link and overwrite all conflicting files:
  brew link --overwrite openssl@1.1

To list all files that would be deleted:
  brew link --overwrite --dry-run openssl@1.1
failed

And this error at that step

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:283:in `find_spec_for_exe': Could not find 'bundler' (2.4.13) required by your /Users/Desktop/discourse/Gemfile.lock. (Gem::GemNotFoundException)
To update to the latest version installed on your system, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.4.13`
	from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:302:in `activate_bin_path'
	from /usr/bin/bundle:23:in `<main>'

Can anyone guide me how should I proceed? This is my first time. @Arkshine

Unfortunately, I don’t own a macOS computer. I know the script is working fine on windows/linux ; but macOS I can’t test it.

Did you try running brew link --overwrite openssl@1.1, then executing the script again? However, there is a high chance it will stop again on this line.

Does anyone know how to set environment variables with this dev environment? I’m trying to get SSO to work but it seems that I need to enable CORS. I read that I have to do that in the app.yml but this setup doesn’t have one. Can it go in the site_settings DB table? Sorry, new to discourse development

Hello @Plabforum,

I am running into exactly the same 2 errors as you. Have you been able to resolve them?

Any advice would be appreciated.

I’m sorry, I don’t have any good news. I actually gave up after that.

Sorry to hear that. I was actually able to get passed this by unlinking openssl@3 through:

brew unlink openssl@3

and then link openssl@1.1

brew link --overwrite openssl@1.1

I reran the script again without errors (got a couple of warnings of the stuff that was installed in the first run).

2 Likes

It looks like I have been able to install Discourse on my Macbook for development following the instructions in this topic. I do have 2 follow up questions.

  1. I did receive warnings and fails while running bundle exec rake autospec is that a reason for concern? My installation seems to work as expected and is not showing errors in the admin section.

  2. I apologize in advance if I ask a silly questions (I am totally new to this type of solution/server). Do I need to run bundle exec rails server, bin/ember-cli and mailhog each time I would like to use the server? And how do I shut down the server if I want to?

Thanks for your support!