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

Fix: ulauncher paths finding #85350

Closed
wants to merge 1 commit into from
Closed

Fix: ulauncher paths finding #85350

wants to merge 1 commit into from

Conversation

gytis-ivaskevicius
Copy link
Contributor

@gytis-ivaskevicius gytis-ivaskevicius commented Apr 16, 2020

Fix path finding

Motivation for this change

Fix for the following exception:

2020-04-16 03:29:53,349 | ERROR | ulauncher: except_hook() | Uncaught exception
Traceback (most recent call last):
  File "/nix/store/p8qyv86nhfbf7pgn9ccdfjy4wzkqxs8h-ulauncher-5.6.1/lib/python3.7/site-packages/ulauncher/config.py", line 68, in get_data_path
    return paths[0]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/nix/store/p8qyv86nhfbf7pgn9ccdfjy4wzkqxs8h-ulauncher-5.6.1/bin/..ulauncher-wrapped-wrapped", line 29, in <module>
    main()
  File "/nix/store/p8qyv86nhfbf7pgn9ccdfjy4wzkqxs8h-ulauncher-5.6.1/lib/python3.7/site-packages/ulauncher/main.py", line 128, in main
    window = UlauncherWindow.get_instance()
  File "/nix/store/p8qyv86nhfbf7pgn9ccdfjy4wzkqxs8h-ulauncher-5.6.1/lib/python3.7/site-packages/ulauncher/utils/decorator/singleton.py", line 19, in wrapper
    instance = fn(*args, **kwargs)
  File "/nix/store/p8qyv86nhfbf7pgn9ccdfjy4wzkqxs8h-ulauncher-5.6.1/lib/python3.7/site-packages/ulauncher/ui/windows/UlauncherWindow.py", line 55, in get_instance
    return cls()
  File "/nix/store/p8qyv86nhfbf7pgn9ccdfjy4wzkqxs8h-ulauncher-5.6.1/lib/python3.7/site-packages/ulauncher/ui/windows/UlauncherWindow.py", line 63, in __new__
    builder = Builder.new_from_file('UlauncherWindow')
  File "/nix/store/p8qyv86nhfbf7pgn9ccdfjy4wzkqxs8h-ulauncher-5.6.1/lib/python3.7/site-packages/ulauncher/ui/windows/Builder.py", line 47, in new_from_file
    ui_filename = get_data_file('ui', '%s.ui' % (builder_file_name,))
  File "/nix/store/p8qyv86nhfbf7pgn9ccdfjy4wzkqxs8h-ulauncher-5.6.1/lib/python3.7/site-packages/ulauncher/config.py", line 42, in get_data_file
    return os.path.join(get_data_path(), *path_segments)
  File "/nix/store/p8qyv86nhfbf7pgn9ccdfjy4wzkqxs8h-ulauncher-5.6.1/lib/python3.7/site-packages/ulauncher/config.py", line 70, in get_data_path
    raise ProjectPathNotFoundError()
ulauncher.config.ProjectPathNotFoundError
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@gytis-ivaskevicius
Copy link
Contributor Author

Just now I was just trying to figure out how that fancy filtering works in the old version and why didn't it worked before and noticed:

+                # Get path that isn't in the /nix/store so they don't get hardcoded into configs
+                if not dir.startswith("/nix/store/")

that's the main change, in my code this part is inverted and is necessary for application to work

@worldofpeace
Copy link
Contributor

@WithoutCaps Are you using ulauncher installed in systemPackages?
Please also read my commit message

We construct the ulauncher data path from xdg_data_dirs
and prevent it from being a nix store path or being xdg_data_home.
We do this to prevent /nix/store paths being hardcoded to shortcuts.json.
On NixOS this path will either be /run/current-system/sw/share/ulauncher
or $HOME/.nix-profile/share/ulauncher if the user used nix-env.

What we could do is have it fallback to code that would return paths from /nix/store.
It'll be broken and hardcoded on non-nixos linux, but you won't get an exception. And you won't get an exception if it isn't installed.

@gytis-ivaskevicius
Copy link
Contributor Author

@worldofpeace Hi, yes I am using ulauncher from systemPackages, but even if I am not - it still does not seem to work:
image

@worldofpeace
Copy link
Contributor

Weird, what's the value of XDG_DATA_DIRS in your shell?

@gytis-ivaskevicius
Copy link
Contributor Author

image

/nix/store/29wjgjk26jdg74h8pxb9k8dhwxjc7mqs-termite-15/share:/nix/store/2chzii7gwmlcii9x73l0v3bl7lf2awvb-gtk+3-3.24.14/share/gsettings-schemas/gtk+3-3.24.14:/nix/store/xjg7kpw38mfaab2fsarll2d39nk06ha5-gsettings-desktop-schemas-3.36.0/share/gsettings-schemas/gsettings-desktop-schemas-3.36.0:/nix/store/2chzii7gwmlcii9x73l0v3bl7lf2awvb-gtk+3-3.24.14/share/gsettings-schemas/gtk+3-3.24.14:/nix/store/xjg7kpw38mfaab2fsarll2d39nk06ha5-gsettings-desktop-schemas-3.36.0/share/gsettings-schemas/gsettings-desktop-schemas-3.36.0:/home/gytis/.nix-profile/share:/etc/profiles/per-user/gytis/share:/nix/var/nix/profiles/default/share:/run/current-system/sw/share

@gytis-ivaskevicius
Copy link
Contributor Author

@worldofpeace any ideas?

@tobinjones
Copy link

Just a note that I have the same issue, running up-to-date NixOS. I note that I have no ulauncher directory in /run/current-system/sw/.

In the meantime I am using this patch as an overlay, which works.

@gytis-ivaskevicius
Copy link
Contributor Author

@worldofpeace Any thoughts?

@stale
Copy link

stale bot commented Nov 3, 2020

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Nov 3, 2020
@gytis-ivaskevicius
Copy link
Contributor Author

Alright, guys, time to close this PR since I am tired of seeing this on my GitHub homepage. I switched to rofi anyways :D

@aaronjanse
Copy link
Member

I get this error when running via nix run nixpkgs#ulauncher but not when I do nix profile install nixpkgs#ulauncher. I think this relates to /run/current-system/sw/.

If this is intended behavior, perhaps 0001-Adjust-get_data_path-for-NixOS.patch should be appended to provide a helpful error message when no paths are found?

@aaronjanse aaronjanse reopened this Dec 22, 2020
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Dec 22, 2020
@aaronjanse
Copy link
Member

Oh whoops, I didn't mean to re-open. I'll leave that to someone else to decide

@aaronjanse aaronjanse closed this Dec 22, 2020
@aaronjanse
Copy link
Member

See also #119350

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

Successfully merging this pull request may close these issues.

None yet

5 participants