Use correct path to snap binary #17274
Open
techknowlogick
wants to merge 8 commits from
techknowlogick/snap-fix
into main
pull from: techknowlogick/snap-fix
merge into: lunny:main
lunny:main
lunny:KN4CK3R/fix-17378
lunny:yarg-kane/main
lunny:6543-forks/refactor_teams-to-api-convert
lunny:qwerty287/timeline-api
lunny:99rgosse/migration-history
lunny:qwerty287/wiki-api
lunny:qwerty287/notifications-site
lunny:qwerty287/fork-dialog
lunny:lunny/lunny/api_ui
lunny:wxiaoguang/issue-content-history-fix
lunny:wxiaoguang/frontend-index-init
lunny:release/v1.15
lunny:zeripath/go-json
lunny:andrebruch/feature-add-issue-and-comment-attachments-api
lunny:wxiaoguang/optimize-logger
lunny:SahAssar/patch-1
lunny:delvh/refactor-js
lunny:noerw/fix-17179
lunny:zeripath/request-as-process
lunny:KN4CK3R/feature-migrate-gitbucket
lunny:dpschen/patch-1
lunny:wxiaoguang/enforce-2fa
lunny:raygervais/update/rel-nofollow
lunny:kolaente/feature/auto-merge
lunny:lunny/lunny/user_orgs_pagination
lunny:techknowlogick/user-settings
lunny:lunny/lunny/refactor_issues
lunny:zeripath/oidc-claims
lunny:techknowlogick/milestone-labels
lunny:n194/wiki-footer-sidebar-hints
lunny:KN4CK3R/feature-packages
lunny:zeripath/attempt-to-fix-17138
lunny:anbraten/sort-project-issuses
lunny:a1012112796/double_clicked_button
lunny:netzbegruenung/feature/ldap-group-sync
lunny:zeripath/backport-17154
lunny:OleHusgaard/main
lunny:KN4CK3R/feature-migrate-codebase
lunny:zeripath/page-directory-entries-on-viewcode
lunny:osmosBe/patch-1
lunny:release/v1.14
lunny:silverwind/hashlink
lunny:fuzzing-stuff/add-custom-date-16841
lunny:derekhu/patch-1
lunny:lunny/lunny/rename_modules_pkgs2
lunny:lunny/lunny/refactor_context
lunny:zeripath/pause-queues
lunny:lunny/lunny/http_refactor
lunny:boppy/pwd-update
lunny:zeripath/fix-15178-provide-aliases-for-submodules
lunny:noerw/docs-stl-update-url
lunny:KN4CK3R/refactor-sanitize
lunny:drachenfels-de/main
lunny:sschroe/main
lunny:zeripath/fix-7508-support-proxy-protocol
lunny:lunny/lunny/cache_ledis
lunny:a1012112796/hooks
lunny:ibpl/master-IB#1107572
lunny:KN4CK3R/fix-12331
lunny:dragonflylee/container
lunny:6543-forks/update-vendor-cli
lunny:zeripath/add-max-concurrent-hashes
lunny:a1012112796/migration_trn
lunny:a1012112796/ui_create_repo_bug
lunny:zeripath/speed-up-testpatch
lunny:a1012112796/issue_lable_api
lunny:colorfulwolf/fix-unuse-truncate
lunny:a1012112796/imap
lunny:release/v1.13
lunny:kolaente/feature/pr-prompt
lunny:a1012112796/custom-repo-buttons
lunny:POPSuL/f/save-whitespace-behavior
lunny:a1012112796/docker_support
lunny:lunny/lunny/services
lunny:andrebruch/fix/release_api
lunny:6543-forks/private-issue_3217
lunny:jolheiser/template-branch-prot
lunny:silverwind/textarea
lunny:rogerluo410/dev-project-board
lunny:CL-Jeremy/svg-vertical-alignment
lunny:CL-Jeremy/mobile-repo-rework
lunny:lunny/lunny/user
lunny:silverwind/jsx
lunny:CL-Jeremy/mobile-tabs
lunny:rogerluo410/dev-find-file
lunny:lunny/lunny/inline_comment
lunny:ibpl/master-IB#1105051
lunny:appleboy/patch2
lunny:lunny/lunny/sqlite
lunny:noerw/fix-14942
lunny:lunny/lunny/fix_http_bug
lunny:AllSpiceIO/kd/fix-docker_rootless_docs
lunny:pini-gh/pini
lunny:daniil-pankratov/create-admin-auths-api
lunny:6543-forks/docs_man_config-pages
lunny:openscript/patch-1
lunny:a1012112796/init_graphql
lunny:jolheiser/commit-hide-email
lunny:jamesorlakin/feature/mfaDocumentationPage
lunny:lunny/lunny/system_hook_api
lunny:Rob61/add-support-for-multiple-ldap-server
lunny:lunny/lunny/reaction_col_size
lunny:lafriks-fork/feat/indexer_availability
lunny:lafriks-fork/feat/secrets
lunny:lunny/lunny/new_file_blank_repo
lunny:lunny/lunny/improve_notification
lunny:mrsdizzie/better-diff
lunny:CirnoT/commit-refs
lunny:zeripath/no-go-git-refactor-all-the-git
lunny:6543-forks/issue-page-filter-author
lunny:6543-forks/ui-migration-cancel
lunny:macvag/master
lunny:6543-forks/release-attachments_reject-duplicate-names
lunny:johanvdw/commit_sha
lunny:release/v1.12
lunny:a1012112796/feature/Pinned_repo
lunny:bhalbright/graphql-poc
lunny:sapk-fork/limit-repo-size
lunny:a1012112796/pr_template_enhancement
lunny:0xC4N1/copyable-line-numbers
lunny:M4RKUS-11111/add_steam
lunny:alvardes/revisions
lunny:ibpl/master-IB#1104925
lunny:ibpl/master-IB#1105071
lunny:adelowo/show_commit_diffs_btw_current_branch_and_master
lunny:zeripath/show-storage-configuration-on-admin-configuration-page
lunny:6543-forks/api-add-reaction-summary
lunny:ibpl/master-IB#1105104
lunny:zeripath/fix-916-go-camo-media-proxy
lunny:lunny/lunny/github_projects
lunny:mvdkleijn/limit-private-repos
lunny:a1012112796/table_name_prefix
lunny:foxy82/patch-1
lunny:TheoLassonder/master
lunny:release/v1.11
lunny:silverwind/rmtheme
lunny:techknowlogick/cdb-support
lunny:zeripath/apply-patch
lunny:guillep2k/user-repo-unit
lunny:zeripath/queues-notification
lunny:release/v1.10
lunny:guillep2k/backport-migration
lunny:jolheiser/loading-button
lunny:mqudsi/attachment_allow_prefix
lunny:lafriks-fork/feat/priority
lunny:Cherrg/gitea_md_wiki_auto_toc
lunny:release/v1.9
lunny:strk/local-source-oauth-users
lunny:gary-kim/security/noid/require-login-for-non-existent-repo
lunny:lunny/lunny/support_hsts
lunny:Cherrg/wiki_directories
lunny:Cherrg/gitea_wiki_page_toc
lunny:release/v1.8
lunny:coolaj86/ux-register-is-signin
lunny:AlexanderBeyn/custom-regexp-external-issues
lunny:ollien/pr-branch-links
lunny:Codeberg-org/global-wiki-edit
lunny:lunny/lunny/private_repo_public_units
lunny:beeonthego/beeonthego-jwt-ui
lunny:lunny/lunny/dump_restore
No reviewers
Labels
Clear labels
Pull requests that update a dependency file
Likely to be an easy fix
features for moderateing spam, abuse, ...
An issue that is caused by an upstream dependency
Performance Issues affecting Big Repositories
Performance issues affecting memory use
performance issues with slow downs
Issue has been reviewed and confirmed to be present or accepted to be implemented
A fix for this issue is already in the attached milestone
The reported issue is the intended behavior
Docker themed issued
Migration issues
backport/done
backport/v1.0
backport/v1.1
backport/v1.10
backport/v1.11
backport/v1.12
backport/v1.13
backport/v1.14
backport/v1.15
backport/v1.2
backport/v1.3
backport/v1.4
backport/v1.5
backport/v1.6
backport/v1.7
backport/v1.8
backport/v1.9
bounty
changelog
dependencies
Pull requests that update a dependency file
frontport/done
frontport/main
good first issue
Likely to be an easy fix
Hacktoberfest
hacktoberfest-accepted
in progress
kind/api
kind/breaking
kind/bug
kind/build
kind/deployment
kind/deprecated
kind/docs
kind/enhancement
kind/feature
kind/lint
kind/misc
kind/moderation
features for moderateing spam, abuse, ...
kind/package
kind/proposal
kind/question
kind/refactor
kind/regression
kind/security
kind/summary
kind/testing
kind/translation
kind/ui
kind/upstream-related
An issue that is caused by an upstream dependency
kind/usability
kind/ux
lgtm/done
lgtm/need 1
lgtm/need 2
performance/bigrepo
Performance Issues affecting Big Repositories
performance/cpu
performance/memory
Performance issues affecting memory use
performance/speed
performance issues with slow downs
priority/critical
priority/low
priority/maybe
priority/medium
proposal/rejected
reviewed/confirmed
Issue has been reviewed and confirmed to be present or accepted to be implemented
reviewed/duplicate
reviewed/fixed
A fix for this issue is already in the attached milestone
reviewed/invalid
reviewed/not-a-bug
The reported issue is the intended behavior
reviewed/wontfix
skip-changelog
stale
status/blocked
status/needs-feedback
status/wip
theme/2fa
theme/authentication
theme/avatar
theme/backup-restore
theme/docker
Docker themed issued
theme/federation
theme/issues
theme/kanban
theme/markdown
theme/migration
Migration issues
theme/mobile
theme/pr
theme/signing
theme/sqlite
theme/timetracker
theme/webhook
theme/wiki
No Label
backport/done
backport/v1.0
backport/v1.1
backport/v1.10
backport/v1.11
backport/v1.12
backport/v1.13
backport/v1.14
backport/v1.15
backport/v1.2
backport/v1.3
backport/v1.4
backport/v1.5
backport/v1.6
backport/v1.7
backport/v1.8
backport/v1.9
bounty
changelog
dependencies
frontport/done
frontport/main
good first issue
Hacktoberfest
hacktoberfest-accepted
in progress
kind/api
kind/breaking
kind/bug
kind/build
kind/deployment
kind/deprecated
kind/docs
kind/enhancement
kind/feature
kind/lint
kind/misc
kind/moderation
kind/package
kind/proposal
kind/question
kind/refactor
kind/regression
kind/security
kind/summary
kind/testing
kind/translation
kind/ui
kind/upstream-related
kind/usability
kind/ux
lgtm/done
lgtm/need 1
lgtm/need 2
performance/bigrepo
performance/cpu
performance/memory
performance/speed
priority/critical
priority/low
priority/maybe
priority/medium
proposal/rejected
reviewed/confirmed
reviewed/duplicate
reviewed/fixed
reviewed/invalid
reviewed/not-a-bug
reviewed/wontfix
skip-changelog
stale
status/blocked
status/needs-feedback
status/wip
theme/2fa
theme/authentication
theme/avatar
theme/backup-restore
theme/docker
theme/federation
theme/issues
theme/kanban
theme/markdown
theme/migration
theme/mobile
theme/pr
theme/signing
theme/sqlite
theme/timetracker
theme/webhook
theme/wiki
Milestone
Clear milestone
No items
No Milestone
Projects
Clear projects
No project
Assignees
Clear assignees
No Assignees
4 Participants
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: lunny/gitea#17274
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
No description provided.
Delete Branch "techknowlogick/snap-fix"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
replace #17157
Fixes #16209
co-authored-by: @OleHusgaard
This fails, as this reports
2021-10-08T21:14:31Z gitea.web[30871]: 2021/10/08 21:14:31 ...s/install/setting.go:21:PreloadSettings() [I] AppPath: $(echo "/snap/gitea/x3/gitea"|sed "s/x3/current/")
@ -433,2 +433,3 @@
func getAppPath() (string, error) {
var appPath string
appPath := AppPath
if giteaAppPath, ok := os.LookupEnv("GITEA_APP_PATH"); ok {
This means that we now have another linker settable default value so it should be included here
https://github.com/go-gitea/gitea/blob/main/docs/content/doc/installation/from-source.en-us.md#changing-default-paths
@ -434,1 +434,3 @@
var appPath string
appPath := AppPath
if giteaAppPath, ok := os.LookupEnv("GITEA_APP_PATH"); ok {
appPath = giteaAppPath
This should be documented in https://github.com/go-gitea/gitea/blob/main/docs/content/doc/advanced/environment-variables.en-us.md#gitea-files
This and line 469 should be documented in https://github.com/go-gitea/gitea/blob/main/docs/content/doc/advanced/environment-variables.en-us.md#operating-system-specifics or perhaps a new section.
@ -433,2 +433,3 @@
func getAppPath() (string, error) {
var appPath string
appPath := AppPath
if giteaAppPath, ok := os.LookupEnv("GITEA_APP_PATH"); ok {
added
@ -434,1 +434,3 @@
var appPath string
appPath := AppPath
if giteaAppPath, ok := os.LookupEnv("GITEA_APP_PATH"); ok {
appPath = giteaAppPath
added
added
I think we should be more careful about the string replacement. Snap document says that the SNAP_REVISION can be something like "x1" (https://snapcraft.io/docs/environment-variables) , a very short string. Maybe there will be other revision strings in future.
So maybe we should just split the appPath and check if the second last field is SNAP_REVISION and replace it, and check the gitea binary existence again. And print a log here to tell users we changed the app path.
SNAP
andSNAP_REVISION
are not intended to be used by real users. So Maybe they can be written in other sections and warn users do not set these variables manually.Can we explain why GITEA_APP_PATH sometimes should be set manually? Otherwise it seems a little confusing.
It shouldn't be set usually, but in some rare cases it may need to be set to a symlink (ex. In the case of snap)
Yep, maybe this point can be described in the document, then there will be no confusing.
This SHOULD NOT be normally be set.
We absolutely need to discourage users from setting this but the more information we give about it the more likely that they are to set this - and do so incorrectly. However, if it is present it does need to be somewhere in the list of things that can affect Gitea.
(In some ways if I could think of a way of guaranteeing being able to create a directory that executables could be run from we could prevent the hook problem (and every hook related problem) by being able to set
git config core.hooksPath
to a Gitea owned path. The other half of the underlying problem relating to theauthorized_keys
file can be solved using a different template which is already possible.)Yes, I tried a lot of different variations of this, and could get nothing to work. Sorry for not getting back to you about this.
I do not think we need this environment variable to fix the issue at hand. The idea for it was that we could then set it in snapcraft.yaml and avoid snap-specific code in setting.go. But unfortunately it seems impossible to set it correctly in snapcraft.yaml.
I agree. Then the code would be like what I proposed in PR 17157, but with an added check that the second last field is SNAP_REVISION. That would also include a check with exec.LookPath() that the modified path will actually work.
Doesn't snap just plonk a symlink in
/usr/bin/gitea
? Why can't you setGITEA_APP_PATH=/usr/bin/gitea
?(Or better not rely on environment variables - compile the correct path in instead?)
@zeripath It seems that snap doesn't create symlink in
/usr/bin
by default now, https://askubuntu.com/questions/1314018/snap-app-cant-see-usr-bin , https://stackoverflow.com/questions/65586325/ubuntu-path-tries-to-execute-from-snap-folder-instead-of-usr-bin-terraform , unlesssnap install --classic
is used.I agree with OleHusgaard, if there is a way to fix the problem by tuning
snapcraft.yaml
, we had better to use it.However as today it seems that none of us have confidence to do the fix correctly in
snapcraft.yaml
, but the problem really exists and it makes snap users panic when they do upgrade.Now we have 3 easy choices:
--classic
and use/usr/bin/gitea
for GITEA_APP_PATH, it makes our snap package not that modern.Key problem here is none of us is snap expert, maybe in future we can find a better way.
Another hacky method:
symlink
step can also be done bysnapcraft.yml
, then we just need to set GITEA_APP_PATH to SNAP_DATA/gitea on our side https://stackoverflow.com/questions/43505004/how-do-i-target-snap-data-from-snapcraft-yamlI have been thinking about this and there may also be another less hacky method:
About (5), we can not and should not
use LDFLAGS to initialize a golang variable appPathOverride at build time
, because the path may change, it can not be predicted at build time.