Install Discourse for development using Docker

Same, it errors when trying to bake the admin user profile. It works after adding a step to yarn install before creating the admin as suggested by @zergov. I went ahead and created a PR to add it: DEV: Yarn install to avoid error creating the admin user. by dsims · Pull Request #20866 · discourse/discourse · GitHub

Follow-up:
Docker Rootless mode causes the same permission mapping issues on Linux as Docker Desktop. The workaround I posted will work with this configuration, too.

However, I’m not super confident with the workaround, so I switched to a native Docker installation on my Linux system, added my non-sudo user to the docker group and now the permissions are mapped correctly inside the container and I can run docker commands without sudo.

Thanks @dsims, I just merged the PR :raised_hands:

1 Like

I get this far when using podman (trying to run d/boot_dev --init):

Installing gems...
Error response from daemon: environment variable "RAILS_ENV" badly formed, must be key=value

I guess I’ll need to use the native development environment approach as I’m not going to install docker on my Fedora desktop as it has been really broken for years now (with random stuff like pushing not working) and podman works so much better without any hassle (for projects that support it).

error
error Could not write file “/src/app/assets/javascripts/discourse/yarn-error.log”: “EACCES: permission denied, open ‘/src/app/assets/javascripts/discourse/yarn-error.log’”
error An unexpected error occurred: “EACCES: permission denied, mkdir ‘/src/app/assets/javascripts/node_modules’”.

Why do I get this error following by d/boot_dev --init?

3.0" has incorrect peer dependency "@uppy/core@^3.2.1".
[4/4] Building fresh packages...
$ ../run-patch-package
patch-package 8.0.0
Applying patches...
@ember/jquery@2.0.0 ✔
babel-plugin-debug-macros@0.3.4 ✔
content-tag@1.1.1 ✔
ember-source@3.28.12 ✔
ember-this-fallback@0.3.1 (1 initial) ✔
ember-this-fallback@0.3.1 (2 themes) ✔
virtual-dom@2.1.1 ✔
Done in 101.54s.
Migrating database...
rake aborted!
Discourse::Utils::CommandError: /src/lib/discourse.rb:138:in `exec': node:internal/modules/cjs/loader:1080
  throw err;
  ^

Error: Cannot find module 'esbuild'
Require stack:
- /src/app/assets/javascripts/theme-transpiler/build.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:121:18)
    at Object.<anonymous> (/src/app/assets/javascripts/theme-transpiler/build.js:3:17)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/src/app/assets/javascripts/theme-transpiler/build.js' ]
}

Node.js v18.17.1
/src/lib/discourse.rb:172:in `execute_command'
/src/lib/discourse.rb:138:in `exec'
/src/lib/discourse.rb:34:in `execute_command'
/src/lib/discourse_js_processor.rb:119:in `build_theme_transpiler'
/src/lib/tasks/assets.rake:313:in `block in <main>'
Tasks: TOP => db:migrate => assets:precompile:theme_transpiler
(See full trace by running task with --trace)

Possibly related to this: Install Discourse for development using Docker - #239 by zergov

Maybe try going to the /var/www/discourse directory and running:

yarn install

Does anybody have some benchmarks about it?

I give a search in this topic but I didn’t found this specifically. I wonder if someone tried the normal and docker installation to compare between them :slight_smile:

A few hints for those who are trying to use the procedure described in this topic:

  1. Step 1 didn’t work for me. In order to install Docker, I had to use the “convenience script” describe here: Install Docker Engine on Ubuntu | Docker Docs

  2. You need sudo for all commands

  3. There seems to be a missing step 3: you need to create an admin user account. To create a new admin, run the following command: sudo d/rails admin:create

  4. As stated in the topic, if you use WSL, symlinks to the Windows file system won’t work. If you try anyway, you’ll break the install and end up with missing gems. To get your gems back, run: sudo d/bundle install

2 Likes

Hello.

I’m trying to install the development in a Debian 12.

When I run the command…

d/boot_dev --init

… after a while the following error appears:

$ ../run-patch-package
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 ✔
Done in 70.39s.
Migrating database...
rake aborted!
Discourse::Utils::CommandError: /src/lib/discourse.rb:138:in `exec': node:internal/modules/cjs/loader:1080
  throw err;
  ^

Error: Cannot find module 'esbuild'
Require stack:
- /src/app/assets/javascripts/theme-transpiler/build.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:121:18)
    at Object.<anonymous> (/src/app/assets/javascripts/theme-transpiler/build.js:3:17)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/src/app/assets/javascripts/theme-transpiler/build.js' ]
}

Node.js v18.17.1
/src/lib/discourse.rb:172:in `execute_command'
/src/lib/discourse.rb:138:in `exec'
/src/lib/discourse.rb:34:in `execute_command'
/src/lib/discourse_js_processor.rb:119:in `build_theme_transpiler'
/src/lib/tasks/assets.rake:313:in `block in <main>'
Tasks: TOP => db:migrate => assets:precompile:theme_transpiler
(See full trace by running task with --trace)```

Am I doing something wrong?
1 Like
yarn install # this will reinstall everything including esbuild
# removing previously error installed container
docker stop discourse_dev
docker rm discourse_dev
d/boot_dev --init
# It will prompt you input admin email if succeed.

Hello. After having placed a symlink in the discourse/plugin directory and then restarting:

$ d/rails s

I get the following error:

https://github.com/rails/sprockets (at 3.x@f4d3dae) is not yet checked out. Run `bundle install` first

“Bundle install” does not resolve the issue. I’ve tried a bunch of things, but nothing seems to resolve this. If I remove the symlink in the plugins directory and restart, everything works fine again. I’ve tried it with different official plugins that I know are working on other discourse installations.

Anyone knows why this happens?

1 Like

Can you try d/bundle install instead?

1 Like

I can run d/bundle install, that works and I can then start everything, but the plugin doesn’t appear installed in discourse.

So I run d/shutdown_dev; d/boot_dev but after that it gives the old error message again https://github.com/rails/sprockets (at 3.x@f4d3dae) is not yet checked out. Run `bundle install` first

vOv

I have improved this in

It is definitely confusing to keep having to run d/bundle install manually each time you boot the dev environment. In the mean time, you will unfortunately have to run d/bundle install each time you run d/boot_dev.

3 Likes

I keep getting this error.

error Could not write file “/src/app/assets/javascripts/discourse/yarn-error.log”: “EACCES: permission denied, open ‘/src/app/assets/javascripts/discourse/yarn-error.log’”

error An unexpected error occurred: “EACCES: permission denied, mkdir ‘/src/app/assets/javascripts/node_modules’”.

hmmm :thinking: I think that is the same one as here - can’t find where it was resolved anywhere tho.

1 Like

Are you running this as a non-root user without sudo?

It was the root user.

I’m trying to install Discourse Development in a WSL Docker - I’ve got as far as the congratulations screen, but without an admin account i’m stuck.

When i try and run d/rails admin:create i get the error stat bin/rails: no such file or directory: unknown

What am i missing?

Thanks