Discourse auf macOS für die Entwicklung installieren

:warning: Diese Anleitung behandelt die Installationsanweisungen für eine macOS-Entwicklungsumgebung. Anleitungen für die Produktion finden Sie unter: Install Discourse in production with the official supported instructions

Sie möchten also Discourse auf macOS einrichten, um daran zu arbeiten und zu entwickeln?

Wir gehen davon aus, dass Sie Ruby/Rails/Postgres/Redis noch nicht auf Ihrem Mac installiert haben. Fangen wir an :rocket: !

Discourse-Abhängigkeiten installieren

Sie benötigen die folgenden Pakete auf Ihrem System:

** optional

Starten Sie Ihr Terminal neu

Nachdem wir nun die Discourse-Abhängigkeiten installiert haben, fahren wir mit der Installation von Discourse selbst fort.

Terminal neu starten

Beenden und starten Sie Ihre Shell neu, um sicherzustellen, dass die Pfade zu den installierten Paketen vom Terminal korrekt übernommen werden.

Discourse klonen

Klonen Sie das Discourse-Repository im Ordner ~/discourse:

git clone https://github.com/discourse/discourse.git ~/discourse

~ steht für das Home-Verzeichnis, sodass der Discourse-Quellcode in Ihrem Home-Verzeichnis verfügbar ist.

Discourse initialisieren (Bootstrap)

Wechseln Sie in Ihren Discourse-Ordner:

cd ~/discourse

Installieren Sie die benötigten Gems

bundle install

Installieren Sie die JS-Abhängigkeiten

pnpm install

Führen Sie als Nächstes diese Befehle aus, um Ihre lokale Discourse-Instanz einzurichten:

bundle exec rake db:create
bundle exec rake db:migrate
RAILS_ENV=test bundle exec rake db:create db:migrate

Starten Sie die Rails- und Ember-Server. Hier haben Sie zwei Möglichkeiten.

Option 1: Verwenden Sie zwei separate Terminal-Tabs/-Fenster und führen Sie Rails und Ember CLI separat über

bundle exec rails server

und

bin/ember-cli

aus.

Option 2: Verwenden Sie nur ein Terminal-Tab/-Fenster:

bin/ember-cli -u # startet den Unicorn-Server im Hintergrund

:tada: Sie sollten nun in der Lage sein, http://localhost:4200 aufzurufen, um Ihre lokale Discourse-Installation anzuzeigen. (Beachten Sie, dass der erste Ladevorgang bis zu einer Minute dauern kann, während der Server hochgefahren wird.)

Sie können auch versuchen, die Tests auszuführen:

bundle exec rake autospec

Alle (oder fast alle) Tests sollten erfolgreich durchlaufen.

Neuen Administrator erstellen

Um einen neuen Administrator zu erstellen, führen Sie den folgenden Befehl aus:

RAILS_ENV=development bundle exec rake admin:create

Folgen Sie den Anweisungen, um ein Administratorkonto zu erstellen.

Mail konfigurieren

Führen Sie MailHog aus:

mailhog

Herzlichen Glückwunsch! Sie sind jetzt Administrator Ihrer eigenen Discourse-Installation!

Viel Spaß beim Hacking! Um damit zu beginnen, lesen Sie den Leitfaden für Anfänger zur Erstellung von Discourse-Plugins.


Dieses Dokument wird versioniert – schlagen Sie Änderungen auf github vor.

78 „Gefällt mir“
Setup discourse on Mac OS
Running Discourse on Docker for Mac
Localhost:3000/users gives no-results
How to install Discourse on windows
How to install Discourse locally?
Best dev installation method for running on macOS?
Help me setup my Discourse development environment
Local installation internal use only
Discourse standalone
Migrate a NodeBB forum with Redis to Discourse
Starting discourse fails with bootstrap error
Error after cleaning tmp folder
MacOS Installation Gem::FilePermissionError
UndefinedTable: ERROR: relation "web_hook_event_types" when trying to run rspec test
Please help, how do I install Discourse on macOS?
[Need help][MacOS M1 dev installation] ArgumentError unknown keywords
Migrate a PunBB forum to Discourse
Migrate a phpBB3 forum to Discourse
Migrate a FluxBB forum to Discourse
Migrate from GetSatisfaction to Discourse
Regarding the installation - docker
Migrate a MyBB forum to Discourse
Migrate a NodeBB forum with MongoDB to Discourse
Migrate a Ning forum to Discourse
Migrate a Phorum forum to Discourse
Migrate from another forum to Discourse
Migrate a Kunena 3 forum to Discourse
Migrate a bbPress WordPress plugin forum to Discourse
Install Discourse for development using Docker
Use the Discourse API ruby gem
Enable CORS on localhost for DiscourseConnect
Set Environmental Variables
Need help integrating code wrote on Edittext to the Discourse
Keyboard navigation messes up the search menu
Contributing to Discourse development
How to install discussions on localhost in my mac?
How to install Discourse for Wordpress locally running on MAMP
Error when building: "Runtime Error: discourse does not support compiling scss/sass files via sprockets"
Discourse as Your First Rails App
Upgrading Mathjax to version 4
Windows server publish method
Migrate a vBulletin 3 forum to Discourse via XenForo
Category option: max topics per user (2 use-case examples)
Can't deploy to heroku
[PAID] Import from Legacy Postgres DB
Vagrant based server failing on db:migrate
Change unicorn port from 3000 in development
I want to build a debug version of discourse
Moderation Tools
Rails server --daemon and plugins
Installing problem - bundle install
Nginx Performance Report plugin incompatible with development environment setup script
Rake aborted message is showing when installing vagrant development
Update PhantomJS to latest for Ubuntu dev guide?
Cannot Backup my Development Instance (Fails)
Install error : Protocol violation
Can't set up dev environment due to cppjieba_rb failing to install
How to edit the discourse files? A development box?
How to add a new language
How to relax Content Security Policy
Installing Discourse for macOS Development Using asdf and docker-compose
Override profile background via SSO
Can't set up dev environment due to cppjieba_rb failing to install
Stuck in infinite loop in Mac terminal after source ~/.bashrc
Install on macOS – Failure: Scheduler::Defer can pause and resume
Disabling SSO in development environment
Local development and deploying from same repo
Discourse Connect on Local instance is not working
Can't start localhost server -- file was built for x86_64 which is not the architecture being linked (i386)
Please help, how do I install Discourse on macOS?
How to connect to an external database running on localhost
How can I include discourse in my local dev stack?
Topic List Previews (TLP)
Global messages on 94632 timed out, restarting process, 95535 successfully terminated by `TERM` signal
Cannot get embedding to work
/admin/config/emoji non responsive/locks up
App.yml file does not exist when installing Discourse locally
Ember-cli error on local MacOS development
Importing / migrating from Zendesk Community to Discourse
Redis version error when I run bundle exec db:create
Dev environment setup failed on bundle install
Set up a local Discourse Development Environment?

