# Discourse-setup: 第260行：\*0：语法错误：应为操作数（错误标记为“\*0”）

**URL:** https://meta.discourse.org/t/discourse-setup-line-260-0-syntax-error-operand-expected-error-token-is-0/260991
**Category:** Self-hosting
**Tags:** arm
**Created:** [2023年四月7日 21:55 UTC](https://meta.discourse.org/t/discourse-setup-line-260-0-syntax-error-operand-expected-error-token-is-0/260991 "2023-04-07T21:55:40Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![laplasz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/laplasz/32/221485_2.png) [@laplasz](https://meta.discourse.org/u/laplasz)
#### Post date: [2023年四月7日 21:55 UTC](https://meta.discourse.org/t/discourse-setup-line-260-0-syntax-error-operand-expected-error-token-is-0/260991/1 "2023-04-07T21:55:40Z")

</div>

首次安装时遇到此错误：  
`discourse-setup: line 260: *0: syntax error: operand expected (error token is "*0")`  
`您的 Discourse 的主机名？ [discourse.example.com]:`

有什么建议知道哪里出错了？

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [2023年四月7日 22:50 UTC](https://meta.discourse.org/t/discourse-setup-line-260-0-syntax-error-operand-expected-error-token-is-0/260991/2 "2023-04-07T22:50:05Z")

</div>

您好，欢迎回来！

您能详细说明您尝试安装 Discourse 的操作系统吗？

---

<div class="post-metadata">

### Author: ![laplasz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/laplasz/32/221485_2.png) [@laplasz](https://meta.discourse.org/u/laplasz)
#### Post date: [2023年四月8日 07:46 UTC](https://meta.discourse.org/t/discourse-setup-line-260-0-syntax-error-operand-expected-error-token-is-0/260991/3 "2023-04-08T07:46:21Z")

</div>

您好！这是 Ubuntu 20.04.6 LTS  
Linux ubuntu 5.4.0-1082-raspi aarch64 aarch64 aarch64 GNU/Linux

---

<div class="post-metadata">

### Author: ![Ed\_S](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ed_s/32/134015_2.png) [@Ed\_S](https://meta.discourse.org/u/Ed_S)
#### Post date: [2023年四月8日 08:35 UTC](https://meta.discourse.org/t/discourse-setup-line-260-0-syntax-error-operand-expected-error-token-is-0/260991/4 "2023-04-08T08:35:13Z")

</div>

我建议先执行 `git pull`。然后，如果脚本仍然出现此问题，或许可以尝试运行  
`bash -vx ./discourse-setup`  
这样我们或许能看到发生了什么。（我不知道第 260 行怎么会引起这个问题）

---

<div class="post-metadata">

### Author: ![laplasz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/laplasz/32/221485_2.png) [@laplasz](https://meta.discourse.org/u/laplasz)
#### Post date: [2023年四月8日 08:42 UTC](https://meta.discourse.org/t/discourse-setup-line-260-0-syntax-error-operand-expected-error-token-is-0/260991/5 "2023-04-08T08:42:49Z")

</div>

260行的代码：

```plaintext
avail_cores=$((`awk '/cpu cores/ {print $4;exit}' /proc/cpuinfo`*`sort /proc/cpuinfo | uniq | grep -c \"physical id\"`))

```

bash -x 的输出：

```plaintext
scale_ram_and_cpu
+ scale_ram_and_cpu
+ local changelog=/tmp/changelog.11937
+ avail_gb=0
+ avail_cores=0
++ check_OS
+++ uname -s
++ echo Linux
+ os_type=Linux
+ '[' Linux == Darwin ']'\
++ check_linux_memory
+++ free -m --si
+++ awk ' /Mem:/ {print $2}'
++ mem=3975
++ '[' 3975 -ge 990 -a 3975 -lt 1000 ']'\
+++ free -g --si
+++ awk ' /Mem:/ {print $2} '\
++ echo 3
+ avail_gb=3
++ awk '/cpu cores/ {print $4;exit}' /proc/cpuinfo
++ sort /proc/cpuinfo
++ uniq
++ grep -c 'physical id'
./discourse-setup: line 260: *0: syntax error: operand expected (error token is \"*0\")

```

cat /proc/cpuinfo：

```plaintext
root@ubuntu:/var/discourse# cat /proc/cpuinfo 
processor	: 0
BogoMIPS	: 108.00
Features	: fp asimd evtstrm crc32 cpuid
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x0
CPU part	: 0xd08
CPU revision	: 3

processor	: 1
BogoMIPS	: 108.00
Features	: fp asimd evtstrm crc32 cpuid
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x0
CPU part	: 0xd08
CPU revision	: 3

processor	: 2
BogoMIPS	: 108.00
Features	: fp asimd evtstrm crc32 cpuid
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x0
CPU part	: 0xd08
CPU revision	: 3

processor	: 3
BogoMIPS	: 108.00
Features	: fp asimd evtstrm crc32 cpuid
CPU implementer	: 0x41
CPU architecture: 8
CPU variant	: 0x0
CPU part	: 0xd08
CPU revision	: 3

Hardware	: BCM2835
Revision	: c03112
Serial : 10000000d0894f90
Model : Raspberry Pi 4 Model B Rev 1.2

```

---

<div class="post-metadata">

### Author: ![Ed\_S](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ed_s/32/134015_2.png) [@Ed\_S](https://meta.discourse.org/u/Ed_S)
#### Post date: [2023年四月8日 09:25 UTC](https://meta.discourse.org/t/discourse-setup-line-260-0-syntax-error-operand-expected-error-token-is-0/260991/6 "2023-04-08T09:25:47Z")

</div>

> [@laplasz](#):
>
> ```plaintext
> avail_cores=$((`awk '/cpu cores/ {print $4;exit}' /proc/cpuinfo`*`sort /proc/cpuinfo | uniq | grep -c \"physical id\"`))
> 
> ```

这里有几种方法可以尝试，我想，或许我会选择

```plaintext
avail_cores=$((`lscpu --parse=core | awk 'NF==1' | sort -u | wc -l`))

```

（我们正在尝试计算当前在线的物理核心总数 - 而不是逻辑核心、cpu、插槽或处理器）

这在你的情况下会起作用吗？

---

<div class="post-metadata">

### Author: ![laplasz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/laplasz/32/221485_2.png) [@laplasz](https://meta.discourse.org/u/laplasz)
#### Post date: [2023年四月8日 10:10 UTC](https://meta.discourse.org/t/discourse-setup-line-260-0-syntax-error-operand-expected-error-token-is-0/260991/7 "2023-04-08T10:10:50Z")

</div>

> [@Ed\_S](#):
>
> `avail_cores=$((`lscpu --parse=core | awk ‘NF==1’ | sort -u | wc -l`))`

是的 - 它返回 4  
所以也许最好使用 lscpu 而不是解析 /proc/cpuinfo

---

<div class="post-metadata">

### Author: ![Ed\_S](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ed_s/32/134015_2.png) [@Ed\_S](https://meta.discourse.org/u/Ed_S)
#### Post date: [2023年四月8日 10:32 UTC](https://meta.discourse.org/t/discourse-setup-line-260-0-syntax-error-operand-expected-error-token-is-0/260991/8 "2023-04-08T10:32:26Z")

</div>

好的 - 我已提交一个 PR

> <https://github.com/discourse/discourse_docker/pull/702>
>
> Previously parsing /proc/cpuinfo but that fails on Raspberry Pi and presumably o…ther aarch64 platforms
> https://meta.discourse.org/t/discourse-setup-line-260-0-syntax-error-operand-expected-error-token-is-0/260991

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2023年五月8日 10:32 UTC](https://meta.discourse.org/t/discourse-setup-line-260-0-syntax-error-operand-expected-error-token-is-0/260991/9 "2023-05-08T10:32:53Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
