WSL安装Discourse的问题

你好!我正在尝试在我的 Windows 11 机器上设置一个本地的 Discourse 实例,以便在 WSL 中进行开发。

首先,我想说我同时也是 Discourse、Ubuntu 和 WSL 的新手。所以这些错误显然是我的问题。请帮帮我!:frowning_with_open_mouth:

在 Windows 10 上安装 Discourse

上面是我遵循的指南。

我已经尝试了第四次,但仍然遇到相同的错误。我将详细介绍安装过程。

首先,我确保安装了 Windows Subsystem for Linux 2。该指南建议使用 Ubuntu 18.04,所以我尝试了它。在那之后没有成功,我又尝试了 22.04,但仍然没有结果。在本指南中,我将使用 18.04 来展示错误。

第一步是使用以下命令安装软件包:

<(wget -qO- https://raw.githubusercontent.com/discourse/install-rails/master/linux)

这工作正常。唯一看起来有点奇怪的是这个:

createuser: could not connect to database template1: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
failed

在设置数据库之前,您必须使用以下命令手动启动 PostgreSQL 服务和 Redis 服务器

sudo service postgresql start
redis-server --daemonize yes

第一个命令运行得非常好,第二个命令已经出现问题:

redis-server --daemonize yes

Command ‘redis-server’ not found, but can be installed with:

sudo apt install redis-server

没关系。我运行

sudo apt install redis-server

然后再次尝试。
这次,它运行得很棒!

  1. 克隆 Discourse 仓库
git clone https://github.com/discourse/discourse.git ~/discourse

这里没有问题。
使用以下命令设置数据库:

sudo -u postgres createuser -s "$USER"

4. 这是关键部分

cd ~/discourse
source ~/.bashrc
bundle install

错误:

Command ‘bundle’ not found, but can be installed with:

sudo apt install ruby-bundler

让我们运行它。安装完成后,再次运行

bundle install

在 Discourse 目录中。

Error: You must use Bundler 2 or greater with this lockfile.

之后,在尝试安装 Bundler 时:

ERROR: Error installing bundler: There are no versions of bundler (= 2.4.17) compatible with your Ruby & RubyGems bundler requires Ruby version >= 2.6.0. The current ruby version is 2.5.0.

好的,也许我需要使用 rbenv 更新我的 Ruby:

rbenv install 2.6.0
ruby-build: definition not found: 2.6.0

See all available versions with `rbenv install --list’.

If the version you need is missing, try upgrading ruby-build.

当检查 rbenv install --list 时,它在 2.5.0 处停止,我似乎无法更新 rbenv。

有人能给我一些关于我可能做错了什么的提示吗?我似乎无法在第 4 步之后继续前进。

非常感谢!

1 个赞

我遇到了同样的问题。这是我所做的(可能有点过了,但我不是专家 ^^)

  1. 安装 rbenvruby-build
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
  1. 安装新版本的 ruby:
rbenv install 3.2.2
rbenv global 3.2.2
  1. 安装正确的 bundler 版本
    gem install bundler:2.4.13

  2. 由于在使用“bundle install”时遇到了一些权限问题,我需要暂时用以下命令修复:
    sudo chmod -R 777 /home/boris/.bundle

  3. bundle install

希望这有帮助

2 个赞

谢谢!这很有帮助。

现在,我在运行以下命令时遇到了另一个错误:

bundle exec rake db:create

Discourse 需要 Redis 6.2.0 或更高版本

嗯,让我们用以下命令检查一下:

redis-server -v

Redis server v=7.0.12 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=b56540d7933227fd

它应该可以工作,对吧?抱歉带来不便。

哈哈,看来我们遇到了同样的问题。

  1. 添加包含最新版本的存储库
sudo add-apt-repository ppa:redislabs/redis
sudo apt-get update
  1. 安装新的 Redis 版本
sudo apt-get install redis
  1. 重启 redis
    sudo service redis-server restart
3 个赞