Allow Gitea to run on POSIX shell (not relying on bash) #2312

Closed
opened 2025-11-02 04:32:17 -06:00 by GiteaMirror · 8 comments
Owner

Originally created by @tinxx on GitHub (Sep 9, 2018).

  • Gitea version (or commit ref): 1.5.1
  • Git version: 2.18.0
  • Operating system: Alpine Linux v3.8
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

As I found out during working around issues described in #4894, Gitea relies on bash being present on host system.
I think it should be beneficial to evaluate if it is possible to make Gitea compatible with POSIX compliant shells. This would drop Bash dependency and make Gitea more flexible and portable.

Originally created by @tinxx on GitHub (Sep 9, 2018). <!-- 1. Please speak English, this is the language all of us can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/NsatcWJ) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.5.1 - Git version: 2.18.0 - Operating system: Alpine Linux v3.8 - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: ## Description As I found out during working around issues described in #4894, Gitea relies on `bash` being present on host system. I think it should be beneficial to evaluate if it is possible to make Gitea compatible with POSIX compliant shells. This would drop Bash dependency and make Gitea more flexible and portable.
GiteaMirror added the type/enhancementissue/stale labels 2025-11-02 04:32:17 -06:00
Author
Owner

@SagePtr commented on GitHub (Sep 9, 2018):

Did you try setting SCRIPT_TYPE in gitea configuration?
After doing this, do "Resynchronize pre-receive, update and post-receive hooks of all repositories." in gitea admin panel

@SagePtr commented on GitHub (Sep 9, 2018): Did you try setting ```SCRIPT_TYPE``` in gitea [configuration](https://docs.gitea.io/en-us/config-cheat-sheet/)? After doing this, do "Resynchronize pre-receive, update and post-receive hooks of all repositories." in gitea admin panel
Author
Owner

@tinxx commented on GitHub (Sep 9, 2018):

I tried it with this in my app.ini:

[repository]
SCRIPT_TYPE = sh

Still, with busybox sh as user's login shell, I get this when pushing to repo:

halt: unrecognized option: c
BusyBox v1.28.4 (2018-07-17 15:21:40 UTC) multi-call binary.

Usage: halt [-d DELAY] [-n] [-f]

Halt the system

	-d SEC	Delay interval
	-n	Do not sync
	-f	Force (don't go through init)
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

And with dash I get this:

Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 530 bytes | 530.00 KiB/s, done.
Total 5 (delta 3), reused 0 (delta 0)
remote: env: can't execute 'bash': No such file or directory
To ssh://domain.tld/user/repo.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'ssh://domain.tld/user/repo.git
@tinxx commented on GitHub (Sep 9, 2018): I tried it with this in my `app.ini`: ``` [repository] SCRIPT_TYPE = sh ``` Still, with busybox `sh` as user's login shell, I get this when pushing to repo: ``` halt: unrecognized option: c BusyBox v1.28.4 (2018-07-17 15:21:40 UTC) multi-call binary. Usage: halt [-d DELAY] [-n] [-f] Halt the system -d SEC Delay interval -n Do not sync -f Force (don't go through init) fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. ``` And with `dash` I get this: ``` Enumerating objects: 9, done. Counting objects: 100% (9/9), done. Delta compression using up to 8 threads. Compressing objects: 100% (5/5), done. Writing objects: 100% (5/5), 530 bytes | 530.00 KiB/s, done. Total 5 (delta 3), reused 0 (delta 0) remote: env: can't execute 'bash': No such file or directory To ssh://domain.tld/user/repo.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'ssh://domain.tld/user/repo.git ```
Author
Owner

@SagePtr commented on GitHub (Sep 9, 2018):

Resynchronize hooks (after setting dash to SCRIPT_TYPE) and try with dash again. If same problem occurs - check if hooks really have dash in their first line, if not - this seems to be hook resynchronization problem.

@SagePtr commented on GitHub (Sep 9, 2018): Resynchronize hooks (after setting dash to SCRIPT_TYPE) and try with dash again. If same problem occurs - check if hooks really have dash in their first line, if not - this seems to be hook resynchronization problem.
Author
Owner

@tinxx commented on GitHub (Sep 9, 2018):

Oh, I missed that for dash. It does run on dash now, but still no luck on busybox.
Thanks for the assistance!

EDIT:
I still would suggest to look into supporting busybox' sh.

What is the benefit in relying on bash by default if Gitea is able to use sh instead? Why not use sh as a default?

@tinxx commented on GitHub (Sep 9, 2018): Oh, I missed that for `dash`. It does run on `dash` now, but still no luck on busybox. Thanks for the assistance! **EDIT:** I still would suggest to look into supporting busybox' `sh`. What is the benefit in relying on `bash` by default if Gitea is able to use `sh` instead? Why not use `sh` as a default?
Author
Owner

@SagePtr commented on GitHub (Sep 9, 2018):

Tested for both docker alpine:3.8 (under Ubuntu 18) and alpine-virt-3.8.0-x86_64.iso (under Virtualbox) - for both of them gitea 1.5.1 worked without problems under busybox sh (in both cases I used SCRIPT_TYPE = sh to make sh used in hooks). Checked with both openssh and internal gitea ssh server, had no problem with git push at all. Even tried auto-rejecting hook - and it printed message well.
Could not reproduce your "halt: unrecognized option: c" result.

@SagePtr commented on GitHub (Sep 9, 2018): Tested for both docker alpine:3.8 (under Ubuntu 18) and alpine-virt-3.8.0-x86_64.iso (under Virtualbox) - for both of them gitea 1.5.1 worked without problems under busybox sh (in both cases I used SCRIPT_TYPE = sh to make sh used in hooks). Checked with both openssh and internal gitea ssh server, had no problem with git push at all. Even tried auto-rejecting hook - and it printed message well. Could not reproduce your "halt: unrecognized option: c" result.
Author
Owner

@SagePtr commented on GitHub (Sep 9, 2018):

Still I think gitea install script should check whenever bash is available and default to sh if not, or simply add script interpreter field to installation form.

@SagePtr commented on GitHub (Sep 9, 2018): Still I think gitea install script should check whenever bash is available and default to sh if not, or simply add script interpreter field to installation form.
Author
Owner

@stale[bot] commented on GitHub (Jan 11, 2019):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale[bot] commented on GitHub (Jan 11, 2019): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.
Author
Owner

@stale[bot] commented on GitHub (Feb 21, 2019):

This issue has been automatically closed because of inactivity. You can re-open it if needed.

@stale[bot] commented on GitHub (Feb 21, 2019): This issue has been automatically closed because of inactivity. You can re-open it if needed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#2312