If anyone is getting failing specs with most of them being .count errors, then try the following:

RAILS_ENV=test bundle exec rake db:reset

I had a problem where development data somehow got into my test database and was causing lots of failures.

7 „Gefällt mir“

Is it possible to reset a discourse completely?

2 „Gefällt mir“

Yes, do:

rake db:drop db:create db:migrate

Note that this will wipe everything and you will have to create your Admin user account again.

11 „Gefällt mir“

Can someone assist me in how I can update my discourse?

/launcher rebuild app

returns an error.

1 „Gefällt mir“

./launcher rebuild app is for discourse_docker based production setup. To update local/development Discourse instance you need:

cd ~/discourse
git pull origin master
8 „Gefällt mir“

I get this error @techAPJ,

error: Your local changes to the following files would be overwritten by merge:
	.gitignore
Please commit your changes or stash them before you merge.
Aborting

The error message is pretty clear:

Please commit your changes or stash them before you merge.

If you want to ignore your local changes, do:

git fetch origin
git reset --hard origin/master
7 „Gefällt mir“

Using the guide from the Ruby on Rails forum, I’m currently stuck on step 7.

This is probably a very “newbie” question, but how do I “point” to the experimental branch that was linked in that topic? I tried a few things and was ultimately giving the Unknown command mini_racer, message every single time.

1 „Gefällt mir“

They’re fine asking here.

There are some specific m1 instructions we wrote that we reference on the rails forum in this guide.

I’d have to look on my m1 air later, and maybe my fellow coworks who recently setup new macs might know better if this is even still needed, but there is an example of how to point to a branch in step 7:

gem 'mini_racer', github: 'rubyjs/mini_racer', branch: 'refs/pull/186/head'

So you would edit this line in your local version of discourse/Gemfile:

and then run bundle install.

4 „Gefällt mir“

It’s linked right at the top of the original post.

The topic from the Ruby on Rails forum has been dead for many months now. The OP hasn’t been active since Feburary and hasn’t replied to any comments there asking for help.

There are more people to help me here. Just saying. :wink:

I tried copying that into Terminal and received the same Unknown command mini_racer, error from before.

Admittedly, the guide from the Ruby on Rails forum isn’t as clear as I’d hope in that regard.

Apologies in advance… :pray:

2 „Gefällt mir“

It’s not a command to run. You will need to EDIT the actual text file called “Gemfile” located inside the discourse directory.

1 „Gefällt mir“

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 „Gefällt mir“

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 „Gefällt mir“

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.

1 „Gefällt mir“

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 „Gefällt mir“

Falls jemand Fehler bei der Installation von Ruby 2.7.3 erhält, hat sich offenbar nach Xcode 12 etwas geändert, was den Installationsprozess mit rbenv unterbricht:

Ich erhielt immer wieder Folgendes, obwohl ich die neuesten Versionen von psych und libyaml installiert habe:

Es scheint, dass Ihrer Ruby-Installation psych (für YAML-Ausgabe) fehlt.
Um diese Warnung zu beseitigen, installieren Sie bitte libyaml und installieren Sie Ihr Ruby neu.

Ich habe den Workaround ausprobiert, den sie im Leitfaden vorschlagen, aber ich erhielt immer wieder dieselbe Fehlermeldung und musste schließlich rvm verwenden:

rvm install 2.7.3
1 „Gefällt mir“

Bezüglich der Frage, wie man beim Erstellen eines Plugins schneller programmieren kann, habe ich kürzlich meinen Ansatz geändert. Und es funktioniert großartig. Im Grunde verlagert man alle Frontend-Sachen in eine Theme-Komponente und programmiert nur die Backend-Sachen im Plugin selbst. Ich weiß, dass andere das schon früher herausgefunden haben. Aber jetzt, wo ich es tue, ist das Programmieren so viel schneller und angenehmer. Details hier.

3 „Gefällt mir“