開発のためにWindowsにDiscourseをインストールする

:information_source: This tutorial has been tested on Windows 10 and 11.

To set up a development environment for Discourse on Windows, you can do it using Windows Subsystem for Linux feature.

This setup requires the WSL 2 installation. It is only available in Windows 10 builds 18917 or higher. We’ll assume that you already installed Windows Subsystem for Linux 2 (Ubuntu) on your Windows 10 system. WARNING: Install Ubuntu 18.04, and not 20.04 since some installations will fail on 20.04. For more information see June 30th, 2020 notes at the bottom of this post.

Let’s begin!

Installing Discourse

  1. Initially follow the steps from the topic Beginners Guide to Install Discourse on Ubuntu for Development until the step Clone Discourse.
  1. Before setting up the database you have to start PostgreSQL service & Redis server manually using following commands

    sudo service postgresql start
    redis-server --daemonize yes
    
  2. Then go through all the remaining steps of the Ubuntu guide.

Creating a Command to Start Discourse

Now your development environment is almost ready. The only problem is every time when you open Ubuntu on Windows you have to start the PostgreSQL service & Redis server manually. Don’t worry we can have a workaround for this by creating a custom command :wink:

cd ~

Create a new file using the command nano start-discourse and paste the content below then save and exit.

#!/bin/bash

# to start PostgreSQL
sudo service postgresql start

# to start Redis server
redis-server --daemonize yes

Now modify the CHMOD using below command

chmod +x start-discourse

And copy the file to your bin folder

sudo cp start-discourse /usr/bin/

It’s done. Now, whenever you open the Ubuntu bash just run the command below and start developing :+1:

start-discourse

Alternatively, if you are using Windows 10 enterprise, pro, or education edition then you can create a Linux virtual machine in hyper-v to set up the Discourse dev environment.

Notes About Windows Environment

As of June 30, 2020:
As of July 1, 2020

Last Reviewed by @SaraDev on 2022-06-16T02:00:00Z


This document is version controlled - suggest changes on github.

「いいね!」 52

解決策が見つかりました。

127.0.0.1localhost に置き換えると、画像の問題が解決することに気づきました。

少し調べたところ、Discourseを起動するには次のコマンドを使用できます。

DISCOURSE_HOSTNAME=localhost UNICORN_LISTENER=localhost:3000 bin/ember-cli -u


後でガイドを更新します。

「いいね!」 4

このPRを確認していただけますか?

これにより、このガイドがもう少し使いやすくなります。

「いいね!」 3

「残念ながら、予期せぬエラーが発生し、Bundler を続行できません。」というエラーが発生する原因について、何かご存知ですか? bundle install の後です。

「いいね!」 1

同じ問題

エラーのスクリーンショットを提供していただけますか?お使いのRubyのバージョンは何ですか?

依存関係で問題が発生しています。

ux430uq@Asus-UX430UQ:~/discourse$ bundle install
You must use Bundler 2 or greater with this lockfile.
ux430uq@Asus-UX430UQ:~/discourse$ bundler -v
Bundler version 1.16.1

ux430uq@Asus-UX430UQ:~/discourse$ gem install bundler

Fetching: bundler-2.4.20.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /var/lib/gems/2.5.0 directory.
ux430uq@Asus-UX430UQ:~/discourse$
ux430uq@Asus-UX430UQ:~/discourse$ sudo gem install bundler
[sudo] password for ux430uq:
Fetching: bundler-2.4.20.gem (100%)
ERROR:  Error installing bundler:
        The last version of bundler (>= 0) to support your Ruby & RubyGems was 2.3.26. Try installing it with `gem install bundler -v 2.3.26`
        bundler requires Ruby version >= 2.6.0. The current ruby version is 2.5.0.
ux430uq@Asus-UX430UQ:~/discourse$ bundler -v
Bundler version 1.16.1
ux430uq@Asus-UX430UQ:~/discourse$

簡単に修正するにはどうすればよいですか? 2.6.0、次に2.7.0をインストールしようとしましたが、常に他の問題が発生していました。

以前のコメントにもありましたが、私もこのガイドに従おうとした際にいくつかの困難やエラーに遭遇しました。Windows 10とWindows 11の両方のデスクトップで試しました。

試行錯誤の結果、Windows 11で完全に動作する開発環境を構築するための手順がわかりました。これは最新の22H2ビルドと、今後の23H2リリースプレビューでテスト済みです(Windows 10の最新ビルドでも機能するはずです)。

もしどなたかの役に立つようでしたら、ガイドをここに投稿しました:-

WindowsでDiscourseを実行しようとしている私のような人々を助けることができれば幸いです :smiley:

「いいね!」 2

再度、公式ガイド全体を確認し、前回試行したときから何も問題が発生していないことを確認しました。
Windows 11 の WSL で Ubuntu (バージョン指定なし) をインストールしました。この場合、最新の LTS バージョンである 22.04 がインストールされました。

問題は発生しませんでした。すべて順調で、エラーもなく、開発環境のインストールも完了しました。

将来、公式ガイドを使用して何かをインストールする際に問題が発生した場合は、エラーを書き留めて私たちに報告してください。常に役立ちます :smile:


ただし、2 つの警告があります。

Node.js をインストールするとき:

================================================================================
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
================================================================================

                           SCRIPT DEPRECATION WARNING


  Node.js をインストールするために使用されていた https://deb.nodesource.com/setup_X に
  あるこのスクリプトは現在非推奨であり、最終的には無効になります。

  NodeSource distributions Github にアクセスし、
  移行手順に従ってください。
  https://github.com/nodesource/distributions

  NodeSource Node.js Linux distributions GitHub リポジトリには、
  どのバージョンの Node.js とどの Linux ディストリビューションが
  サポートされているか、およびインストール方法に関する情報が含まれています。
  https://github.com/nodesource/distributions


                          SCRIPT DEPRECATION WARNING

================================================================================
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓
================================================================================

この待機を避けるにはスクリプトを移行してください
60 秒後に続行します (中止するには Ctrl-C を押してください)...

redis-server --daemonize yes を実行するとき:

# WARNING メモリのオーバーコミットを有効にする必要があります!無効にすると、メモリ不足の状態でバックグラウンド保存またはレプリケーションが失敗する可能性があります。無効にすると、メモリ不足の状態でも失敗する可能性があります。詳細については https://github.com/jemalloc/jemalloc/issues/1328 を参照してください。この問題を解決するには、/etc/sysctl.conf に 'vm.overcommit_memory = 1' を追加してから再起動するか、コマンド 'sysctl vm.overcommit_memory=1' を実行して有効にしてください。

なぜそんなに多くの問題があったのか分かりません!トラブルシューティング中に気づかずに修正したWindowsのインストールに何か奇妙なものがあったのかもしれません!:stuck_out_tongue:

それでも、これまでに学んだことに満足しており、フォーラムをDiscourseに移行する作業を続けることを楽しみにしています。

「いいね!」 2

Windowsを再インストールする必要があったので、クリーンなWindows 11をインストールしました。
ガイドに従って、後で報告します!@AliBenBongoさんのガイドも念頭に置きます

「いいね!」 1

フォローアップです。

ガイドは確かに更新が必要ですが、Windows 11 22H2 のクリーンインストールでも問題なく動作します。:+1:

唯一の問題は、ターミナルで wsl コマンドは動作していましたが、WSL 機能がデフォルトで有効になっていなかったことです。

「いいね!」 3

このガイドは古いと思います。Ubuntu/Debianガイドで言及されている手順は、もはや存在しません。

これらの手順をすべて元に戻す方法はありますか。たとえば、パッケージ、gem、およびクローンをアンインストールするスクリプトを実行することはできますか。

18.04 を 20.04 の上にインストールすることは、まだ必要ですか?

nodejs をインストールする際にエラーが発生しています。

# apt install nodejs

パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
いくつかのパッケージはインストールできませんでした。これは、不可能な状況を要求したか、不安定版ディストリビューションを使用している場合に、必要なパッケージがまだ作成されていないか、Incoming から移動されていないことを意味する可能性があります。
以下の情報が状況の解決に役立つかもしれません。

以下のパッケージにはアンメットな依存関係があります:
  nodejs : 依存: libc6 (>= 2.28) ですが、2.27-3ubuntu1.6 がインストールされようとしています
E: 問題を修正できません。保留中の壊れたパッケージがあります。```