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

? directory in Ubuntu 20.04.6 LTS with static build #75

Open
nabato opened this issue Oct 20, 2023 · 17 comments
Open

? directory in Ubuntu 20.04.6 LTS with static build #75

nabato opened this issue Oct 20, 2023 · 17 comments
Labels
bug Something isn't working

Comments

@nabato
Copy link

nabato commented Oct 20, 2023

bbin 0.2.0 creates a directory with a singe letter name ? with subdirectories .clojure, .deps.clj, .gitlibs, .local and installs bbins in there, which makes bbin and installed bbins unusable. The path to an installed bbin looks like $HOME/?/.local/bin/installed-bbin-name.

Calling (System/getProperty "user.home") returns correct name not a ?.

Installing bbin by means of brew or as a standalone executbale makes no difference.

P.S. Appreciate all of your work.

@nabato nabato changed the title ? as user-home on Ubuntu 20.04.6 LTS ? directory on Ubuntu 20.04.6 LTS Oct 20, 2023
@borkdude
Copy link
Contributor

borkdude commented Oct 20, 2023

What is the value of your XDG_*_HOME environment variables, if you have them set?

@nabato
Copy link
Author

nabato commented Oct 20, 2023

XDG_HOME

I don't have one.

@borkdude
Copy link
Contributor

I edited the question, list any environment variable starting with XDG

@nabato
Copy link
Author

nabato commented Oct 20, 2023

I edited the question, list any environment variable starting with XDG

printenv | grep xdg:

XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg

@borkdude
Copy link
Contributor

I don't see any mention of XDG_CONFIG_DIRS in the code. According to the spec they should be used (in order) in addition to XDG_CONFIG_HOME.
Still I'd be curious where the ? comes from.

cc @rads

@nabato nabato changed the title ? directory on Ubuntu 20.04.6 LTS ? directory in Ubuntu 20.04.6 LTS Oct 20, 2023
@akutschera
Copy link

I have a system with the same behaviour.
On this system the output of bb -e '(print (System/getProperty "user.home"))' returns ? Trying the same in a clj repl prints my home directory so I assume it's happening here (in fact, if I change that code to set the property to the desired directory, bbin works as expected).
I found a JDK bug that seems to suggest that there is an issue on systems with LDAP authentication, even though on the system where I re-create the behaviour there are only 64-bit libs installed (and I use LDAP authentication there).

@borkdude
Copy link
Contributor

Perhaps this is an issue with GraalVM?

You can repro this as follows:

Repro.java:

public class Repro {
    public static void main(String [] args) {
        System.out.println(System.getProperty("user.dir"));
    }
}
javac Repro.java
java Repro # test if it works
$GRAALVM_HOME/bin/native-image Repro --no-fallback
./repro # test if it works in native-image

@borkdude
Copy link
Contributor

If it turns out to be a GraalVM issue, please file an issue on their Github.

@akutschera
Copy link

I guess it is not a GraalVM issue. I tried the program with "user.dir" and "user.home". Both are displayed.
I tried it with a GraalVM JDK 21 and JDK 17.
I compiled the program with Java 17 and Java 8 (sic!).
Everytime my home directory was printed.

@borkdude
Copy link
Contributor

@akutschera Did you try it inside of a native-image rather than just a JDK? This wasn't clear from your answer.

@akutschera
Copy link

Sorry for the misunderstanding. I tried to follow your suggestions. Here's what I did:
I created a file Repro.java like you suggested. I added the following line System.out.println(System.getProperty("user.home"));
I compiled the file with both JDK8 and JDK17
For each class file I created a GraalVM native image with both a GraalVM 17 and 21 with
$GRAALVM_HOME/bin/native-image Repro --no-fallback
So I ended up with 2 class files and 4 native images.
Each printed out my current and my home directory as expected.

@borkdude
Copy link
Contributor

Which GraalVM did you use, the CE version or Oracle GraalVM?

@borkdude
Copy link
Contributor

I have another repro for you which is closer to how bb (SCI) works:

public class Repro {
    public static void main(String [] args) throws NoSuchMethodException, IllegalAccessException, java.lang.reflect.InvocationTargetException {
        var clazz = System.class;
        var meth = clazz.getMethod("getProperty", String.class);
        System.out.println(meth.invoke(clazz, "user.dir"));
    }
}

Can you also try that one?

@akutschera
Copy link

I downloaded the GraalVMs from https://www.graalvm.org/downloads I downloaded both the Java 17 and the Java 21 version.
I will have to try the new Repro later.

@akutschera
Copy link

Now, that's a bit embarassing. I found a solution/workaround for this.
All I tried all the time was the static build of babashka.
If I use the non-static build, everything is fine. That one can talk to sssd and get the home directory from the LDAP server.

@borkdude borkdude changed the title ? directory in Ubuntu 20.04.6 LTS ? directory in Ubuntu 20.04.6 LTS with static build Feb 19, 2024
@borkdude
Copy link
Contributor

Btw, my repro above contains a mistake and should have user.home, not user.dir.

@borkdude
Copy link
Contributor

I just tried the above on a Linux x64 Ubuntu 20.04 in WSL and both the static version and non-static version return the right value for user.home for me.
I also tried it in a Docker image:

FROM ubuntu:20.04

RUN apt-get update && apt-get install curl -y
RUN curl -sLO https://raw.githubusercontent.com/babashka/babashka/master/install
RUN chmod +x install
RUN ./install --dir /tmp
RUN /tmp/bb -e "(System/getProperty \"user.home\")"
 /tmp/bb -e '(System/getProperty "user.home")'
"/root"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants