Skip to content

Open fails when xdg-open would launch a terminal program #10045

Closed

Description

@genevieve-me
  • fish 3.6.1
  • Linux 6.6.0-rc3 Need a history built-in #1-NixOS SMP PREEMPT_DYNAMIC
  • I tried running fish with no configuration (sh -c 'env HOME=$(mktemp -d) XDG_CONFIG_HOME= fish') and experienced the same behavior

Expected behavior

> echo $EDITOR
hx
> xdg-mime query default inode/directory 
lf.desktop
> xdg-open ~/mydirectory
(lf opens)
> open ~/mydirectory
(lf opens)
> open ~/myfile.txt
(hx opens)
> xdg-open ~/myfile.txt
(hx opens)

Current behavior

> xdg-open ~/mydirectory
(lf opens)
> open ~/mydirectory
(nothing happens and I'm still at a fish prompt)
> open ~/myfile.txt
(nothing happens and I'm still at a fish prompt)
> xdg-open ~/myfile.txt
(hx opens)

Furthermore, I tried copying the basic behavior of open.fish, and the following occurs:

> function opentest
       for i in $argv
             xdg-open $i
         end
     end
> opentest somedir/
(lf is opened correctly)

I see mention of a possible issue in the code comment here : https://github.com/fish-shell/fish-shell/blob/4ab34f2e86f91e90e732302446f1382cc122f07c/share/functions/open.fish#L33C48-L33C48 : could that be relevant?

Activity

  1. faho commented on Oct 4, 2023

    @faho
    Member

    The issue here is that we background the xdg-open - we use xdg-open $i &. This is a workaround for an issue where in some paths it'll do that itself and in others won't.

    Fundamentally we can't detect that and have to pick one - either we work around that bug or we enable things running in the terminal.

    Ideally that would be fixed in xdg-open, but it's been pretty unmaintained for years (and never was all that great tbqh). If it isn't I'm not sure if we want to reintroduce a bug for graphical applications, which xdg-open was always geared towards more, or if we want to allow terminal applications.

    Or we could always drop the open function and let people deal with it themselves.

  2. faho commented on Oct 4, 2023

    @faho
    Member

    This is a workaround for an issue where in some paths it'll do that itself and in others won't.

    Fixed in xdg-utils 1 month ago.

  3. added this to the fish 3.7.0 milestone on Oct 4, 2023
  4. added
    bugSomething that's not working as intended
    on Oct 4, 2023
  5. added a commit that references this issue on Oct 8, 2023
    04492a1
  6. added a commit that references this issue on Jan 27, 2024
    f8e3881
  7. locked as resolved and limited conversation to collaborators on Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething that's not working as intended

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions