Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Native Termux builds #3605

Open
ErrrorMaxx opened this issue Feb 27, 2024 · 6 comments
Open

feat: Native Termux builds #3605

ErrrorMaxx opened this issue Feb 27, 2024 · 6 comments
Labels
android only Affects Android/Termux only enhancement New feature or request help wanted Extra attention is needed

Comments

@ErrrorMaxx
Copy link
Contributor

Describe the bug

chezmoi on Android sometimes can't connect to DNS. So it can't download externals

To reproduce

Idk, it just sometimes work and sometimes it doesn't

Expected behavior

No errors, externals are always can be downloaded

Output of command with the --verbose flag

$ chezmoi --verbose diff
chezmoi: Get "https://github.com/macvk/dnsleaktest/raw/HEAD/dnsleaktest.py": dial tcp: lookup github.com on [::1]:53: read udp [::1]:50174->[::1]:53: read: connection refused

$ chezmoi doctor
RESULT    CHECK                       MESSAGE
failed    latest-version              Get "https://api.github.com/repos/twpayne/chezmoi/releases/latest": dial tcp: lookup api.github.com on [::1]:53: read udp [::1]:57535->[::1]:53: read: connection refused

Output of chezmoi doctor

$ chezmoi doctor
RESULT    CHECK                       MESSAGE
ok        version                     v2.47.0, commit 39bd915f446068862cc3064edb6dbeee795785ca, built at 2024-02-25T20:56:37Z, built by goreleaser
failed    latest-version              Get "https://api.github.com/repos/twpayne/chezmoi/releases/latest": dial tcp: lookup api.github.com on [::1]:53: read udp [::1]:54920->[::1]:53: read: connection refused
ok        os-arch                     android/arm64
ok        uname                       Linux localhost 4.19.191+ #1 SMP PREEMPT Wed Nov 29 21:44:22 CST 2023 aarch64 Android
ok        go-version                  go1.22.0 (gc)
ok        executable                  ~/.local/bin/chezmoi
ok        upgrade-method              replace-executable
ok        config-file                 ~/.config/chezmoi/chezmoi.yaml, last modified 2024-02-27T15:51:50Z
warning   source-dir                  ~/.local/share/chezmoi is a git working tree (dirty)
warning   suspicious-entries          ~/.local/share/chezmoi/home/dot_config/rootmoi/chezmoi.yaml.tmpl
warning   working-tree                ~/.local/share/chezmoi is a git working tree (dirty)
warning   dest-dir                    ~ is a git working tree (dirty)
warning   umask                       077
ok        cd-command                  found /data/data/com.termux/files/usr/bin/zsh
ok        cd-args                     /data/data/com.termux/files/usr/bin/zsh
info      diff-command                not set
ok        edit-command                found /data/data/com.termux/files/usr/bin/micro
ok        edit-args                   micro
ok        git-command                 found /data/data/com.termux/files/usr/bin/git, version 2.44.0
warning   merge-command               vimdiff not found in $PATH
ok        shell-command               found /data/data/com.termux/files/usr/bin/zsh
ok        shell-args                  /data/data/com.termux/files/usr/bin/zsh
info      age-command                 age not found in $PATH
ok        gpg-command                 found /data/data/com.termux/files/usr/bin/gpg, version 2.4.4
info      pinentry-command            not set
info      1password-command           op not found in $PATH
info      bitwarden-command           bw not found in $PATH
info      bitwarden-secrets-command   bws not found in $PATH
info      dashlane-command            dcli not found in $PATH
info      doppler-command             doppler not found in $PATH
info      gopass-command              gopass not found in $PATH
info      keepassxc-command           keepassxc-cli not found in $PATH
info      keepassxc-db                not set
info      keeper-command              keeper not found in $PATH
info      lastpass-command            lpass not found in $PATH
info      pass-command                pass not found in $PATH
info      passhole-command            ph not found in $PATH
info      rbw-command                 rbw not found in $PATH
info      vault-command               vault not found in $PATH
info      vlt-command                 vlt not found in $PATH
info      secret-command              not set
@twpayne
Copy link
Owner

