[Gitea 1.16.0] Unable to find configuration file #287

Closed
opened 2022-02-01 09:05:39 +00:00 by viceice · 21 comments
Contributor

Can't currently upgrade to gitea v1.16. Getting the following errors on configure-gitea container:

==== BEGIN GITEA CONFIGURATION ====
2022/02/01 09:02:51 ...s/setting/setting.go:543:SetCustomPathAndConf() [W] Using 'custom' directory as relative origin for configuration file: '/data/gitea/"/etc/gitea/app.ini"'
2022/02/01 09:02:51 ...s/setting/setting.go:543:SetCustomPathAndConf() [W] Using 'custom' directory as relative origin for configuration file: '/data/gitea/"/etc/gitea/app.ini"'
2022/02/01 09:02:51 ...s/setting/setting.go:583:loadFromConf() [F] Unable to find configuration file: "/data/gitea/\"/etc/gitea/app.ini\"".
	Ensure you are running in the correct environment or set the correct configuration file with -c.
Can't currently upgrade to gitea v1.16. Getting the following errors on `configure-gitea` container: ``` ==== BEGIN GITEA CONFIGURATION ==== 2022/02/01 09:02:51 ...s/setting/setting.go:543:SetCustomPathAndConf() [W] Using 'custom' directory as relative origin for configuration file: '/data/gitea/"/etc/gitea/app.ini"' 2022/02/01 09:02:51 ...s/setting/setting.go:543:SetCustomPathAndConf() [W] Using 'custom' directory as relative origin for configuration file: '/data/gitea/"/etc/gitea/app.ini"' 2022/02/01 09:02:51 ...s/setting/setting.go:583:loadFromConf() [F] Unable to find configuration file: "/data/gitea/\"/etc/gitea/app.ini\"". Ensure you are running in the correct environment or set the correct configuration file with -c. ```
Author
Contributor

Looks like GITEA_APP_INI is no longer used and we need to explicit pass it to the cli via -c ${GITEA_APP_INI} ?

Looks like `GITEA_APP_INI` is no longer used and we need to explicit pass it to the cli via `-c ${GITEA_APP_INI}` ?
Author
Contributor

OK, looks like i need to first update to chart version v5, currently using latest v4

OK, looks like i need to first update to chart version v5, currently using latest v4
Author
Contributor

Nope, same issue with chart v5.0.1

Nope, same issue with chart v5.0.1
viceice changed title from [1.16.0] Unable to find configuration file to [Gitea 1.16.0] Unable to find configuration file 2022-02-01 11:04:54 +00:00
Author
Contributor
maybe also fixes this https://github.com/go-gitea/gitea/pull/18524
Owner

You can try 1.16.1 now.

You can try 1.16.1 now.

With 1.16.1, the env var is used, but the configure-gitea container can't find the app.ini file while in 1.15.10 it would find it.

Unable to find configuration file: "/data/gitea/\"/data/gitea/conf/app.ini\"". │
│ Ensure you are running in the correct environment or set the correct configuration file with -c
With 1.16.1, the env var is used, but the configure-gitea container can't find the app.ini file while in 1.15.10 it would find it. ``` Unable to find configuration file: "/data/gitea/\"/data/gitea/conf/app.ini\"". │ │ Ensure you are running in the correct environment or set the correct configuration file with -c ```
Member

Will have a look at this today.

Will have a look at this today.
Member

Need more time to investigate this. I wasn't even able to run a simple "gitea serv" inside the containers (rootful/rootless) when not using the entrypoint of the container.

Need more time to investigate this. I wasn't even able to run a simple "gitea serv" inside the containers (rootful/rootless) when not using the entrypoint of the container.
Contributor

The problem is related to the code below in /usr/local/bin/gitea:
https://github.com/go-gitea/gitea/blob/main/docker/rootless/usr/local/bin/gitea#L35

....
....
if [ -z "$APP_INI_SET" ]; then
        CONF_ARG="-c \"${GITEA_APP_INI:-$APP_INI}\""
fi


# Provide docker defaults
GITEA_WORK_DIR="${GITEA_WORK_DIR:-$WORK_DIR}" exec -a "$0" "$GITEA" $CONF_ARG "$@"

The thing is that $CONF_ARG in the bottom line is expanded into -c '"/data/gitea/conf/app.ini"' (extra single quotes). Not sure why bash is doing this.

As a workaround I added export PATH=/app/gitea/:$PATH to the top of configure_gitea.sh file. This way gitea there will run /app/gitea/gitea instead of /usr/local/bin/gitea.

The problem is related to the code below in `/usr/local/bin/gitea`: https://github.com/go-gitea/gitea/blob/main/docker/rootless/usr/local/bin/gitea#L35 ``` .... .... if [ -z "$APP_INI_SET" ]; then CONF_ARG="-c \"${GITEA_APP_INI:-$APP_INI}\"" fi # Provide docker defaults GITEA_WORK_DIR="${GITEA_WORK_DIR:-$WORK_DIR}" exec -a "$0" "$GITEA" $CONF_ARG "$@" ``` The thing is that $CONF_ARG in the bottom line is expanded into `-c '"/data/gitea/conf/app.ini"'` (extra single quotes). Not sure why `bash` is doing this. As a workaround I added `export PATH=/app/gitea/:$PATH` to the top of `configure_gitea.sh` file. This way `gitea` there will run `/app/gitea/gitea` instead of `/usr/local/bin/gitea`.
Owner
It's related with https://github.com/go-gitea/gitea/pull/17846 . @zeripath
Owner

Well it's more related to https://github.com/go-gitea/gitea/pull/18524 and related to the way the helm chart is passing in the variable.

(In some ways I'm slightly confused as to why that was needed in the first place because the docker-entrypoint.sh actually sets the -c ${GITEA_APP_INI} correctly so it should not have been needed if people were going through the docker-entrypoint.sh)

Not running the helm chart myself - I cannot begin to understand how or why the variable is ending up being double escaped. Nor can I test or change the script to make it work or print out what variable it is being sent. I am almost convinced that the problem has to be that helm chart is pre-quoting the environment variable - but I don't know enough to say that that is the case.

My suspicion comes from docker run -e GITEA_APP_INI="/etc/gitea/app-special.ini" gitea/gitea:1.16-dev-rootless does exactly the right thing.

Whereas, docker run -e GITEA_APP_INI="\"/etc/gitea/app-special.ini\"" gitea/gitea:1.16-dev-rootless replicates the problem.

The only thing I can think is that the helm chart is deliberately putting these quotes in and passing them to bash.

One option is to remove the \" from the shim?

But tbh docker-entrypoint.sh and docker-setup.sh should be changed to be quoting their use of ${GITEA_APP_INI} too.

Well it's more related to https://github.com/go-gitea/gitea/pull/18524 and related to the way the helm chart is passing in the variable. (In some ways I'm slightly confused as to why that was needed in the first place because the `docker-entrypoint.sh` actually sets the `-c ${GITEA_APP_INI}` correctly so it should not have been needed if people were going through the `docker-entrypoint.sh`) Not running the helm chart myself - I cannot begin to understand how or why the variable is ending up being double escaped. Nor can I test or change the script to make it work or print out what variable it is being sent. I am almost convinced that the problem has to be that helm chart is pre-quoting the environment variable - but I don't know enough to say that that is the case. My suspicion comes from `docker run -e GITEA_APP_INI="/etc/gitea/app-special.ini" gitea/gitea:1.16-dev-rootless` does exactly the right thing. Whereas, `docker run -e GITEA_APP_INI="\"/etc/gitea/app-special.ini\"" gitea/gitea:1.16-dev-rootless` replicates the problem. The only thing I can think is that the helm chart is deliberately putting these quotes in and passing them to bash. One option is to remove the `\"` from the shim? But tbh `docker-entrypoint.sh` and `docker-setup.sh` should be changed to be quoting their use of `${GITEA_APP_INI}` too.
Contributor

From what I've seen, there's no problem with helm chart setting the GITEA_APP_INI env var.

here's the minimal sample to demonstrate the extra single quotes added by bash:

#!/usr/bin/env bash

set -x

GITEA_APP_INI=/data/gitea/conf/app.ini
CONF_ARG="-c \"${GITEA_APP_INI}\""

echo $CONF_ARG

results into:

+ GITEA_APP_INI=/data/gitea/conf/app.ini
+ CONF_ARG='-c "/data/gitea/conf/app.ini"'
+ echo -c '"/data/gitea/conf/app.ini"'
-c "/data/gitea/conf/app.ini"
From what I've seen, there's no problem with helm chart setting the GITEA_APP_INI env var. here's the minimal sample to demonstrate the extra single quotes added by bash: ```bash #!/usr/bin/env bash set -x GITEA_APP_INI=/data/gitea/conf/app.ini CONF_ARG="-c \"${GITEA_APP_INI}\"" echo $CONF_ARG ``` results into: ```text + GITEA_APP_INI=/data/gitea/conf/app.ini + CONF_ARG='-c "/data/gitea/conf/app.ini"' + echo -c '"/data/gitea/conf/app.ini"' -c "/data/gitea/conf/app.ini" ```
Contributor

My suspicion comes from docker run -e GITEA_APP_INI="/etc/gitea/app-special.ini" gitea/gitea:1.16-dev-rootless does exactly the right thing.

It works because docker-entrypoint.sh passes the -c <ini_path> into /usr/local/bin/gitea and the latter doesn't hit the faulty branch.
The thing is that init containers in helm chart override the entrypoint from Dockerfile (docker-entrypoint.sh) with init/config scripts and /usr/local/bin/gitea has to deduce the config filepath on it's own (from GITEA_APP_INI env var).

> My suspicion comes from docker run -e GITEA_APP_INI="/etc/gitea/app-special.ini" gitea/gitea:1.16-dev-rootless does exactly the right thing. It works because `docker-entrypoint.sh` passes the `-c <ini_path>` into `/usr/local/bin/gitea` and the latter doesn't hit the faulty branch. The thing is that `init` containers in helm chart **override** the entrypoint from Dockerfile (`docker-entrypoint.sh`) with init/config scripts and `/usr/local/bin/gitea` has to deduce the config filepath on it's own (from GITEA_APP_INI env var).
Contributor

shellcheck reports an error for line 35 in /usr/local/bin/gitea
I think it might be related to the problem.
https://github.com/go-gitea/gitea/blob/main/docker/rootless/usr/local/bin/gitea#L35

Quotes/backslashes will be treated literally. Use an array.shellcheck(SC2089)
https://github-wiki-see.page/m/koalaman/shellcheck/wiki/SC2089

`shellcheck` reports an error for line 35 in `/usr/local/bin/gitea` I think it might be related to the problem. https://github.com/go-gitea/gitea/blob/main/docker/rootless/usr/local/bin/gitea#L35 > Quotes/backslashes will be treated literally. Use an array.shellcheck(SC2089) https://github-wiki-see.page/m/koalaman/shellcheck/wiki/SC2089
Owner

My suspicion comes from docker run -e GITEA_APP_INI="/etc/gitea/app-special.ini" gitea/gitea:1.16-dev-rootless does exactly the right thing.

It works because docker-entrypoint.sh passes the -c <ini_path> into /usr/local/bin/gitea and the latter doesn't hit the faulty branch.

aha...

I've replicated it by just using the command line.

docker exec -it musing_brahmagupta bash 

OK that at least means I can fix the damned problem.

> > My suspicion comes from docker run -e GITEA_APP_INI="/etc/gitea/app-special.ini" gitea/gitea:1.16-dev-rootless does exactly the right thing. > It works because docker-entrypoint.sh passes the -c <ini_path> into /usr/local/bin/gitea and the latter doesn't hit the faulty branch. aha... I've replicated it by just using the command line. ```bash docker exec -it musing_brahmagupta bash ``` OK that at least means I can fix the damned problem.
Owner
#!/bin/bash

###############################################################
# This script sets defaults for gitea to run in the container #
###############################################################

# It assumes that you place this script as gitea in /usr/local/bin
#
# And place the original in /usr/lib/gitea with working files in /data/gitea
GITEA="/app/gitea/gitea"
WORK_DIR="/var/lib/gitea"
APP_INI="/etc/gitea/app.ini"

APP_INI_SET=""
for i in "$@"; do
	case "$i" in
	"-c")
		APP_INI_SET=1
		;;
	"-c="*)
		APP_INI_SET=1
		;;
	"--config")
		APP_INI_SET=1
		;;
	"--config="*)
		APP_INI_SET=1
		;;
	*)
	;;
	esac
done

