Figma-Linux / figma-linux-font-helper

Font Helper for Figma for Linux x64 platform
GNU General Public License v2.0
410 stars 34 forks source link

${XDG_CONFIG_HOME} not valid on status systemectl #38

Open blackinitial opened 1 year ago

blackinitial commented 1 year ago

when i run systemctl --user restart figma-fonthelper.service or status, i got error home/user/.config/systemd/user/figma-fonthelper-updater.service:7: Neither a valid executable name nor an absolute path: ${XDG_CONFIG_HOME}/figma-fonthelper/updater.sh

i was add export on zshrc export XDG_CONFIG_HOME="$HOME/.config"

i try to manual edit Execstart from ${XDG_CONFIG_HOME} to /home/user/.local/share on ~/.config/systemd/user/figma-fonthelper-updater.service it can start system with no error but the config come back again to ${XDG_CONFIG_HOME} after many minutes.

what i miss it?

david03130 commented 1 year ago

I have the same issue.

effeottantuno commented 1 year ago

same, the only fix that i found is to reinstall the helper but it only lasts until i reboot

radan-magie commented 1 year ago

Same for me, on Ubuntu 22.04.2 LTS.

I thought that I found a solution here:

If the file~/.profile doesn't exist yet, create an empty file with the command touch ~/.profile. Open the file using a text editor and add these two lines:

XDG_CONFIG_HOME="$HOME/.config"
export XDG_CONFIG_HOME

Save the file, and it will take effect the next time you login. or type:

. ~/.profile

But after restart did't work, sorry.

datsudo commented 1 year ago

Same for me, on Ubuntu 22.04.2 LTS.

Found a solution here:

If the file~/.profile doesn't exist yet, create an empty file with the command touch ~/.profile. Open the file using a text editor and add these two lines:

XDG_CONFIG_HOME="$HOME/.config"
export XDG_CONFIG_HOME

Save the file, and it will take effect the next time you login. or type:

. ~/.profile

I already have that in my $HOME/.xprofile:

...
export XDG_CONFIG_HOME="$HOME/.config"
...

image

Service status:

● figma-fonthelper.service - Font Helper for Figma
     Loaded: bad-setting (Reason: Unit figma-fonthelper.service has a bad unit file setting.)
     Active: active (running) since Wed 2023-07-26 14:07:36 PST; 6min ago
   Main PID: 7301 (fonthelper)
        CPU: 1.495s
     CGroup: /user.slice/user-1000.slice/user@1000.service/app.slice/figma-fonthelper.service
             └─7301 /home/datsudo/.local/share/figma-fonthelper/fonthelper

Jul 26 14:07:41 eos systemd[1233]: /home/datsudo/.config/systemd/user/figma-fonthelper.service:7: Neither a valid executable name nor an absolute path: ${XDG_CONFIG_HOME}/figma-fonthelper/fonthelper
Jul 26 14:07:41 eos systemd[1233]: figma-fonthelper.service: Unit configuration has fatal error, unit will not be started.
datsudo commented 1 year ago

For now I just set the ExecStart path like this:

[Unit]
Description=Font Helper for Figma
After=systemd-user-sessions.service

[Service]
Type=simple
ExecStart=/home/datsudo/.local/share/figma-fonthelper/fonthelper
ExecStop=/bin/bash -c '`which killall` fonthelper'
Restart=on-failure

[Install]
WantedBy=multi-user.target

The original value was ${XDG_CONFIG_HOME}/figma-fonthelper/fonthelper but the exec file is actually installed in ~/.local/share/figma-fonthelper. I tried ${XDG_DATA_HOME}/figma-fonthelper/fonthelper (because I also set XDG_DATA_HOME to ~/.local/share) but still doesn't work.

radan-magie commented 1 year ago

Sorry my solution didn't works after restart.

Ended with a script that launchs /home/<username>/.local/share/figma-fonthelper/fonthelper

blackinitial commented 1 year ago

For now I just set the ExecStart path like this:

[Unit]
Description=Font Helper for Figma
After=systemd-user-sessions.service

[Service]
Type=simple
ExecStart=/home/datsudo/.local/share/figma-fonthelper/fonthelper
ExecStop=/bin/bash -c '`which killall` fonthelper'
Restart=on-failure

[Install]
WantedBy=multi-user.target

The original value was ${XDG_CONFIG_HOME}/figma-fonthelper/fonthelper but the exec file is actually installed in ~/.local/share/figma-fonthelper. I tried ${XDG_DATA_HOME}/figma-fonthelper/fonthelper (because I also set XDG_DATA_HOME to ~/.local/share) but still doesn't work.

same i was set like that, but after minutes the updater config back to ${XDG_DATA_HOME}/ again.

datsudo commented 1 year ago

For now I just set the ExecStart path like this:

[Unit]
Description=Font Helper for Figma
After=systemd-user-sessions.service

[Service]
Type=simple
ExecStart=/home/datsudo/.local/share/figma-fonthelper/fonthelper
ExecStop=/bin/bash -c '`which killall` fonthelper'
Restart=on-failure

[Install]
WantedBy=multi-user.target

The original value was ${XDG_CONFIG_HOME}/figma-fonthelper/fonthelper but the exec file is actually installed in ~/.local/share/figma-fonthelper. I tried ${XDG_DATA_HOME}/figma-fonthelper/fonthelper (because I also set XDG_DATA_HOME to ~/.local/share) but still doesn't work.

same i was set like that, but after minutes the updater config back to ${XDG_DATA_HOME}/ again.

You might want to disable the auto-update service

zewebdev1337 commented 11 months ago

Since the issue is still open, I'd like to point to a "solution" I implemented in my fork (be warned, it's extremely hacky).

@zewebdev1337/figma-archlinux-font-helper [named like so because at first I thought it was only arch being quirky]

It's done by using sed to hijack the changes brought over by the update, rewriting the appropriate paths. I also turned the install into a system-wide service as it's marked as wanted by multi-user.target, which is inexistent for user services). If I understand correctly, the update system is working on my fork but I'm honestly not sure. What I know is that using sed the way I did allows me to keep the update service and prevent the bugs I mentioned. (and update service reports all good after lots of troubleshooting. In fact I catched several updates that broke my install and addressed the breaking changes brought over by them one by one).

It seems like this is an issue that requires a somewhat complex and deep refactoring so I've decided against opening a PR as my code makes everything even more convoluted and changes some key aspects of the original implementation like moving the files to /usr/share/, /etc/ and /etc/systemd/system/, thus requiring sudo to install.

antoninhrlt commented 11 months ago

Since the issue is still open, I'd like to point to a "solution" I implemented in my fork (be warned, it's extremely hacky).

@zewebdev1337/figma-archlinux-font-helper [named like so because at first I thought it was only arch being quirky]

It's done by using sed to hijack the changes brought over by the update, rewriting the appropriate paths. I also turned the install into a system-wide service as it's marked as wanted by multi-user.target, which is inexistent for user services). If I understand correctly, the update system is working on my fork but I'm honestly not sure. What I know is that using sed the way I did allows me to keep the update service and prevent the bugs I mentioned. (and update service reports all good after lots of troubleshooting. In fact I catched several updates that broke my install and addressed the breaking changes brought over by them one by one).

It seems like this is an issue that requires a somewhat complex and deep refactoring so I've decided against opening a PR as my code makes everything even more convoluted and changes some key aspects of the original implementation like moving the files to /usr/share/, /etc/ and /etc/systemd/system/, thus requiring sudo to install.

Thanks for this. After the install.sh execution is done, I get these messages :

● figma-fonthelper.service - Font Helper for Figma
     Loaded: loaded (/etc/systemd/system/figma-fonthelper.service; enabled; preset: disabled)
     Active: active (running) since Thu 2023-11-30 21:39:48 CET; 2min 29s ago
   Main PID: 1014 (fonthelper)
      Tasks: 17 (limit: 18384)
     Memory: 4.9M
        CPU: 30ms
     CGroup: /system.slice/figma-fonthelper.service
             └─1014 /usr/share/figma-fonthelper/fonthelper

nov. 30 21:39:48 antolenovo systemd[1]: Started Font Helper for Figma.
● figma-fonthelper-updater.service - Updater for Font Helper
     Loaded: loaded (/etc/systemd/system/figma-fonthelper-updater.service; enabled; preset: disabled)
     Active: active (running) since Thu 2023-11-30 21:39:48 CET; 2min 29s ago
   Main PID: 1013 (updater.sh)
      Tasks: 2 (limit: 18384)
     Memory: 1.4M
        CPU: 70ms
     CGroup: /system.slice/figma-fonthelper-updater.service
             ├─1013 /bin/bash /usr/share/figma-fonthelper/updater.sh
             └─1042 sleep 360

That's great.... but the tool doesn't actually works. And, when I do this, here is what I get:

$ systemctl --user status figma-fonthelper.service                                        INT ✘ 
Unit figma-fonthelper.service could not be found.

So I tried to run this and I got:

systemctl list-unit-files --state=enabled --type=service                                  4 ✘ 
UNIT FILE                          STATE   PRESET  
...
figma-fonthelper-updater.service   enabled disabled
figma-fonthelper.service           enabled disabled
...

It's actually weird. The tool doesn't work, isn't found but is enabled. Maybe could you help me about that ?

zewebdev1337 commented 11 months ago

Since the issue is still open, I'd like to point to a "solution" I implemented in my fork (be warned, it's extremely hacky). @zewebdev1337/figma-archlinux-font-helper [named like so because at first I thought it was only arch being quirky] It's done by using sed to hijack the changes brought over by the update, rewriting the appropriate paths. I also turned the install into a system-wide service as it's marked as wanted by multi-user.target, which is inexistent for user services). If I understand correctly, the update system is working on my fork but I'm honestly not sure. What I know is that using sed the way I did allows me to keep the update service and prevent the bugs I mentioned. (and update service reports all good after lots of troubleshooting. In fact I catched several updates that broke my install and addressed the breaking changes brought over by them one by one). It seems like this is an issue that requires a somewhat complex and deep refactoring so I've decided against opening a PR as my code makes everything even more convoluted and changes some key aspects of the original implementation like moving the files to /usr/share/, /etc/ and /etc/systemd/system/, thus requiring sudo to install.

Thanks for this. After the install.sh execution is done, I get these messages :

● figma-fonthelper.service - Font Helper for Figma
     Loaded: loaded (/etc/systemd/system/figma-fonthelper.service; enabled; preset: disabled)
     Active: active (running) since Thu 2023-11-30 21:39:48 CET; 2min 29s ago
   Main PID: 1014 (fonthelper)
      Tasks: 17 (limit: 18384)
     Memory: 4.9M
        CPU: 30ms
     CGroup: /system.slice/figma-fonthelper.service
             └─1014 /usr/share/figma-fonthelper/fonthelper

nov. 30 21:39:48 antolenovo systemd[1]: Started Font Helper for Figma.
● figma-fonthelper-updater.service - Updater for Font Helper
     Loaded: loaded (/etc/systemd/system/figma-fonthelper-updater.service; enabled; preset: disabled)
     Active: active (running) since Thu 2023-11-30 21:39:48 CET; 2min 29s ago
   Main PID: 1013 (updater.sh)
      Tasks: 2 (limit: 18384)
     Memory: 1.4M
        CPU: 70ms
     CGroup: /system.slice/figma-fonthelper-updater.service
             ├─1013 /bin/bash /usr/share/figma-fonthelper/updater.sh
             └─1042 sleep 360

That's great.... but the tool doesn't actually works. And, when I do this, here is what I get:

$ systemctl --user status figma-fonthelper.service                                        INT ✘ 
Unit figma-fonthelper.service could not be found.

So I tried to run this and I got:

systemctl list-unit-files --state=enabled --type=service                                  4 ✘ 
UNIT FILE                          STATE   PRESET  
...
figma-fonthelper-updater.service   enabled disabled
figma-fonthelper.service           enabled disabled
...

It's actually weird. The tool doesn't work, isn't found but is enabled. Maybe could you help me about that ?

It's weird indeed; the reason you get Unit figma-fonthelper.service could not be found. is because I converted the service to be a system service, so adding the --user flag founds no service, but if you remove --user, you should actually see the status of the tool.

My suggestion is to disable the services disable before uninstalling (just remove the executables at /usr/share/figma-fonthelper/ and service files at /etc/systemd/system/ once you disabled the services), then reinstall it, if you query the status after that, it should be running and working (it should look no different than what you got in your first messages after install).

I also noticed some odd behavior while working on the patch if I didn't disable the services before installing again, maybe that's what's happening here.

Elmabt commented 10 months ago

i am getting the same problem.

i have changed the path from ${XDG_CONFIG_HOME}/figma-fonthelper/fonthelper to /home/elma/.local/share/figma-fonthelper/fonthelper

but i am still getting these errors

figma-fonthelper.service - Font Helper for Figma
     Loaded: bad-setting (Reason: Unit figma-fonthelper.service has a bad unit file setting.)
     Active: active (running) since Wed 2024-01-10 15:27:05 CET; 8min ago
   Main PID: 211715 (fonthelper)
        CPU: 255ms
     CGroup: system.slice/figma-fonthelper.service
             └─211715 /home/elma/.local/share/figma-fonthelper/fonthelper

jan 10 15:27:07 C systemd[2106]: /home/elma/.config/systemd/user/figma-fon>
jan 10 15:27:07 C systemd[2106]: figma-fonthelper.service: Unit configuration has fatal error, u>
jan 10 15:27:07 C systemd[2106]: /home/elma/.config/systemd/user/figma-fon>
jan 10 15:27:07 C systemd[2106]: figma-fonthelper.service: Unit configuration has fatal error, u>
jan 10 15:33:10 C systemd[2106]: /home/elma/.config/systemd/user/figma-fon>
jan 10 15:33:10 C systemd[2106]: figma-fonthelper.service: Unit configuration has fatal error, u>
jan 10 15:33:10 C systemd[2106]: /home/elma/.config/systemd/user/figma-fon>
jan 10 15:33:10 C systemd[2106]: figma-fonthelper.service: Unit configuration has fatal error, u>
jan 10 15:33:10 C systemd[2106]: /home/elma/.config/systemd/user/figma-fon>
jan 10 15:33:10 C systemd[2106]: figma-fonthelper.service: Unit configuration has fatal error, u>
~

has anyone found the solution?

navidmafi commented 10 months ago

41 has already fixed the issue but needs to be tagged by maintainers to be fetched as an update in the systemd service.

Flashwalker commented 9 months ago

I just made a fresh install. And still get ${XDG_CONFIG_HOME} instead of /home/user/.local/share in .service files.

Also the json config is not applied, because it's already created by figma-linux. So i edited it manually with a host and port keys.

The port now should be 44950 instead of 18412.

Swivelgames commented 8 months ago

I figured out what the problem is (described at the bottom), and put together a workaround.

[!IMPORTANT] This workaround requires disabling the updater. Any updates will have to be done manually.

[!CAUTION] This service gives figma.com access to your local filesystem. While highly unlikely, failing to update could result in exposing your machine to unpatched vulnerabilities.

1. Disable and Stop the Updater

systemctl --user disable figma-fonthelper-updater.service
systemctl --user stop figma-fonthelper-updater.service

2. Hard-code your .local/share dir in the service file:

  [Unit]
  Description=Font Helper for Figma
  After=systemd-user-sessions.service

  [Service]
  Type=simple
- ExecStart=${XDG_CONFIG_HOME}/figma-fonthelper/fonthelper
+ ExecStart=/home/YOUR_USERNAME/.local/share/figma-fonthelper/fonthelper
  ExecStop=/bin/bash -c '`which killall` fonthelper'
  Restart=on-failure

  [Install]
  WantedBy=multi-user.target

3. Restart the systemd daemon and the service

systemctl --user daemon-restart
systemctl --user restart figma-fonthelper.service

[!TIP] You might also want to make sure there are no rogue updaters still running:

$ ps -ef | grep figma
usernam+  927970       0  0 01:21 ?        00:00:00 /bin/bash /home/username/.local/share/figma-fonthelper/updater.sh
usernam+  936562    1631  0 01:38 ?        00:00:00 /home/username/.local/share/figma-fonthelper/fonthelper
$ kill -9 927970

The Problem

There are multiple reasons why this isn't working properly...

  1. The systemd service files are referencing XDG_CONFIG_HOME, when they should be looking for XDG_DATA_HOME
  2. If either XDG_DATA_HOME or XDG_CONFIG_HOME are unset, the service will fail anyways
  3. The updater is in an infinite loop downloading the latest version. This is due to fonthelper -v always returning 0.1.5 even for version 0.1.7.