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

gvim appimage: run vim if called as vim; work with extracted appimage #67

Closed
mralusw opened this issue Mar 26, 2024 · 4 comments
Closed

Comments

@mralusw
Copy link
Contributor

mralusw commented Mar 26, 2024

The GVim appimage always tries to run as gvim (even if called through a symlink named vim, and even if no X11 $DISPLAY is set). This is because AppRun.wrapped tries first

test -L "${HERE}/usr/bin/gvim" && exec "${HERE}/usr/bin/gvim" "${@+"$@"}"

Cutting through all the cruft probably generated by linuxdeploy (two bash exec's even though no bash features are needed, the "${@+"$@"}" workaround for 1990's Bash), here's a simpler AppRun that works as vim when the appimage is called as vim. As a bonus this AppRun works when symlinked from an extracted appimage (hidden option gvim.appimage --appimage-extract available with all appimages)

#!/bin/sh
set -ue
: "${ARGV0:=$0}"  # run without AppImage too
this_dir=$(readlink -f "$0")
this_dir=${this_dir%/*}  # empty for '/'
[ -r "$this_dir"/apprun-hooks/linuxdeploy-plugin-gtk.sh ] &&
  .  "$this_dir"/apprun-hooks/linuxdeploy-plugin-gtk.sh
VIMRUNTIME=${this_dir}/usr/share/vim/vim91; export VIMRUNTIME
test -x "${this_dir}/usr/bin/gvim" || ARGV0=/vim
case "${ARGV0##*/}" in
  (vim*) set -- "${this_dir}/usr/bin/vim"  "$@" ;;
  (*)    set -- "${this_dir}/usr/bin/gvim" "$@" ;;
esac
unset ARGV0
exec "$@"

(note: updated after further investigation & #68)

@jnm
Copy link

jnm commented Mar 27, 2024

Would you consider making a PR for this?

@chrisbra
Copy link
Member

yes please. I'd appreciate it.

@mralusw
Copy link
Contributor Author

mralusw commented Mar 28, 2024

I've pushed PR #68; it's a little complicated, comments in the commit message (identical to PR message).

Summary:

  • Vim.appimage didn't have any problems to begin with.
  • GVim.appimage (un-extracted) can now be symlinked to vim / gvim and behaves accordingly (just as the release notes say — they were incorrect as this issue explains).
  • remaining problem: GVim.appimage's AppRun is generated by linuxdeploy-plugin-gtk (i.e. not under our control) and fails when symlinked from an extracted appimage (aka AppDir); this is not a new problem — it also fails before the PR, when symlinked (due to dirname / readlink order).
  • thus we'd still need a separate script (say AppDirRun, similar to the one I quoted in my initial issue) for users who extract. Alternatively, we'd need to mess with the deployment process and patch / replace the "broken" AppRun just before packaging the appimage archive (I'm not keen on this).

I've tested by regenerating Vim.appimage and GVim.appimage manually with appimagetool; I have not tested the GitHub deployment workflow though.

Should I add a separate AppDirRun as proposed in #68?

chrisbra pushed a commit that referenced this issue Mar 28, 2024
appimage.sh: detect vim/gvim self name
related: #67 

Signed-off-by: Christian Brabandt <[email protected]>
@chrisbra
Copy link
Member

closing as fixed by #68

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants