Install Discourse for development using Docker

Thanks for the report @Aubrey @topological and @FlyingCat. We’ve now reverted that commit in Discourse core.

@cvx identified the cause of the issue, and opened an issue on the upstream mail gem:

Once that’s resolved, we’ll switch back to the official gem again.

6 Likes

I’m getting a different error on d/boot_dev --init. This is on a fresh install of Ubuntu 22.04 and following the guide in the OP

EDIT: Solved – it really doesn’t like being run as root. Make sure you are a normal user from the get go.

# d/boot_dev --init
Using source in: /root/dev/discourse
Using data in:   /root/dev/discourse/data/postgres
release: Pulling from discourse/discourse_dev
214ca5fb9032: Pull complete 
37cd9d4cd9e6: Pull complete 
9b38588fc778: Pull complete 
cb13139046fe: Pull complete 
1243de3fe752: Pull complete 
ec3e5331f9b3: Pull complete 
0fab0821518d: Pull complete 
9b5e686bba91: Pull complete 
428573951790: Pull complete 
38013f421bac: Pull complete 
733b166992df: Pull complete 
1fb3d7e57e63: Pull complete 
f76a1270a527: Pull complete 
133993b18ebe: Pull complete 
226b3b82cab1: Pull complete 
Digest: sha256:0a08c79cd8997e3bfac037625f2f5b2f26a64564113116b8c18969484b00a8ce
Status: Downloaded newer image for discourse/discourse_dev:release
docker.io/discourse/discourse_dev:release
439f53088cc4aab844a8864b779056a576c731ba4723d4cf8b23d0e97c8ae79c
Installing gems...
^TFollowing files may not be writable, so sudo is needed:
  /usr/local/bin
  /usr/local/lib/ruby/gems/2.7.0
  /usr/local/lib/ruby/gems/2.7.0/build_info
  /usr/local/lib/ruby/gems/2.7.0/cache
  /usr/local/lib/ruby/gems/2.7.0/doc
  /usr/local/lib/ruby/gems/2.7.0/extensions
  /usr/local/lib/ruby/gems/2.7.0/gems
  /usr/local/lib/ruby/gems/2.7.0/plugins
  /usr/local/lib/ruby/gems/2.7.0/specifications
Using rake 13.0.6
Using concurrent-ruby 1.1.10
Using i18n 1.10.0
Using minitest 5.15.0
Using tzinfo 2.0.4
Using activesupport 7.0.3
Using builder 3.2.4
Using erubi 1.10.0
Using racc 1.6.0
Using nokogiri 1.13.6 (x86_64-linux)
Using rails-dom-testing 2.0.3
Using crass 1.0.6
Using loofah 2.18.0
Using rails-html-sanitizer 1.4.2
Using actionview 7.0.3
Using rack 2.2.3
Using rack-test 1.1.0
Using actionpack 7.0.3
Using globalid 1.0.0
Using activejob 7.0.3
Using mini_mime 1.1.2
Using mail 2.8.0.edge from https://github.com/discourse/mail.git
Using digest 3.1.0
Using timeout 0.2.0
Using net-protocol 0.1.3
Using strscan 3.0.3
Using net-imap 0.2.3
Using net-pop 0.1.1
Using net-smtp 0.3.1
Using actionmailer 7.0.3
Using actionview_precompiler 0.2.3
Using activemodel 7.0.3
Using active_model_serializers 0.8.4
Using activerecord 7.0.3
Using public_suffix 4.0.7
Using addressable 2.8.0
Using annotate 3.2.0
Using ast 2.4.2
Using aws-eventstream 1.2.0
Using aws-partitions 1.583.0
Using aws-sigv4 1.5.0
Using jmespath 1.6.1
Using aws-sdk-core 3.130.2
Using aws-sdk-kms 1.56.0
Using aws-sdk-s3 1.114.0
Using aws-sdk-sns 1.53.0
Using ember-source 2.18.2
Using execjs 2.8.1
Using barber 0.12.2
Using coderay 1.1.3
Using better_errors 2.9.1
Using debug_inspector 1.1.0
Using binding_of_caller 1.0.0
Using msgpack 1.5.1
Using bootsnap 1.11.1
Using uniform_notifier 1.16.0
Using bullet 7.0.1
Using bundler 2.3.13
Using byebug 11.1.3
Using cbor 0.5.9.6
Using certified 1.0.0
Using chunky_png 1.4.0
Using colored2 3.1.2
Using connection_pool 2.2.5
Using ipaddr 1.2.4
Using openssl 2.2.1
Using openssl-signature_algorithm 1.1.1
Using cose 1.2.0
Using cppjieba_rb 0.4.2
Using rexml 3.2.5
Using crack 0.4.5
Using css_parser 1.11.0
Using diff-lcs 1.5.0
Using diffy 3.4.0
Using ember-data-source 3.0.2
Using sprockets 3.7.2
Using ember-handlebars-template 0.8.0
Using method_source 1.0.0
Using thor 1.2.1
Using zeitwerk 2.5.4
Using railties 7.0.3
Using jquery-rails 4.4.0
Using discourse-ember-rails 0.18.6
Using discourse-ember-source 3.12.2.3
Using discourse-fonts 0.0.9
Using faker 2.21.0
Using literate_randomizer 0.4.0
Using discourse_dev_assets 0.0.4
Using docile 1.4.0
Using regexp_parser 2.4.0
Using ecma-re-validator 0.4.0
Using email_reply_trimmer 0.1.13
Using excon 0.92.3
Using exifr 1.3.9
Using fabrication 2.28.0
Using fakeweb 1.3.0
Using faraday-em_http 1.0.0
Using faraday-em_synchrony 1.0.0
Using faraday-excon 1.1.0
Using faraday-httpclient 1.0.1
Using multipart-post 2.1.1
Using faraday-multipart 1.0.3
Using faraday-net_http 1.0.1
Using faraday-net_http_persistent 1.2.0
Using faraday-patron 1.0.0
Using faraday-rack 1.0.0
Using faraday-retry 1.0.3
Using ruby2_keywords 0.0.5
Using faraday 1.10.0
Using fast_blank 1.0.1
Using fast_xs 0.8.0
Using fastimage 2.2.6
Using ffi 1.15.5
Using fspath 3.1.2
Using gc_tracer 1.5.1
Using guess_html_encoding 0.0.11
Using hana 1.3.7
Using hashdiff 1.0.1
Using hashie 5.0.0
Using highline 2.0.3
Using hkdf 0.3.0
Using htmlentities 4.3.4
Using http_accept_language 2.1.1
Using image_size 3.0.1
Using in_threads 1.6.0
Using progress 3.6.0
Using image_optim 0.31.1
Using json 2.6.1
Using json-schema 2.8.1
Using uri_template 0.7.0
Using json_schemer 0.2.21
Using jwt 2.3.0
Using kgio 2.11.4
Using libv8-node 16.10.0.0 (x86_64-linux)
Using rb-fsevent 0.11.1
Using rb-inotify 0.10.1
Using listen 3.7.1
Using request_store 1.5.1
Using lograge 0.12.0
Using logstash-event 1.2.02
Using logstash-logger 0.26.1
Using logster 2.11.2
Using lru_redux 1.1.0
Using lz4-ruby 0.3.3
Using maxminddb 0.1.22
Using memory_profiler 1.0.0
Using message_bus 4.2.0
Using mini_racer 0.6.2
Using redis 4.5.1
Using sidekiq 6.4.2
Using mini_scheduler 0.13.0
Using mini_sql 1.4.0
Using mini_suffix 0.3.3
Using mocha 1.14.0
Using multi_json 1.15.0
Using multi_xml 0.6.0
Using mustache 1.1.1
Using uri 0.11.0
Using net-http 0.2.2
Using nio4r 2.5.8
Using oauth 0.5.10
Using oauth2 1.4.7
Using oj 3.13.11
Using omniauth 1.9.1
Using omniauth-oauth2 1.7.2
Using omniauth-facebook 9.0.0
Using omniauth-github 1.4.0
Using omniauth-google-oauth2 0.8.2
Using omniauth-oauth 1.2.0
Using omniauth-twitter 1.4.0
Using optimist 3.0.1
Using parallel 1.22.1
Using parallel_tests 3.8.1
Using parser 3.1.2.0
Using pg 1.3.5
Using pry 0.13.1
Using pry-byebug 3.9.0
Using pry-rails 0.3.9
Using puma 5.6.4
Using r2 0.2.7
Using rack-mini-profiler 3.0.0
Using rack-protection 2.2.0
Using rails_failover 0.8.1
Using rails_multisite 4.0.1
Using rainbow 3.1.1
Using raindrops 0.20.0
Using rbtrace 0.4.14
Using rchardet 1.8.0
Using redis-namespace 1.8.2
Using rinku 2.0.6
Using rotp 6.2.0
Using rqrcode_core 1.2.0
Using rqrcode 2.1.1
Using rspec-support 3.11.0
Using rspec-core 3.11.0
Using rspec-expectations 3.11.0
Using rspec-mocks 3.11.1
Using rspec 3.11.0
Using rspec-html-matchers 0.9.4
Using rspec-rails 5.1.2
Using rss 0.2.9
Using rswag-specs 2.5.1
Using rubocop-ast 1.18.0
Using ruby-progressbar 1.11.0
Using unicode-display_width 2.1.0
Using rubocop 1.29.1
Using rubocop-rspec 2.10.0
Using rubocop-discourse 2.5.0
Using ruby-prof 1.4.3
Using ruby-readability 0.7.0
Using rubyzip 2.3.2
Using sanitize 6.0.0
Using sassc 2.0.1
Using sprockets-rails 3.4.2
Using tilt 2.0.10
Using sassc-rails 2.1.2
Using seed-fu 2.3.9
Using shoulda-matchers 5.1.0
Using simplecov-html 0.12.3
Using simplecov_json_formatter 0.1.4
Using simplecov 0.21.2
Using sshkey 2.0.0
Using stackprof 0.2.19
Using test-prof 1.0.9
Using uglifier 4.2.0
Using unf_ext 0.0.8.1
Using unf 0.1.4
Using unicorn 6.1.0
Using webmock 3.14.0
Using webpush 1.1.0
Using xorcist 1.1.2
Using yaml-lint 0.0.10
Bundle complete! 126 Gemfile dependencies, 232 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
1 installed gem you directly depend on is looking for funding.
  Run `bundle fund` for details
Migrating database...
rake aborted!
Errno::EACCES: Permission denied @ dir_s_mkdir - /src/app/assets/javascripts/plugins
/src/lib/plugin/instance.rb:449:in `ensure_directory'
/src/lib/plugin/instance.rb:721:in `activate!'
/src/lib/discourse.rb:279:in `block in activate_plugins!'
/src/lib/discourse.rb:276:in `each'
/src/lib/discourse.rb:276:in `activate_plugins!'
/src/config/application.rb:222:in `block in <class:Application>'
/src/lib/plugin.rb:6:in `initialization_guard'
/src/config/application.rb:221:in `<class:Application>'
/src/config/application.rb:81:in `<module:Discourse>'
/src/config/application.rb:80:in `<main>'
/src/Rakefile:7:in `<main>'
(See full trace by running task with --trace)
# d/rails s
Traceback (most recent call last):
	8: from /src/bin/unicorn:70:in `<main>'
	7: from /src/bin/unicorn:38:in `ensure_cache_clean!'
	6: from /usr/local/lib/ruby/2.7.0/fileutils.rb:211:in `mkdir_p'
	5: from /usr/local/lib/ruby/2.7.0/fileutils.rb:211:in `each'
	4: from /usr/local/lib/ruby/2.7.0/fileutils.rb:226:in `block in mkdir_p'
	3: from /usr/local/lib/ruby/2.7.0/fileutils.rb:226:in `reverse_each'
	2: from /usr/local/lib/ruby/2.7.0/fileutils.rb:228:in `block (2 levels) in mkdir_p'
	1: from /usr/local/lib/ruby/2.7.0/fileutils.rb:250:in `fu_mkdir'
/usr/local/lib/ruby/2.7.0/fileutils.rb:250:in `mkdir': Permission denied @ dir_s_mkdir - /src/tmp (Errno::EACCES)
1 Like


how do I disable cors for development?
I want to send cors requests from the origin of http://localhost:3001 but the cors_origin setting has no effect. the Access-Control-Allow-Origin header does not appear.
never mind. I solved it. seems like the enable_cors setting is ignored in dev mode.

so the cors middleware is never installed. I just removed the if statement in my local discourse repo so the middleware is installed in any case.

Maybe a dev (or this guide’s author @rishabh maybe?) can help me out here. I followed the OP guide to the letter, on a new VM install with Ubuntu 22.04, using a user (non-root) account.

  • Symlinking the plugin into the discourse/plugins/ subfolder, changes in the plugin’s initializer JS code is not seen unless I do d/shutdown_dev; d/boot_dev, despite restarting d/rails s and d/ember-cli

  • Copying the plugin into the discourse/plugins/ subfolder, changes in the plugin’s initializer JS code is seen without doing d/shutdown_dev; d/boot_dev but only restarting d/rails s and d/ember-cli

