embedded subcommand not working in Linux
- Gitea version (or commit ref): 1.12.1 (till latest)
Description
The embedded subcommand does not work list or extract any files.
Screenshots
bash-5.0# gitea -v
Gitea version 1.12.1 built with GNU Make 4.2.1, go1.14.4 : bindata, sqlite, sqlite_unlock_notify
bash-5.0# gitea embedded list '**'
bash-5.0#
Reason
Gitea embedded can not run with mismatched Linux user in an installed config, there will be no output at all.
Workaround
Run gitea with the correct Linux user (as in the app.ini), using su or sudo
~In fact the command name is embed not embedded~
Yeah, this is wrong in the help:
bash-5.0# gitea help
NAME:
Gitea - A painless self-hosted Git service
USAGE:
gitea [global options] command [command options] [arguments...]
VERSION:
1.12.1 built with GNU Make 4.2.1, go1.14.4 : bindata, sqlite, sqlite_unlock_notify
DESCRIPTION:
By default, gitea will start serving using the webserver with no
arguments - which can alternatively be run by running the subcommand web.
COMMANDS:
web Start Gitea web server
serv This command should only be called by SSH shell
hook Delegate commands to corresponding Git hooks
dump Dump Gitea files and database
cert Generate self-signed certificate
admin Command line interface to perform common administrative operations
generate Command line interface for running generators
migrate Migrate the database
keys This command queries the Gitea database to get the authorized command for a given ssh key fingerprint
convert Convert the database
doctor Diagnose problems
manager Manage the running gitea process
embedded Extract embedded resources
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--port value, -p value Temporary port number to prevent conflict (default: "3000")
--pid value, -P value Custom pid file path (default: "/var/run/gitea.pid")
--custom-path value, -C value Custom path file path (default: "/data/gitea")
--config value, -c value Custom configuration file path (default: "/data/gitea/conf/app.ini")
--version, -v print the version
--work-path value, -w value Set the gitea working path (default: "/usr/local/bin")
--help, -h show help
GLOBAL OPTIONS:
--port value, -p value Temporary port number to prevent conflict (default: "3000")
--pid value, -P value Custom pid file path (default: "/var/run/gitea.pid")
--custom-path value, -C value Custom path file path (default: "/data/gitea")
--config value, -c value Custom configuration file path (default: "/data/gitea/conf/app.ini")
--version, -v print the version
--work-path value, -w value Set the gitea working path (default: "/usr/local/bin")
--help, -h show help
DEFAULT CONFIGURATION:
CustomPath: /data/gitea (GITEA_CUSTOM)
CustomConf: /data/gitea/conf/app.ini
AppPath: /usr/local/bin/gitea
AppWorkPath: /usr/local/bin
I'm confused by this response. embedded seems to be parsed properly while embed (or any other random string) merely attempts to boot up gitea.
If the command is not understood it should error.
embedded is the correct sub-command name.
The reason strings that aren't valid sub-commands boot up gitea is because of
https://github.com/go-gitea/gitea/blob/838fef2ae84f8752363e8e3e31c252d66a5c6027/main.go#L98-L101
We are setting the default command to be the same we gitea web
As for why the command isn't working for you, you need to specify the config file with the -c flag.
e.g. gitea -c /etc/gitea/app.ini embedded list
I'm getting empty file listings in docker exec, while the paths are being detected without flags:
DEFAULT CONFIGURATION:
CustomPath: /data/gitea (GITEA_CUSTOM)
CustomConf: /data/gitea/conf/app.ini
AppPath: /usr/local/bin/gitea
AppWorkPath: /usr/local/bin
I've however tried adding the flag, and no files were listed still.
/ # gitea -c /data/gitea/conf/app.ini embedded list '**'
/ #
This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.
bump
I can't replicate your problem.
This works on gitea/gitea:latest:
docker pull gitea/gitea:latest
docker run gitea/gitea:latest &
docker exec $(docker ps | grep gitea | cut -f1 -d\ ) gitea embedded list "**"
This works on gitea/gitea:1.12:
docker pull gitea/gitea:1.12
docker run gitea/gitea:1.12 &
docker exec $(docker ps | grep gitea | cut -f1 -d\ ) gitea embedded list "**"
view appears to work
docker exec $(docker ps | grep gitea | cut -f1 -d\ ) gitea embedded view templates/user/settings/keys.tmpl
extract also works.
docker exec $(docker ps | grep gitea | cut -f1 -d\ ) gitea embedded extract templates/user/auth/change_passwd_inner.tmpl
docker exec $(docker ps | grep gitea | cut -f1 -d\ ) cat templates/user/auth/change_passwd_inner.tmpl
This issue still seems to be present. I can get a result from embedded list but only by specifying an invalid config file.
(1) With invalid config file - works
bash-5.1# gitea -c garbage/app.ini embedded list templates/user/settings/keys.tmpl
2021/11/27 13:46:59 ...s/setting/setting.go:547:SetCustomPathAndConf() [W] Using 'custom' directory as relative origin for configuration file: '/data/gitea/garbage/app.ini'
2021/11/27 13:46:59 ...s/setting/setting.go:547:SetCustomPathAndConf() [W] Using 'custom' directory as relative origin for configuration file: '/data/gitea/garbage/app.ini'
2021/11/27 13:46:59 ...s/setting/setting.go:547:SetCustomPathAndConf() [W] Using 'custom' directory as relative origin for configuration file: '/data/gitea/garbage/app.ini'
templates/user/settings/keys.tmpl
(2) With correct path to config file - No Result
bash-5.1# gitea -c conf/app.ini embedded list templates/user/settings/keys.tmpl
2021/11/27 13:47:46 ...s/setting/setting.go:547:SetCustomPathAndConf() [W] Using 'custom' directory as relative origin for configuration file: '/data/gitea/conf/app.ini'
2021/11/27 13:47:46 ...s/setting/setting.go:547:SetCustomPathAndConf() [W] Using 'custom' directory as relative origin for configuration file: '/data/gitea/conf/app.ini'
2021/11/27 13:47:46 ...s/setting/setting.go:547:SetCustomPathAndConf() [W] Using 'custom' directory as relative origin for configuration file: '/data/gitea/conf/app.ini'
bash-5.1#
(3) With no path specified (presumably using /data/gitea/conf/app.ini) - No Result
bash-5.1# gitea embedded list templates/user/settings/keys.tmpl
bash-5.1#
stat showing the config file exists at the location used for (2) (3)
bash-5.1# stat /data/gitea/conf/app.ini
File: /data/gitea/conf/app.ini
Size: 2449 Blocks: 8 IO Block: 4096 regular file
Device: 802h/2050d Inode: 31590370 Links: 1
Access: (0600/-rw-------) Uid: ( 1000/ git) Gid: ( 1000/ git)
Access: 2021-11-27 04:13:00.305459938 +0100
Modify: 2021-11-27 10:49:48.344909082 +0100
Change: 2021-11-27 10:49:48.344909082 +0100
So a workaround seems to be to specify an incorrect config file. I'm using gitea docker 1.15.6
I meet the similar problem on my side: embedded list outputs nothing.
If I do TAGS=bindata make build (1.16) on macOS, then ./gitea embedded list can output the correct list.
But if I do GOOS=... TAGS=bindata make build (1.16) and copy the binary into the Linux docker, ./gitea embedded list outputs nothing. (I know my operation is a little strange, but whatever happens the output should not be empty)
I should note that it seems that when using an 'invalid' app.ini path, the file and path gets created with the content:
[security]
INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6......................VRdGT1imauIcCNegCJi0xjZQyB46FGa7v7qtUF_IAc
I should note that it seems that when using an 'invalid' app.ini path, the file and path gets created with the content:
[security] INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6......................VRdGT1imauIcCNegCJi0xjZQyB46FGa7v7qtUF_IAc
@rmawatson That's a bug, will be fixed in https://github.com/go-gitea/gitea/pull/17779
You can delete these files & directories safely.
Thanks - have deleted.
Unfortunately when #17779 is merged, it will give an error according to the change list
Show errors in CLI code if an incorrect app.ini is used
So the current 'workaround' to specify an invalid app.ini wont work.
Thanks - have deleted.
Unfortunately when #17779 is merged, it will give an error according to the change list
Show errors in CLI code if an incorrect app.ini is used
So the current 'workaround' to specify an invalid app.ini wont work.
Nope, that PR just does correct things, embeded sub-commands don't require an app.ini actually, so you won't see that error message.
And that PR is not related to this bug, I will hide these two comments here.
Some thoughts (maybe conclusions):
- This bug is not Docker-related: I can reproduce it in a real Linux server
- This bug is not config (app.ini) related: The
embeddedsub-commands don't need it - The
embedded listandembedded viewmay output nothing (even with the with non-existing file paths): it's abnormal,embedded viewshould output error messages if the target doesn't exist. - The bug seems related with the console output mechanism (according 3)
ps: I haven't investigated this problem carefully, these information is just FYI, correct me if I was wrong.
@lunny I think this is a bug, not related to docker. See my comments above. So maybe we should keep this open.
I found the root case of this bug.
- There is a check: https://github.com/go-gitea/gitea/blob/72f9050689912f5910a08d593ebe53078fe85aa4/modules/setting/setting.go#L954 . The code is pretty old (as early as 2014)
- The
embeddedcommand removes loggers: https://github.com/go-gitea/gitea/blob/72f9050689912f5910a08d593ebe53078fe85aa4/cmd/embedded.go#L115
Then bad thing happens: Gitea embedded can not run with mismatched Linux user in an installed config, and no error is outputted.
working that way:
# ls -l conf/app.ini
-rw-r--r-- 1 git git 2611 Jan 16 19:09 conf/app.ini
# su git -s /usr/local/bin/gitea embedded list