twpayne commented Feb 27, 2024

This is something to do with your system. This is not a bug in chezmoi.

@twpayne twpayne closed this as not planned Won't fix, can't repro, duplicate, stale Feb 27, 2024
@ErrrorMaxx
Copy link
Contributor Author

ErrrorMaxx commented Feb 27, 2024

After switching to Termux's chezmoi I found out that after diffing with Termux build (and when all externals are downloaded), then diffing with official build works again (using cached externals).
So turns out that android build without some Termux patches works only partially

$ /data/data/com.termux/files/home/.local/bin/chezmoi diff
chezmoi: Get "https://github.com/macvk/dnsleaktest/raw/HEAD/dnsleaktest.py": dial tcp: lookup github.com on [::1]:53: read udp [::1]:48172->[::1]:53: read: connection refused

$ /data/data/com.termux/files/usr/bin/chezmoi diff
*diff here*

$ /data/data/com.termux/files/home/.local/bin/chezmoi diff
*diff here*

UPD: I did some research and Termux actually has a patch for golang: termux/termux-packages/packages/golang/fix-hardcoded-etc-resolv-conf.sh which fixes DNS resolving on Android

UPD2: This is actually a bug of golang on Android: golang/go#8877

@ErrrorMaxx ErrrorMaxx changed the title chezmoi on Android sometimes can't connect to DNS chezmoi on Android can't connect to Internet/DNS Feb 28, 2024
@twpayne twpayne reopened this Feb 28, 2024
@twpayne twpayne added bug Something isn't working in dependency In a dependency, not in chezmoi labels Feb 28, 2024
@twpayne
Copy link
Owner

twpayne commented Feb 28, 2024

Thanks for the further investigation and apologies for the too-hasty fix.

If I understand correctly, there are two ways for chezmoi to work around this bug in Go:

  1. Build the Android binaries with cgo. This will require the Android SDK.
  2. Add a user-configurable DNS server in chezmoi's config and use that on Android.
  3. Use https://github.com/mtibben/androiddnsfix.

Of these, (1) is the cleanest but might not be supported by goreleaser (the tool chezmoi uses to build its release binaries), (2) has poor user experience, and (3) strikes me as too much of a hack.

Does the Termux-built chezmoi binary have this same problem?

@ErrrorMaxx
Copy link
Contributor Author

Patch in Termux is for golang itself. So any binaries built in Termux are patched:

$ gitcd https://github.com/twpayne/chezmoi repos/chezmoi
Cloning into 'repos/chezmoi'...
remote: Enumerating objects: 76049, done.
remote: Counting objects: 100% (5230/5230), done.
remote: Compressing objects: 100% (583/583), done.
remote: Total 76049 (delta 4748), reused 4696 (delta 4627), pack-reused 70819
Receiving objects: 100% (76049/76049), 70.23 MiB | 4.79 MiB/s, done.
Resolving deltas: 100% (42413/42413), done.

$ go build
...

$ ./chezmoi diff -R
*diff here* (externals downloaded)

@twpayne twpayne added the android only Affects Android/Termux only label Apr 28, 2024
@twpayne
Copy link
Owner

twpayne commented Jul 1, 2024

For info, goreleaser is adding support for Termux in goreleaser/goreleaser#4901, which will be part of goreleaser v2.1.0 (not released yet).

@twpayne twpayne changed the title chezmoi on Android can't connect to Internet/DNS feat: Native Termux builds Sep 13, 2024
@twpayne twpayne added help wanted Extra attention is needed enhancement New feature or request and removed bug Something isn't working in dependency In a dependency, not in chezmoi labels Sep 13, 2024
@twpayne
Copy link
Owner

twpayne commented Sep 13, 2024

I've updated this issue to show that native builds for Termux would be an enhancement for chezmoi, but they are not something that I will work on myself because I do not use Termux and do not have access to a Termux environment.

If someone could update chezmoi's GitHub Actions to take advantage of goreleaser/goreleaser#4901, that would be awesome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android only Affects Android/Termux only enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants