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

Respect localization for main directory (e.g., ~/Dokkumente) #8010

Closed
2 tasks done
starsareintherose opened this issue Aug 21, 2021 · 24 comments · Fixed by #9625 or #9837
Closed
2 tasks done

Respect localization for main directory (e.g., ~/Dokkumente) #8010

starsareintherose opened this issue Aug 21, 2021 · 24 comments · Fixed by #9625 or #9837

Comments

@starsareintherose
Copy link

starsareintherose commented Aug 21, 2021

JabRef version

5.3 (latest release)

Operating system

GNU / Linux

Details on version and operating system

ArchLinux linux-lts

Checked with the latest development build

  • I made a backup of my libraries before testing the latest development version.
  • I have tested the latest development version and the problem persists

Steps to reproduce the behaviour

1. Open the `preference
2. change any option
3. bug shows
4. 2021-08-21 18-13-16屏幕截图

See #8010 (comment)

Appendix

...

Log File ``` Paste an excerpt of your log file here ```
@starsareintherose starsareintherose changed the title W File > External file link > Main file directory : Directory not found Aug 21, 2021
@Siedlerchr
Copy link
Member

As the error mesage says you need to check the main file directory in the preferences. It has to be a valid absolute path

@starsareintherose
Copy link
Author

I solved it by export my reference and set the reference as default and then put the old reference into it. It works, that's so strange.

@kvnptl
Copy link

kvnptl commented Dec 29, 2022

Facing the same issue on version 5.8. I tried uninstalling and installing it, but nothing worked.

In Preference -> File, there is no option to set the Main file directory.
image

@Siedlerchr could you please mention where to set the main file directory in the preference?

@Siedlerchr
Copy link
Member

@kvnptl Hi, the setting for the main file directory is now under Linked Files
grafik

@kvnptl
Copy link

kvnptl commented Dec 29, 2022

Thanks. It was pointing to snap/jabref/2209/Documents, which was not there. Now, I changed it, and the error message is gone.

@HoussemNasri HoussemNasri reopened this Feb 17, 2023
@HoussemNasri
Copy link
Member

I think this should stay open, the error message is misleading.

@HoussemNasri HoussemNasri added os: linux bug Confirmed bugs or reports that are very likely to be bugs and removed bug Confirmed bugs or reports that are very likely to be bugs labels Feb 17, 2023
@HoussemNasri HoussemNasri self-assigned this Feb 18, 2023
@Siedlerchr
Copy link
Member

It seems like the issue here is that the native default fallback directory is invalid inside a snap

@HoussemNasri
Copy link
Member

This is the path I got by default "/home/houssem/snap/jabref/2265/Documents". The problem here is that "Documents" folder doesn't exist under "2265".

Environnement

snap 2.58.2
snapd 2.58.2
series 16
ubuntu 22.04
kernel 5.15.0-52-generic

@Siedlerchr
Copy link
Member

Yes, this is correct. The home dir is set via this property.

https://github.com/JabRef/jabref/blob/98c9cbb85bfb2714d767769a7707f46f906f16ac/snap/snapcraft.yaml#LL54C37-L54C37

And the directory is coming from here:

public Path getDefaultFileChooserDirectory() {

So I think we need to check if the path contains "snap" and then either create the subdirectory (don't know if possible) or just return "home" or set it to another env var: https://snapcraft.io/docs/environment-variables

Can you attach files outside the snap directory?

@HoussemNasri
Copy link
Member

image

@dermalikmann
Copy link

I just skimmed over this issue, and I believe that there is another issue in regards to this error.

I believe that there is an issue in regards to non-english XDG directories. On my machine the default "Documents" folder is called ~/Dokumente, but JabRef defaults to ~/Documents, which in fact does not exist.

I won't exclude the possibility of my setup being broken, but to me it seems like JabRef does not honor XDG Directories?

I am using Jabref 5.9.

@koppor
Copy link
Member

koppor commented May 2, 2023

It is because, we hard-coded "Documents" at Linux.java

System.getProperty("user.home") + "/Documents")

This code was introduced in #9222.

Does your XDG environment have the environement variable XDG_DOCUMENTS_DIR set?

I tried to craft a fix at #9835

Can you try the portable edition from https://github.com/JabRef/jabref/actions/runs/4866174963?

(I could not upload it to builds.jabref.org - hope the link above works)

@koppor koppor reopened this May 2, 2023
@HoussemNasri HoussemNasri changed the title File > External file link > Main file directory : Directory not found Refer to the Documents directory by its Environnement variable e.g., XDG_DOCUMENTS_DIR instead of hardcoding it May 3, 2023
@HoussemNasri HoussemNasri removed their assignment May 3, 2023
@HoussemNasri HoussemNasri changed the title Refer to the Documents directory by its Environnement variable e.g., XDG_DOCUMENTS_DIR instead of hardcoding it Refer to the Documents directory by Environnement variable e.g., XDG_DOCUMENTS_DIR instead of hardcoding it May 3, 2023
@calixtus
Copy link
Member

calixtus commented May 3, 2023

Thanks @dermalikmann for your issue report. I use arch linux on my laptop too and i was able to reproduce the problem. This was in my case the same issue #8010 (comment) had. Would you be so kind to check three things to triangulate the issue a bit better:
a) Have you installed jabref via snap?
b) whats the content of ~/.config/user-dirs-dirs
c) What does the setting in preferences/linked files/main file directory show if you run the portable version of vanilla jabref 5.9 https://www.fosshub.com/JabRef.html?dwl=JabRef-5.9-portable_linux.tar.gz and also on the version you have installed after resetting the preferences, cancelling out of the prefs dialog an restarting jabref?
Thanks!

@calixtus
Copy link
Member

calixtus commented May 3, 2023

It is because, we hard-coded "Documents" at Linux.java

System.getProperty("user.home") + "/Documents")

The hardcoded variant is just the fallback option, if no XDG_DOCUMENTS_DIR can be found.

return Path.of(Objects.requireNonNullElse(
                System.getenv("XDG_DOCUMENTS_DIR"),
                System.getProperty("user.home") + "/Documents")
        );

So this could be a bigger problem with resolving enviroment variables.
Maybe we can introduce some test cases?

@Siedlerchr
Copy link
Member

We need to be aware that in snaps this can look different or at least the vars are mapped to internal dirs
https://snapcraft.io/docs/environment-variables

@dermalikmann
Copy link

dermalikmann commented May 3, 2023

Sorry for the delayed response

@calixtus
a) no, i use the AUR version (source, not -bin)
b) my ~/.config/user-dirs.dir is fine, i already checked it. there might be something else tho, see blow
c) see even further below

in regards to the ENV:

$ env |grep XDG | cut -d'=' -f1
XDG_SESSION_TYPE
XDG_RUNTIME_DIR
XDG_DATA_DIRS
XDG_SESSION_DESKTOP
XDG_CURRENT_DESKTOP
XDG_SESSION_CLASS
XDG_MENU_PREFIX

it seems that the user-dirs dont get sourced by my default env. AFAIK, this usually should happen through /etc/profile(.d/), but it seems that it in fact does not. @calixtus if you are running arch too, could you check if you have any script in there that access the user dirs conf?
Also anyone else, that is not running arch or an derivate of arch, could you check for something the likes too?

\

@koppor I have problems clean up my JabRef configuration 🤔 I deleted ~/.local/share/JabRef and ~/.local/share/jabref, bun when i run the portable version, it still loads my configuration. Am i missing something?

@koppor
Copy link
Member

koppor commented May 3, 2023

@HoussemNasri I think, the title changed wrong to "Refer to the Documents directory by Environnement variable e.g., XDG_DOCUMENTS_DIR instead of hardcoding it", because this is the way it is currently implemented:

System.getenv("XDG_DOCUMENTS_DIR"),

See also #9835 (comment) 😅

The issue is that this variable is sometimes empty. We are investigating why this could be the case.

Moreover, we should check on non-English macOS if everything works. Not sure if we will manage that...

@calixtus
Copy link
Member

calixtus commented May 3, 2023

Checked /etc/profile.d but did not find something.
This guide here https://wiki.archlinux.org/title/XDG_user_directories suggests that xdg-user-dirs-update.service may be a systemd service?

The preferences are usually stored here: ~/.java/.userPrefs/org/jabref. So for a 'fresh' install you need to remove that directory.

@HoussemNasri
Copy link
Member

@koppor Hmm I see, feel free to change it to something more precise.

@koppor koppor changed the title Refer to the Documents directory by Environnement variable e.g., XDG_DOCUMENTS_DIR instead of hardcoding it Respect localization for main directory (e.g., ~/Dokkumente) May 3, 2023
@calixtus
Copy link
Member

calixtus commented May 3, 2023

Interestingly, the XDG_DOCUMENTS_DIR does also not show up when i look it up in my env vars, only by calling xdg-user-dir DOCUMENTS

@calixtus
Copy link
Member

calixtus commented May 3, 2023

The longer I think about it, I realize calling calling xdg-user-dir is the way it's meant to be, because the basedir specification from freedesktop.org does not mention XDG_DOCUMENT_DIR (https://specifications.freedesktop.org/basedir-spec/latest/), but only the manual on the tool xdg-user-dir does (https://freedesktop.org/wiki/Software/xdg-user-dirs/). Good news is, every modern desktop environment should have xdg-user-dir installed on default.

Silly us for looking in the system environment vars for that XDG_DOCUMENT_DIR...

@dermalikmann
Copy link

@koppor I have problems clean up my JabRef configuration thinking I deleted ~/.local/share/JabRef and ~/.local/share/jabref, bun when i run the portable version, it still loads my configuration. Am i missing something?

Thx for the info with ~/.java/.userPrefs
I tired it, and now it defaults to my Home /home/$USER

@koppor
Copy link
Member

koppor commented May 10, 2023

@dermalikmann Please try the build at https://builds.jabref.org/pull/9837/merge/. JabRef should also display the path at "Help -> View Event Log"

@dermalikmann
Copy link

@koppor please see my comment in #9837

if that gets fixed, i think this issue can be closed

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