Install Discourse on macOS for development

Doh! :facepalm:

Thanks! Let me try that right now.

In my opinion, somebody should edit the guide from the Ruby on Rails forum and provide further clarification regarding step 7. Just my two cents though.

I will be right back. Hold on a second…

1 Like

Sorry I have to run, but I think that mini_racer fix for m1 macs has been merged in. I just checked my Gemfile on my m1 mac and mine isn’t edited. So I think you can skip step 7.

3 Likes

I ran step 8 and received the Could not locate Gemfile error.

I (think) I was able to figure out step 7, but step 8 is still giving me trouble and is spitting out the error mentioned above.

You need to be inside of the discourse directory when you run bundle install.

Hi @merefield: Can you describe your remote setup a little more?

While developing a theme allows me to add changes on a live site, for developing a plugin I don’t see any way around doing it on my local machine, having the whole discourse codebase there (with my plugin on top of it).

The result is that for any (non-css) change when coding a plugin, when I reload it 1) kicks off my computer’s fan and 2) takes a solid 30 seconds to reload. And if I need to restart the server, it takes several minutes.

Those delays really add up–with the result that it might take me an hour to code something up that with my normal coding flow (where there’s hot reload or at most 2-3 seconds per change) would take 15 minutes.

So, I’d appreciate any suggestions for speeding things up.

This arguably would be better on the Ubuntu topic, as I’m just running that install on a cloud server, fronted by nginx and a full DNS (no docker), so I’m actually addressing the domain. Running everything from the terminal. I’ve even got Ember CLI working well in that set up now.

It’s not that quick either, but fast enough. It has the benefit of being able to run and test full https callback services.

The fastest plugin development environment by far that I’m aware of is local Docker Dev on WSL2 which screams. It’s also extremely simple to maintain. Unfortunately discourse_theme doesn’t work in that environment yet afaik so I’m back to my cloud server for that work.

It’s a little odd why Apple is lagging behind here? The Microsoft engineers have shown themselves to be very canny.

3 Likes

In case someone gets errors trying to install ruby 2.7.3, apparently something changed after Xcode 12 which breaks the install process with rbenv:

I kept getting this, even though I have the latest versions of psych and libyaml installed:

It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.

I tried the workaround they suggest in the guide, but I kept getting the same error and ended up having to use rvm:

rvm install 2.7.3
1 Like

Regarding how to program faster when doing a plugin, I’ve recently changed my approach. And it’s working great. Basically, move any front end stuff to a theme component, and only code the backend stuff in the plugin itself. I know others have figured that out before. But now that I’m doing it, programming is so much faster and nicer. Details here.

3 Likes

While setting up a new M1 MacBook Air, I was unable to run bundle install successfully, getting this error:

An error occurred while installing openssl (2.2.1), and Bundler cannot continue.

This Mac came pre-installed with OpenSSL1.1 and the script installs OpenSSL3.0 through Homebrew. After uninstalling 3.0, bundle install worked as expected.

8 Likes

Hi @alxndr did you ever find a fix?

1 Like

Thank you this was helpful! On OSX Big Sur, at this step

I continually run in to:

An error occurred while installing mini_racer (0.6.1), and Bundler cannot continue.

I’ve confirmed my gcc is up to date, and haven’t had any other issues with gemfile or dependencies up to this point. Any ideas?

For more context:

make: *** [mini_racer_extension.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/nick.moores/discourse/vendor/bundle/ruby/2.6.0/gems/mini_racer-0.6.1 for inspection.
Results logged to /Users/nick.moores/discourse/vendor/bundle/ruby/2.6.0/extensions/universal-darwin-20/2.6.0/mini_racer-0.6.1/gem_make.out

  /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:99:in `run'
  /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:51:in `block in make'
  /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:43:in `each'
  /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:43:in `make'
  /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/ext_conf_builder.rb:62:in `block in build'
  /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/tempfile.rb:295:in `open'
  /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/ext_conf_builder.rb:29:in `build'
  /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:185:in `block in build_extension'
  /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/monitor.rb:230:in `mon_synchronize'
  /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:181:in `build_extension'
  /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:229:in `block in build_extensions'
  /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:226:in `each'
  /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:226:in `build_extensions'
  /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/installer.rb:830:in `build_extensions'
  /Library/Ruby/Gems/2.6.0/gems/bundler-2.2.26/lib/bundler/rubygems_gem_installer.rb:66:in `build_extensions'
  /Library/Ruby/Gems/2.6.0/gems/bundler-2.2.26/lib/bundler/rubygems_gem_installer.rb:26:in `install'
  /Library/Ruby/Gems/2.6.0/gems/bundler-2.2.26/lib/bundler/source/rubygems.rb:192:in `install'
  /Library/Ruby/Gems/2.6.0/gems/bundler-2.2.26/lib/bundler/installer/gem_installer.rb:54:in `install'
  /Library/Ruby/Gems/2.6.0/gems/bundler-2.2.26/lib/bundler/installer/gem_installer.rb:16:in `install_from_spec'
  /Library/Ruby/Gems/2.6.0/gems/bundler-2.2.26/lib/bundler/installer/parallel_installer.rb:186:in `do_install'
  /Library/Ruby/Gems/2.6.0/gems/bundler-2.2.26/lib/bundler/installer/parallel_installer.rb:177:in `block in worker_pool'
  /Library/Ruby/Gems/2.6.0/gems/bundler-2.2.26/lib/bundler/worker.rb:62:in `apply_func'
  /Library/Ruby/Gems/2.6.0/gems/bundler-2.2.26/lib/bundler/worker.rb:57:in `block in process_queue'
  /Library/Ruby/Gems/2.6.0/gems/bundler-2.2.26/lib/bundler/worker.rb:54:in `loop'
  /Library/Ruby/Gems/2.6.0/gems/bundler-2.2.26/lib/bundler/worker.rb:54:in `process_queue'
  /Library/Ruby/Gems/2.6.0/gems/bundler-2.2.26/lib/bundler/worker.rb:91:in `block (2 levels) in create_threads'
3 Likes

Hi Mark,

Do you mean simply brew uninstall openssl and then re-run bundle install ? On an M1 mba, bundle install still errors out with the openssl 2.2.1 message after doing so.

[edit] ah, I had to add /opt/homebrew/opt/openssl@1.1/bin to PATH. Let’s see if this works…

[edit2] also had to brew install node for ember-cli. Now it’s working!

6 Likes

Can you please explain where we need to add this path ? I am facing same issue, details will be very helpful !

2 Likes

export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"

I also had to mess with the mysql gem to get it to build on ARM. I was using mariadb so it was something like this:

gem install mysql2 -v '0.5.3' -- 
--with-mysql-lib=$(brew --prefix mariadb)/lib 
--with-mysql-dir=$(brew --prefix mariadb) 
--with-mysql-config=$(brew --prefix mariadb)/bin/mysql_config 
--with-mysql-include=$(brew --prefix mariadb)/include
6 Likes

To start the rails server
I used rails server instead of bundle exec rails server
the bundle exec rails server gives me an error.

Could not find ‘xxx gem’ (Even though I have installed the gem…)

What is the difference between bundle exec vs no bundle exec?

1 Like

Have any of you faced this issue while trying the bundle install?

An error occurred while installing openssl (2.2.1), and Bundler cannot continue.

In Gemfile:
  cose was resolved to 1.2.0, which depends on
    openssl-signature_algorithm was resolved to 1.1.1, which depends on
      openssl

and also:

An error occurred while installing mini_racer (0.6.2), and Bundler cannot continue.
1 Like

I don’t know exactly if this was the catch, but I ran this command:

gem update --system

After running it, I relaunched the my terminal, and the bundle install worked fine. Didn’t have any other issues after that, just followed the guide.

3 Likes

Hi! I am currently trying to run bundle exec rake db:create but I keep getting redis related errors, specially the following:
nil versions are discouraged and will be deprecated in Rubygems 4 Discourse requires Redis 6.2.0 or up
I’ve been working on this all weekend and I am just about ready to retire and take up basketweaving. Any help would be really appreciated!

2 Likes

Sorry you’re so stuck.

The “nil versions are discouraged” means that it failed to connect and/or get a version from Redis. So it’s not that the version is wrong, but that it’s not finding it.

Did you install with brew install? (which is in https://raw.githubusercontent.com/techAPJ/install-rails/master/mac that you should have run if you followed these instructions)

I think the thing to do is to go through https://raw.githubusercontent.com/techAPJ/install-rails/master/mac line by line and make sure that stuff worked?

But maybe first, check these things:

Did you do a bundle install before trying to do the bundle exec rake db:migrate? What does ./bin/rake db:migrate do?

2 Likes

Thank you for replying, Jay.
I have run bundle install within the discourse directory and it ran successfully. However, both commands (bundle exec rake db:migrate and ./bin/rake db:migrate) both show the same nil version error.
I have tried installed via brew and I also had the idea of installing it line by line, but still the same error.
Should I try trashing the directory and starting from scratch?

2 Likes