smartcontractkit / smartcontractkit/chainlink

[DEVEL] setup-testdb invalid function syntax, mktemp: too few X's in template

Open
#16,179 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
8.2k
Forks
2k
Avg merge
1d 23h
Merged PRs (30d)
202

Description

Description

The make setup-testdb script is broken on Linux. It fails with the error pasted below when I try to run it:

$ make setup-testdb
./core/scripts/setup_testdb.sh
./core/scripts/setup_testdb.sh: 3: function: not found
Error: 
make: *** [GNUmakefile:137: setup-testdb] Error 1

Your Environment

$ bash --version
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ mktemp --version
mktemp (GNU coreutils) 8.32
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Jim Meyering and Eric Blake.
$ go version
go version go1.23.4 linux/amd64
$ docker info
Client: Docker Engine - Community
 Version:    27.5.0
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.19.3
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v2.32.4
    Path:     /usr/libexec/docker/cli-plugins/docker-compose

Server:
 Containers: 17
  Running: 1
  Paused: 0
  Stopped: 16
 Images: 52
 Server Version: 27.5.0
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Using metacopy: false
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 nvidia runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: bcc810d6b9066471b0b6fa75f557a15a1cbf31bb
 runc version: v1.2.4-0-g6c52b3f
 init version: de40ad0
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.9.3-76060903-generic
 Operating System: Pop!_OS 22.04 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 16
 Total Memory: 46.37GiB
 Name: zend
 ID: 8293dc4a-8497-4fd7-9ecd-0d5907cb2af3
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: peter.metz@unarin.com
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
$ cat /etc/os-release
NAME="Pop!_OS"
VERSION="22.04 LTS"
ID=pop
ID_LIKE="ubuntu debian"
PRETTY_NAME="Pop!_OS 22.04 LTS"
VERSION_ID="22.04"
HOME_URL="https://pop.system76.com"
SUPPORT_URL="https://support.system76.com"
BUG_REPORT_URL="https://github.com/pop-os/pop/issues"
PRIVACY_POLICY_URL="https://system76.com/privacy"
VERSION_CODENAME=jammy
UBUNTU_CODENAME=jammy
LOGO=distributor-logo-pop-os
$ uname -a
Linux myhostname 6.9.3-76060903-generic #202405300957~1736980680~22.04~44ea8a9 SMP PREEMPT_DYNAMIC Thu J x86_64 x86_64 x86_64 GNU/Linux
$ npx systeminformation info
Need to install the following packages:
systeminformation@5.25.11
Ok to proceed? (y) y
┌─────────────────────────────────────────────────────────────────────────────────────────┐
│  SYSTEMINFORMATION                                                     Version: 5.25.11 │
└─────────────────────────────────────────────────────────────────────────────────────────┘

Operating System:
──────────────────────────────────────────────────────────────────────────────────────────
Platform         : linux
Distro           : Pop
Release          : 22.04 LTS
Codename         : jammy
Kernel           : 6.9.3-76060903-generic
Arch             : x64
Hostname         : zend
Codepage         : UTF-8
Build            : 

System:
──────────────────────────────────────────────────────────────────────────────────────────
Manufacturer     : ASUSTeK COMPUTER INC.
Model            : ROG Zephyrus G14 GA402XV_GA402XV
Version          : 1.0
Virtual          : 

CPU:
──────────────────────────────────────────────────────────────────────────────────────────
Manufacturer     : AMD
Brand            : Ryzen 9 7940HS w/ Radeon 780M Graphics
Family           : 25
Model            : 116
Stepping         : 1
Speed            : 3.3
Cores            : 16
PhysicalCores    : 8
PerformanceCores : 8
EfficiencyCores  : 
Processors       : 1
Socket           : 

Basic Information

There are two issues with the script in my environment at present:

  1. The function declaration is not valid syntax for sh (which is explicitly specified to be the shell for the script on the first line)
  2. Once the function declaration syntax is fixed, then the mktemp call crashes because of invalid parameters (assuming the version of it on Mac is having a looser validation and that's why this has gone unnoticed)
  3. After fixing the mktemp template by adding some X characters to it, it than crashes with ./core/scripts/setup_testdb.sh: 58: pushd: not found which is allegedly happening because the script declares that it wants to run in sh instead of bash. So finally, updating the hashbang to use bash solves all the issues. Happy days!

Sources:

Steps to Reproduce

Execute the steps exactly as specified in the README's ## Development --> ### Running tests section

Additional Information

The fixes to all three issues are relatively easy, here's the diff that I needed to make it work on my machine:

Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with core/scripts/setup_testdb.sh and the setup-testdb target in GNUmakefile, then follow the README's Development > Running tests instructions on Linux. Check the shell declaration, function syntax, mktemp template, and pushd usage; done means make setup-testdb completes successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, shell
Domain
build-system, testing-qa
Issue type
Bug
Difficulty
2/5
Estimated time
Half a day
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.