Настройка Discourse для разработки на Fedora Linux

Это руководство было протестировано на чистой установке Fedora 31 и 33, но может подойти и для более старых версий, которые также используют dnf как инструмент управления пакетами. Это не официальное руководство, но оно может быть полезно другим разработчикам, использующим Fedora. Оно в значительной степени основано на руководстве по разработке для Ubuntu, с изменениями, учитывающими различия в пакетах для dnf. Предполагается, что у вас ещё не установлены ни один из перечисленных пакетов, хотя большинство из них будут пропущены инструментами, если они уже установлены.

Если вы планируете установить Discourse для продакшн-среды, лучше воспользоваться инструкциями по установке через Docker на GitHub.

Установка необходимых системных и разработческих пакетов

sudo dnf update
sudo dnf install -y "@development-tools" git rpm-build zlib-devel ruby-devel readline-devel libpq-devel ImageMagick sqlite sqlite-devel nodejs npm curl gcc g++ bzip2 openssl-devel libyaml-devel libffi-devel zlib-devel gdbm-devel ncurses-devel optipng pngquant jhead jpegoptim gifsicle oxipng

Установка необходимых npm-пакетов

sudo npm install -g svgo pnpm

Установка и настройка PostgreSQL

sudo dnf install postgresql-server postgresql-contrib
sudo postgresql-setup --initdb --unit postgresql
sudo systemctl enable postgresql
sudo systemctl start postgresql
sudo -u postgres -i createuser -s $USER

Установка и настройка Redis

sudo dnf install redis
sudo systemctl enable redis
sudo systemctl start redis

Установка rbenv, ruby-build и Ruby

git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
~/.rbenv/bin/rbenv init
printf 'export PATH="$HOME/.rbenv/bin:$PATH"\n' >> ~/.bashrc
printf 'eval "$(rbenv init - --no-rehash)"\n' >> ~/.bashrc
source ~/.bashrc
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
# подтвердите корректность установки
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash
rbenv install 2.7.1
rbenv global 2.7.1
rbenv rehash

Установка зависимостей Ruby

gem update --system
gem install bundler mailcatcher rails

Клонирование кода Discourse

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

Установка зависимостей Discourse

bundle install
pnpm install

Создание необходимых баз данных и загрузка схемы

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

Проверка установки путём запуска тестов

bundle exec rake autospec

Запуск приложения

bundle exec rails server

Теперь вы должны увидеть страницу настройки Discourse по адресу http://localhost:3000.

Для дальнейшей настройки ознакомьтесь с существующими официальными руководствами по установке.


Этот документ находится под контролем версий — предлагайте изменения на GitHub.

27 лайков

In Installing rbenv, ruby-build, and ruby, the url to the rbenv-doctor script is not working anymore (apparently the branch has been rename from master to main), the correct command is now:

curl -fsSL https://github.com/rbenv/rbenv-installer/raw/main/bin/rbenv-doctor | bash
2 лайка

Thanks for the info @nicolas-jaussaud, I’ve updated the OP.

FWIW I now prefer to use chruby and ruby-install over rbenv.

2 лайка

I ran into an issue trying to run bundle install as Fedora now has by default disabled file transport.

The error happens when trying to install the sprockets gem and ends with the message:

transport 'file' not allowed

I don’t know what’s the proper way to do this, but you can temporarily allow the unsafe transport:

git config --global protocol.file.allow always
# run the discourse setup here
git config --global protocol.file.allow never

After that I ran into an error like this when running db:migrate:

At /home/hhyyrylainen/Projects/discourse/lib/site_setting_extension.rb:199:in `public_send`
Deprecation notice: `SiteSetting.enable_personal_messages` has been deprecated. Please use `SiteSetting.personal_message_enabled_groups` instead. (removal in Discourse 3.0) 
At /home/hhyyrylainen/Projects/discourse/lib/site_setting_extension.rb:199:in `public_send`
#<Thread:0x00007f94c3342600 /home/hhyyrylainen/Projects/discourse/lib/scheduler/defer.rb:83 run> terminated with exception (report_on_exception is true):
/home/hhyyrylainen/.gem/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/connection_handling.rb:309:in `connection_pool': ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)
	from /home/hhyyrylainen/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rails_multisite-4.0.1/lib/rails_multisite/connection_management/rails_61_compat.rb:8:in `current'
	from /home/hhyyrylainen/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rails_multisite-4.0.1/lib/rails_multisite/connection_management.rb:115:in `current_db_hostnames'
	from /home/hhyyrylainen/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rails_multisite-4.0.1/lib/rails_multisite/connection_management.rb:111:in `current_hostname'
	from /home/hhyyrylainen/Projects/discourse/lib/discourse.rb:232:in `handle_job_exception'
	from /home/hhyyrylainen/Projects/discourse/lib/scheduler/defer.rb:114:in `rescue in do_work'
	from /home/hhyyrylainen/Projects/discourse/lib/scheduler/defer.rb:113:in `do_work'
	from /home/hhyyrylainen/Projects/discourse/lib/scheduler/defer.rb:85:in `block (2 levels) in start_thread'
/home/hhyyrylainen/.gem/ruby/3.2.0/gems/activerecord-7.0.4.3/lib/active_record/connection_handling.rb:309:in `connection_pool': ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)
	from /home/hhyyrylainen/.rbenv/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rails_multisite-4.0.1/lib/rails_multisite/connection_management.rb:79:in `with_connection'
	from /home/hhyyrylainen/Projects/discourse/lib/scheduler/defer.rb:96:in `do_work'
	from /home/hhyyrylainen/Projects/discourse/lib/scheduler/defer.rb:85:in `block (2 levels) in start_thread'

It seems it happened after the migration finished, so as I couldn’t figure out how to fix that I ignored it, but luckily my development site seems to be working.

For the test environment I didn’t get the same error but got an error about missing oxipng, which doesn’t seem to be available as a Fedora package.

After that I didn’t run into any more issues, everything still more or less worked fine on Fedora 38. Though, I had previously installed rbenv using some other setup instructions.

Running bundle exec rake autospec I got some test failures (135) but it seems I got a mostly working development setup.

2 лайка

I got the Dev version going some time ago but the Production version was too difficult for me . .

Just followed this guide to install on Fedora 40 Workstation, had to add oxipng to the distro installs.
sudo dnf install oxipng

3 лайка

Thanks for letting us know, I’ve updated the documentation in this commit: docs/fedora-setup: include oxipng package (#14) · discourse/discourse-developer-docs@eb51e54 · GitHub.

1 лайк

I am stuck after installation today on Fedora 41 with the following issue when I connect to localhost:3000 and click on register :
“no administrator emails were defined during setup”; the message provides how to add an administrator email.

I’ve failed to successfuly add an admin acount following this procedure because of 2 errors when using ./launcher enter app :
1° First solved error was: no app.yml file is present → I copied the sampleapp.yml from the sample folder to the container folder, then modified to add email adresses, then did the rebuild with /var/discourse/launcher rebuild app
2° Second error is not solved :
Error response from daemon: No such container: app
If I use the rake commands to create an admin it tells me no rakefile found

Can anyone please help?

This install doesn’t use docker, so you can’t enter a container.

Try creating an admin from the Discourse folder with this command:

bin/rails admin:create
1 лайк

Hi Coconut, you are quick to respond and efficient, thanks a lot !
The command returns gem bunder missing, which I installed with `gem install bundler -v 2.6.2’ and then I could successfuly apply your solution !

2 лайка

Just tried running a local install and ran into issues with pgvector. This is on Fedora 42 and Postgres16. The packaged version of pgvector is 0.6.2 and it seems I need to compile from source to get a more recent one.

Then ran into conflicts trying to build pgvector, which seems to require postgresql-private-devel package that had conflicting requests with libpq-devel.

Resolved it by:

  •  sudo dnf install postgresql-server-devel --allowerasing
    
  • Build pgvector
  • Check installed version
    sudo -u postgres psql discourse_development -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';"
    
  •  sudo systemctl restart postgresql
    
2 лайка