The plugin in question is discourse-math, and the code I’m changing is in assets/initializers/javascript/*.js. I noticed these files are side-loaded and not HTTP GET called by the browser directly (not sure if it makes a difference).

p.s. I’m only new to Discourse, not to web/JS development (in other words, no need to ask me if I refreshed the browser :slight_smile: )

Can a dev please check this error out, it seems to be related to Ruby rather than something specific to my situation. I was installing Discourse for Development on Windows following these instructions for the Docker install which I have done successfully several times. The script got as far as the database installation and bounced. The first warning does not look fatal but there’s a missing xss.min.js file further down this dump which was fatal:

‘’'You are attempting to run migrations in your test environment and are not loading plugins, setting LOAD_PLUGINS to 1
DEPRECATION WARNING: Using legacy connection handling is deprecated. Please set
legacy_connection_handling to false in your application.

The new connection handling does not support connection_handlers
getter and setter.

Read more about how to migrate at: Multiple Databases with Active Record — Ruby on Rails Guides
(called from at /src/config/environment.rb:7)
== 20150501152228 RenameTotalVotesToVoters: migrating =========================
== 20150501152228 RenameTotalVotesToVoters: migrated (0.0106s) ================

== 20151016163051 MergePollsVotes: migrating ==================================
== 20151016163051 MergePollsVotes: migrated (0.0017s) =========================

== 20160321164925 ClosePollsInClosedTopics: migrating =========================
== 20160321164925 ClosePollsInClosedTopics: migrated (0.0281s) ================

== 20180820073549 CreatePollsTables: migrating ================================
– create_table(:polls, {})
→ 0.0067s
– add_index(:polls, [:post_id, :name], {:unique=>true})
→ 0.0008s
– create_table(:poll_options, {})
→ 0.0039s
– add_index(:poll_options, [:poll_id, :digest], {:unique=>true})
→ 0.0009s
– create_table(:poll_votes, {:id=>false})
→ 0.0044s
– add_index(:poll_votes, [:poll_id, :poll_option_id, :user_id], {:unique=>true})
→ 0.0006s
== 20180820073549 CreatePollsTables: migrated (0.0188s) =======================

== 20180820080623 MigratePollsData: migrating =================================
– execute(“INSERT INTO post_custom_fields (name, value, post_id, created_at, updated_at)\nSELECT ‘has_polls’, ‘t’, post_id, MIN(created_at), MIN(updated_at)\n FROM polls\n GROUP BY post_id\n”)
→ 0.0008s
== 20180820080623 MigratePollsData: migrated (0.0033s) ========================

== 20191114160613 AddGraphToPolls: migrating ==================================
– add_column(:polls, :chart_type, :integer, {:default=>0, :null=>false})
→ 0.0012s
== 20191114160613 AddGraphToPolls: migrated (0.0020s) =========================

== 20191206123012 AddGroupNameToPolls: migrating ==============================
– add_column(:polls, :groups, :string, {})
→ 0.0005s
== 20191206123012 AddGroupNameToPolls: migrated (0.0012s) =====================

== 20200520015508 ClearLastGravatarDownloadAttemptOnUserAvatars: migrating ====
– execute(“UPDATE user_avatars\nSET last_gravatar_download_attempt = null\nWHERE user_id = -2 AND custom_upload_id IS NULL AND gravatar_upload_id IS NULL\n”)
→ 0.0006s
== 20200520015508 ClearLastGravatarDownloadAttemptOnUserAvatars: migrated (0.0014s)

== 20200804144550 AddTitleToPolls: migrating ==================================
– add_column(:polls, :title, :string, {})
→ 0.0005s
== 20200804144550 AddTitleToPolls: migrated (0.0011s) =========================

rake aborted!
Errno::ENOENT: No such file or directory @ rb_sysopen - /src/app/assets/javascripts/node_modules/xss/dist/xss.min.js
/src/lib/pretty_text.rb:613:in block in ctx_load' /src/lib/pretty_text.rb:612:in each’
/src/lib/pretty_text.rb:612:in ctx_load' /src/lib/pretty_text.rb:108:in create_es6_context’
/src/lib/pretty_text.rb:153:in block in v8' /src/lib/pretty_text.rb:151:in synchronize’
/src/lib/pretty_text.rb:151:in v8' /src/lib/pretty_text.rb:190:in block in markdown’
/src/lib/pretty_text.rb:606:in block in protect' /src/lib/pretty_text.rb:605:in synchronize’
/src/lib/pretty_text.rb:605:in protect' /src/lib/pretty_text.rb:189:in markdown’
/src/lib/pretty_text.rb:318:in cook' /src/app/models/user_profile.rb:149:in cooked’
/src/app/models/user_profile.rb:158:in cook' (eval):51:in block (2 levels) in run_file’
/src/lib/tasks/db.rake:234:in block (2 levels) in <main>' /src/lib/distributed_mutex.rb:57:in block in synchronize’
/src/lib/distributed_mutex.rb:53:in synchronize' /src/lib/distributed_mutex.rb:53:in synchronize’
/src/lib/distributed_mutex.rb:38:in synchronize' /src/lib/tasks/db.rake:214:in block in ’
Tasks: TOP => db:migrate
(See full trace by running task with --trace)‘’’

3 Likes

Thank you so much for this great resource. A couple of points to help:

  1. Here is a command to completely delete and restart the data:
    docker stop discourse_dev ; docker rm discourse_dev ; sudo rm -rf data ; rm -rf tmp/*

  2. If you are having migration problems like above, ensure that you have the correct permissions. You must be part of the docker group or sudo (bad second option).

  3. let d/rails s complete before launching d/ember-cli, otherwise there is some weirdness

1 Like

Thanks for this, Tarek.

After wiping the install and repeating the cloning process the exact same error occured during the initialization, ie;
"rake aborted!
“Errno::ENOENT: No such file or directory @ rb_sysopen”

However this time I was able to proceed successfully and got to “Congratulations.” Thank you.

Now, because the script terminated early, there is no dev admin email, and no config file. It would be nice if somebody figured out the problem with the initialization.

I configured an admin email using the command “d/rake admin:create” and entered a valid email and (minimum 10 character) password.

I was then able to successfully launch Discourse in a browser as instructed.

2 Likes

Anyone here using Fedora? This adds some more complexity, because Podman and SELinux are used for enhanced security. Podman is not really an issue I hope, it’s OCI compliant and having podman-docker installed, all Docker commands are translated to Podman commands. For SELinux I think I’ve found the proper fix as well, but still I run into an issue.

So while in the discourse directory, I run this command mkdir -vp data/postgres; sudo semanage fcontext -a -t svirt_sandbox_file_t "/home/user/discourse/data(/.*)?" && restorecon -rv . to apply an SELinux context label that I think is sufficient for this (at least, the SELinux errors are gone)

But I then still run into this error:

[user@fedora discourse]$ d/boot_dev --init
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
Error: template: info:1:2: executing "info" at <.Architecture>: can't evaluate field Architecture in type *define.Info
WARNING: Docker architecture is not x86_64.
Discourse development is unlikely to work using Docker's architecture emulation.
Please try a native development installation.
Using source in: /home/user/discourse
Using data in:   /home/user/discourse/data/postgres
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
✔ docker.io/discourse/discourse_dev:release
Trying to pull docker.io/discourse/discourse_dev:release...
Getting image source signatures
Copying blob b42e9bacf67a done  
Copying blob 3257b89dc3e0 done  
Copying blob 8f87c7014fb0 done  
Copying blob bf00c24d0f5b done  
Copying blob 10e0cd28eb63 done  
Copying blob 1efc276f4ff9 done  
Copying blob 6d9350d0e59c done  
Copying blob 84ee3423e706 done  
Copying blob ee2701209d47 done  
Copying blob ce48a2c1c5d3 done  
Copying blob 2f702c3c2f9f done  
Copying blob 27762615d0fc done  
Copying blob 7056a5796a1a done  
Copying blob c8a22dd30e4c done  
Copying blob 1a93cd2f0c23 done  
Copying config 6365e737b9 done  
Writing manifest to image destination
Storing signatures
6365e737b90aea36af1fd9ed029db43a0a620f1c285416546f5e6ee728aca4c5
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
5282393e248e33800e235b4405c9a7197d10a3fc1d405450f1c99d2a5c7c85c7
Installing gems...
Emulate Docker CLI using podman. Create /etc/containers/nodocker to quiet msg.
Could not locate Gemfile

The systemd journal reports this:

Aug 09 18:47:45 fedora podman[19380]: 2022-08-09 18:47:45.841001786 +0200 CEST m=+0.137712533 image pull  discourse/discourse_dev:release
Aug 09 18:47:45 fedora podman[19380]: 
Aug 09 18:47:46 fedora podman[19380]: 2022-08-09 18:47:46.043506861 +0200 CEST m=+0.340217585 container create 5282393e248e33800e235b4405c9a7197d10a3fc1d405450f1c99d2a5c7c85c7 (image=docker.io/discourse/discourse_dev:release, name=discourse_dev)
Aug 09 18:47:46 fedora kernel: tun: Universal TUN/TAP device driver, 1.6
Aug 09 18:47:46 fedora systemd[1684]: selinux: avc:  op=load_policy lsm=selinux seqno=7 res=1
Aug 09 18:47:46 fedora systemd[1684]: selinux: Regex version mismatch, expected: 10.39 2021-10-29 actual: 10.40 2022-04-14
Aug 09 18:47:46 fedora systemd[1684]: selinux: Regex version mismatch, expected: 10.39 2021-10-29 actual: 10.40 2022-04-14
Aug 09 18:47:46 fedora systemd[1684]: selinux: Regex version mismatch, expected: 10.39 2021-10-29 actual: 10.40 2022-04-14
Aug 09 18:47:46 fedora systemd[1684]: Started libpod-conmon-5282393e248e33800e235b4405c9a7197d10a3fc1d405450f1c99d2a5c7c85c7.scope.
Aug 09 18:47:46 fedora systemd[1684]: Started libpod-5282393e248e33800e235b4405c9a7197d10a3fc1d405450f1c99d2a5c7c85c7.scope - libcrun container.
Aug 09 18:47:46 fedora chronyd[792]: Selected source 158.101.221.122 (2.fedora.pool.ntp.org)
Aug 09 18:47:46 fedora podman[19380]: 2022-08-09 18:47:46.370028125 +0200 CEST m=+0.666738859 container init 5282393e248e33800e235b4405c9a7197d10a3fc1d405450f1c99d2a5c7c85c7 (image=docker.io/discourse/discourse_dev:release, name=discourse_dev)
Aug 09 18:47:46 fedora podman[19380]: 2022-08-09 18:47:46.433863112 +0200 CEST m=+0.730573845 container start 5282393e248e33800e235b4405c9a7197d10a3fc1d405450f1c99d2a5c7c85c7 (image=docker.io/discourse/discourse_dev:release, name=discourse_dev)
Aug 09 18:47:46 fedora discourse_dev[19420]: run-parts: executing /etc/runit/1.d/00-fix-var-logs
Aug 09 18:47:46 fedora discourse_dev[19420]: run-parts: executing /etc/runit/1.d/anacron
Aug 09 18:47:46 fedora discourse_dev[19420]: run-parts: executing /etc/runit/1.d/cleanup-pids
Aug 09 18:47:46 fedora discourse_dev[19420]: Cleaning stale PID files
Aug 09 18:47:46 fedora discourse_dev[19420]: run-parts: executing /etc/runit/1.d/ensure-database
Aug 09 18:47:47 fedora podman[19425]: 2022-08-09 18:47:47.698175757 +0200 CEST m=+1.211177315 container exec 5282393e248e33800e235b4405c9a7197d10a3fc1d405450f1c99d2a5c7c85c7 (image=docker.io/discourse/discourse_dev:release, name=discourse_dev)
Aug 09 18:47:48 fedora discourse_dev[19420]: Started runsvdir, PID is 29
Aug 09 18:47:48 fedora podman[19425]: 2022-08-09 18:47:48.535303673 +0200 CEST m=+2.048305123 container exec_died 5282393e248e33800e235b4405c9a7197d10a3fc1d405450f1c99d2a5c7c85c7 (image=docker.io/discourse/discourse_dev:release, name=discourse_dev, execID=166d86f7ca8739899bd59801c2f8bb3d9b940329d8e6bb29d0f45ad82e9d60b0)

The log dir in the discourse directory is empty, how could I troubleshoot this better?

The paths seem to set correctly to find the Gem file.

[user@fedora discourse]$ SCRIPTPATH=$(cd "$(dirname "$0")" > /dev/null; pwd -P)
[user@fedora discourse]$ echo $SCRIPTPATH 
/home/user/discourse

I had some success ages ago with a virtual Fedora Dev environment from scratch but couldn’t get a production setup to work. I also asked the Podman Q which someone kindly responded to say it was possible but lots of stuff to change which he didn’t have time to do . .

I would love to get Dev and Prod Fedora versions going . .

2 Likes

I don’t get this question. It aborts with this:

rake aborted!
Errno::ENOENT: No such file or directory @ rb_sysopen - /src/app/assets/javascripts/node_modules/xss/dist/xss.min.js
/src/lib/pretty_text.rb:613:in `block in ctx_load'
/src/lib/pretty_text.rb:612:in `each'
/src/lib/pretty_text.rb:612:in `ctx_load'
/src/lib/pretty_text.rb:108:in `create_es6_context'
/src/lib/pretty_text.rb:153:in `block in v8'
/src/lib/pretty_text.rb:151:in `synchronize'
/src/lib/pretty_text.rb:151:in `v8'
/src/lib/pretty_text.rb:190:in `block in markdown'
/src/lib/pretty_text.rb:606:in `block in protect'
/src/lib/pretty_text.rb:605:in `synchronize'
/src/lib/pretty_text.rb:605:in `protect'
/src/lib/pretty_text.rb:189:in `markdown'
/src/lib/pretty_text.rb:318:in `cook'
/src/app/models/user_profile.rb:149:in `cooked'
/src/app/models/user_profile.rb:158:in `cook'
(eval):51:in `block (2 levels) in run_file'
/src/lib/tasks/db.rake:234:in `block (2 levels) in <main>'
/src/lib/distributed_mutex.rb:57:in `block in synchronize'
/src/lib/distributed_mutex.rb:53:in `synchronize'
/src/lib/distributed_mutex.rb:53:in `synchronize'
/src/lib/distributed_mutex.rb:38:in `synchronize'
/src/lib/tasks/db.rake:214:in `block in <main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

I would like to use Ubuntu, but for some reason it doesn’t work well with the spice-vdagent, many graphic errors when running the VM. Fedora works smooth as butter… I thought containers fixed portability :stuck_out_tongue: I guess I’ll just setup a headless Ubuntu system and login via SSH.


I get the same error in Ubuntu Server 22.04

I have this issue too. Followed and double checked the suggestions from @tarek. The issue keeps returning. Also cleaned up the entire discourse directory and started from scratch. Using Ubuntu 22.04.01 in a VM and using the latest Docker available for Ubuntu.

1 Like

As of the current git master, this will not complete successfully. I believe it’s a bug in core. To get a dev environment up and running, do the following after the error:

d/rake db:migrate
d/rake admin:create
d/rails s

plus in the next two terminals, d/ember-cli and d/mailhog.

4 Likes

Any idea about how I can stop d/rails s from showing all of the query output? It makes it much harder to use byebug and such to figure out where bugs are for me.

2 Likes

Try: DISCOURSE_DEV_LOG_LEVEL=info bin/rails s

More tips here: Debugging Ruby with Byebug - Development - Discourse Plugin Manager

7 Likes

Hello,

I’m trying to run this on Ubuntu on stable (v2.8.8), and I’m getting the following errors:

Migrating database...
== 20220104053343 AddBookmarkPolymorphicColumns: migrating ====================
-- add_column(:bookmarks, :bookmarkable_id, :integer)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::DuplicateColumn: ERROR:  column "bookmarkable_id" of relation "bookmarks" already exists
/src/lib/migration/safe_migrate.rb:92:in `async_exec'
/src/db/migrate/20220104053343_add_bookmark_polymorphic_columns.rb:5:in `change'
/src/lib/freedom_patches/schema_migration_details.rb:9:in `block in exec_migration'
/src/lib/freedom_patches/schema_migration_details.rb:8:in `exec_migration'
/src/lib/migration/safe_migrate.rb:28:in `migrate'
/src/lib/migration/safe_migrate.rb:55:in `migrate'
/src/lib/tasks/db.rake:218:in `block (2 levels) in <main>'
/src/lib/distributed_mutex.rb:33:in `block in synchronize'
/src/lib/distributed_mutex.rb:29:in `synchronize'
/src/lib/distributed_mutex.rb:29:in `synchronize'
/src/lib/distributed_mutex.rb:14:in `synchronize'
/src/lib/tasks/db.rake:210:in `block in <main>'

Caused by:
ActiveRecord::StatementInvalid: PG::DuplicateColumn: ERROR:  column "bookmarkable_id" of relation "bookmarks" already exists
/src/lib/migration/safe_migrate.rb:92:in `async_exec'
/src/db/migrate/20220104053343_add_bookmark_polymorphic_columns.rb:5:in `change'
/src/lib/freedom_patches/schema_migration_details.rb:9:in `block in exec_migration'
/src/lib/freedom_patches/schema_migration_details.rb:8:in `exec_migration'
/src/lib/migration/safe_migrate.rb:28:in `migrate'
/src/lib/migration/safe_migrate.rb:55:in `migrate'
/src/lib/tasks/db.rake:218:in `block (2 levels) in <main>'
/src/lib/distributed_mutex.rb:33:in `block in synchronize'
/src/lib/distributed_mutex.rb:29:in `synchronize'
/src/lib/distributed_mutex.rb:29:in `synchronize'
/src/lib/distributed_mutex.rb:14:in `synchronize'
/src/lib/tasks/db.rake:210:in `block in <main>'

Caused by:
PG::DuplicateColumn: ERROR:  column "bookmarkable_id" of relation "bookmarks" already exists
/src/lib/migration/safe_migrate.rb:92:in `async_exec'
/src/db/migrate/20220104053343_add_bookmark_polymorphic_columns.rb:5:in `change'
/src/lib/freedom_patches/schema_migration_details.rb:9:in `block in exec_migration'
/src/lib/freedom_patches/schema_migration_details.rb:8:in `exec_migration'
/src/lib/migration/safe_migrate.rb:28:in `migrate'
/src/lib/migration/safe_migrate.rb:55:in `migrate'
/src/lib/tasks/db.rake:218:in `block (2 levels) in <main>'
/src/lib/distributed_mutex.rb:33:in `block in synchronize'
/src/lib/distributed_mutex.rb:29:in `synchronize'
/src/lib/distributed_mutex.rb:29:in `synchronize'
/src/lib/distributed_mutex.rb:14:in `synchronize'
/src/lib/tasks/db.rake:210:in `block in <main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

I’ve tried to do:

d/rake db:migrate RAILS_ENV=development

But I end up with the same error. Has anyone gone through this as well?

Got a suspicion you are using the same database as you did before, so it’s already migrated?

Actually @hyphalos I take that back, I can repro this with the following shell commands inside the container:

discourse@discourse:/src$ sudo su postgres -c 'psql discourse -c "drop database discourse_test"'
DROP DATABASE
discourse@discourse:/src$ sudo su postgres -c 'psql discourse -c "create database discourse_test"'
CREATE DATABASE
discourse@discourse:/src$ sudo su postgres -c 'psql -c "grant all privileges on database discourse_test to discourse;"'
GRANT
discourse@discourse:/src$ RAILS_ENV=test rake db:migrate

Something not right here?

Seems like this migration can be problematic?:

== 20220104053343 AddBookmarkPolymorphicColumns: migrating ====================
-- add_column(:bookmarks, :bookmarkable_id, :integer)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::DuplicateColumn: ERROR:  column "bookmarkable_id" of relation "bookmarks" already exist

which is weird (?) because:

discourse_test=> \d bookmarks
                                                Table "public.bookmarks"
         Column         |              Type              | Collation | Nullable |                Default
------------------------+--------------------------------+-----------+----------+---------------------------------------
 id                     | bigint                         |           | not null | nextval('bookmarks_id_seq'::regclass)
 user_id                | bigint                         |           | not null |
 post_id                | bigint                         |           | not null |
 name                   | character varying(100)         |           |          |
 reminder_at            | timestamp without time zone    |           |          |
 created_at             | timestamp(6) without time zone |           | not null |
 updated_at             | timestamp(6) without time zone |           | not null |
 reminder_last_sent_at  | timestamp without time zone    |           |          |
 reminder_set_at        | timestamp without time zone    |           |          |
 auto_delete_preference | integer                        |           | not null | 0
 pinned                 | boolean                        |           |          | false
 for_topic              | boolean                        |           | not null | false
Indexes:
    "bookmarks_pkey" PRIMARY KEY, btree (id)
    "index_bookmarks_on_post_id" btree (post_id)
    "index_bookmarks_on_reminder_at" btree (reminder_at)
    "index_bookmarks_on_reminder_set_at" btree (reminder_set_at)
    "index_bookmarks_on_user_id" btree (user_id)
    "index_bookmarks_on_user_id_and_post_id_and_for_topic" UNIQUE, btree (user_id, post_id, for_topic)

This doesn’t afflict tests-passed it seems, only stable branch?

thanks to @RGJ this might shed some light:

cc: @pfaffman

1 Like

Hey @Robert,

I thought I was going crazy, I thought I was the only one experiencing this. I’ve struggled to find a work around for this. I have an earlier post here where I found a workaround for the bookmark issue, but ran into another issue:

Can someone point me in the right direction to fix this?
This occurs when I try to run d/boot_dev --init

rake aborted!
ActiveRecord::ConnectionNotEstablished: connection to server at "127.0.0.1", port 5432 failed: Connection refused
        Is the server running on that host and accepting TCP/IP connections?
connection to server at "::1", port 5432 failed: Cannot assign requested address
        Is the server running on that host and accepting TCP/IP connections?
/src/config/initializers/006-ensure_login_hint.rb:8:in `block in <main>'
/src/config/environment.rb:7:in `<main>'

Caused by:
PG::ConnectionBad: connection to server at "127.0.0.1", port 5432 failed: Connection refused
        Is the server running on that host and accepting TCP/IP connections?
connection to server at "::1", port 5432 failed: Cannot assign requested address
        Is the server running on that host and accepting TCP/IP connections?
/src/config/initializers/006-ensure_login_hint.rb:8:in `block in <main>'
/src/config/environment.rb:7:in `<main>'
Tasks: TOP => db:migrate => db:load_config => environment
(See full trace by running task with --trace)

Thanks for any/all help in advance :smile:

1 Like

I am getting the following error when running d/boot_dev --init

...
...
...
== 20221219082223 AddIndexToChatMessages: migrated (0.0138s) ==================

rake aborted!
Errno::ENOENT: No such file or directory @ rb_sysopen - /src/app/assets/javascripts//node_modules/loader.js/dist/loader/loader.js
/src/lib/pretty_text.rb:637:in `block in ctx_load'
/src/lib/pretty_text.rb:636:in `each'
/src/lib/pretty_text.rb:636:in `ctx_load'
/src/lib/pretty_text.rb:97:in `create_es6_context'
/src/lib/pretty_text.rb:144:in `block in v8'
/src/lib/pretty_text.rb:142:in `synchronize'
/src/lib/pretty_text.rb:142:in `v8'
/src/lib/pretty_text.rb:184:in `block in markdown'
/src/lib/pretty_text.rb:630:in `block in protect'
/src/lib/pretty_text.rb:629:in `synchronize'
/src/lib/pretty_text.rb:629:in `protect'
/src/lib/pretty_text.rb:183:in `markdown'
/src/lib/pretty_text.rb:328:in `cook'
/src/app/models/user_profile.rb:149:in `cooked'
/src/app/models/user_profile.rb:158:in `cook'
(eval):51:in `block (2 levels) in run_file'
/src/lib/tasks/db.rake:234:in `block (2 levels) in <main>'
/src/lib/distributed_mutex.rb:57:in `block in synchronize'
/src/lib/distributed_mutex.rb:53:in `synchronize'
/src/lib/distributed_mutex.rb:53:in `synchronize'
/src/lib/distributed_mutex.rb:38:in `synchronize'
/src/lib/tasks/db.rake:214:in `block in <main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

1 Like