https://github.com/thomasvitale/flox-java-issue
https://github.com/thomasvitale/flox-java-issue
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/thomasvitale/flox-java-issue
- Owner: ThomasVitale
- License: apache-2.0
- Created: 2025-08-07T14:15:09.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2025-08-07T14:48:03.000Z (about 2 months ago)
- Last Synced: 2025-08-07T16:28:02.111Z (about 2 months ago)
- Language: Nix
- Size: 12.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Flox Java Issue
_It's recommended to open this repository in a Devcontainers environment such as GitHub Codespaces or VS Code._
## Host
This Ubuntu environment defines a value for the `JAVA_HOME` environment variable. Let's verify that by running the following command:
```bash
echo $JAVA_HOME
```The result will be `/yolo`.
## Nix Flakes
Let's see what happens when we use Nix Flakes to define a Java development environment.
Navigate to the `graalvm-ce` directory:
```bash
cd graalvm-ce
```Then, activate the Nix development environment:
```bash
nix develop
```Now, print out the JAVA_HOME environment variable:
```bash
echo $JAVA_HOME
```It will correctly point to the Nix store path, such as `/nix/store/abc123-graalvm-ce-24.0.1`.
Exit the environment and go back to the root directory:
```bash
exit
cd ..
```Try printing the `JAVA_HOME` variable again:
```bash
echo $JAVA_HOME
```It will still print `/yolo`, which is the value defined in the current Ubuntu environment, not the Nix environment. This is expected behavior since the Nix Flakes environment does not modify the host's environment variables.
## Flox
Let's now see what happens when we use Flox instead of plain Nix Flakes.
First, install Flox following [these instructions](https://flox.dev/docs/install-flox/install/#__tabbed_1_3).
Next, navigate to the `flox` directory:
```bash
cd flox
```Then, activate the Nix development environment:
```bash
flox activate
```Print out the JAVA_HOME environment variable:
```bash
echo $JAVA_HOME
```It will print out `/yolo`, which is the value defined in the current Ubuntu environment, not the Nix environment. The Nix Java package usually configures the `JAVA_HOME` variable to point to the Nix store path, but in Flox that doesn't happen.
Exit the environment.
```bash
exit
```Now let's try unsetting the `JAVA_HOME` variable in the host environment:
```bash
unset JAVA_HOME
```Confirm it's empty:
```bash
echo $JAVA_HOME
```Activate the Flox environment again:
```bash
flox activate
```Print out the `JAVA_HOME` variable:
```bash
echo $JAVA_HOME
```The result is an empty string, proving that no matter if the `JAVA_HOME` variable is set or not in the host environment, Flox does not set it automatically, unlike Nix Flakes.