if [ -z "$APP_INI_SET" ]; then
	CONF_ARG=("-c" "${GITEA_APP_INI:-$APP_INI}")
fi


# Provide docker defaults
GITEA_WORK_DIR="${GITEA_WORK_DIR:-$WORK_DIR}" exec -a "$0" "$GITEA" "${CONF_ARG[@]}" "$@"

fixes the problem

```bash #!/bin/bash ############################################################### # This script sets defaults for gitea to run in the container # ############################################################### # It assumes that you place this script as gitea in /usr/local/bin # # And place the original in /usr/lib/gitea with working files in /data/gitea GITEA="/app/gitea/gitea" WORK_DIR="/var/lib/gitea" APP_INI="/etc/gitea/app.ini" APP_INI_SET="" for i in "$@"; do case "$i" in "-c") APP_INI_SET=1 ;; "-c="*) APP_INI_SET=1 ;; "--config") APP_INI_SET=1 ;; "--config="*) APP_INI_SET=1 ;; *) ;; esac done if [ -z "$APP_INI_SET" ]; then CONF_ARG=("-c" "${GITEA_APP_INI:-$APP_INI}") fi # Provide docker defaults GITEA_WORK_DIR="${GITEA_WORK_DIR:-$WORK_DIR}" exec -a "$0" "$GITEA" "${CONF_ARG[@]}" "$@" ``` fixes the problem
Owner
https://github.com/go-gitea/gitea/pull/18690
Member

Can confirm that the current 1.16-dev(-rootless) image works again.

Can confirm that the current 1.16-dev(-rootless) image works again.
Member

FWIW I also face troubles on a fresh install using chart v5.0.0 and

  • Gitea 1.15.10
  • Gitea 1.16.1
  • Gitea 1.16-dev
Processing additionals...
find: /env-to-ini-mounts/additionals/: No such file or directory

=== All configuration sources loaded ===

2022/02/12 16:39:29 ...nvironment-to-ini.go:109:runEnvironmentToIni() [W] Custom config '/data/gitea/conf/app.ini' not found, ignore this if you're running first time
2022/02/12 16:39:29 ...nvironment-to-ini.go:89:main() [F] Failed to run app with [environment-to-ini -o /data/gitea/conf/app.ini -p ENV_TO_INI]: open /data/gitea/conf/app.ini: no such file or directory

but I am not sure, it might be a different error.

I am almost running the vanilla chart, with only changes to ingress and config.database which should not have an effect on the app.ini location.

EDIT: Probably related to a different issue, see #296.

FWIW I also face troubles on a **fresh** install using chart v5.0.0 and - Gitea 1.15.10 - Gitea 1.16.1 - Gitea 1.16-dev ``` Processing additionals... find: /env-to-ini-mounts/additionals/: No such file or directory === All configuration sources loaded === 2022/02/12 16:39:29 ...nvironment-to-ini.go:109:runEnvironmentToIni() [W] Custom config '/data/gitea/conf/app.ini' not found, ignore this if you're running first time 2022/02/12 16:39:29 ...nvironment-to-ini.go:89:main() [F] Failed to run app with [environment-to-ini -o /data/gitea/conf/app.ini -p ENV_TO_INI]: open /data/gitea/conf/app.ini: no such file or directory ``` but I am not sure, it might be a different error. I am almost running the vanilla chart, with only changes to `ingress` and `config.database` which should not have an effect on the `app.ini` location. EDIT: Probably related to a different issue, see https://gitea.com/gitea/helm-chart/issues/296.
Contributor

Can confirm that the current 1.16-dev(-rootless) image works again.

Yes, it works with 1.16-dev ?

> Can confirm that the current 1.16-dev(-rootless) image works again. Yes, it works with `1.16-dev` ?
justusbunsi added the
kind
bug
upstream
gitea
labels 2022-02-25 08:40:08 +00:00
Contributor

Just to add it works but it fails SSH authentication via public key even when SSH key is Verified in gitea. Not sure if this is related to this bug. No issue when root-mode is used.

Just to add it works but it fails SSH authentication via public key even when SSH key is `Verified` in gitea. Not sure if this is related to this bug. No issue when root-mode is used.
Sign in to join this conversation.
No Milestone
No Assignees
8 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: gitea/helm-chart#287
No description provided.