alda-lang / alda

A music programming language for musicians. :notes:
https://alda.io
Eclipse Public License 2.0
5.62k stars 289 forks source link

`exec java` resolving to the wrong path #487

Closed alpineyahoo closed 1 year ago

alpineyahoo commented 1 year ago

🐞 Bug report 🐞

Alda doesn't work properly.

Description

I installed alda from homebrew and tried to play an example code on alda official webpage, but failed.

Steps to Reproduce

  1. I installed/updated alda from homebrew.
  2. alda and alda-player executables are in /usr/local/bin directory as expected.
  3. I ran alda play -c "(tempo! 160) trumpet: (quant 60) f12 b- > d f6 d12 f1" and the output is below:
    
    Starting player processes...
    Aug 29 16:23:07 WRN alda.io/client/cmd/root.go:80 > Failed to fill player pool. error="exit status 126"
    It looks like Alda is having trouble starting player processes in the
    background. This could happen for a number of reasons.

To troubleshoot:

• Run alda doctor and see if any of the health checks fail.

• Run alda ps to see the state of any currently running player processes.

• Look for error messages in: /Users/***/Library/Caches/alda/logs/alda-player.log

• Try running a player process in the foreground: alda-player -v run -p 27278

• Try to make it play something: alda -v2 play -p 27278 -c "piano: c12 e g > c4"

4. I also ran `alda doctor` and `alda ps`. The outputs are below:

$ alda doctor OK Parse source code OK Generate score model OK Ensure that there are no stale player processes OK Find an open port OK Send and receive OSC messages ERR Locate alda-player executable on PATH


Oops! Something went wrong: exit status 126

This might be a bug. For help, consider filing an issue at: https://github.com/alda-lang/alda/issues/new/choose

Or come chat with us on Slack: https://slack.alda.io

$ alda ps id port state expiry type

5. `alda-player.log` doesn't exist at this time.

<!--- Does the problem happen consistently? -->

<!--- Is there an example score that demonstrates the problem? -->

<!--- Is there anything else that it would be useful for us to know? -->

## Expected Behavior
<!--- Tell us what you think should happen when you follow the steps above -->

## Actual Behavior
<!--- Tell us what happens instead -->

## Environment
<!--- Please provide the following information so that we can better assist you -->

<!--- Are you running Windows, macOS, Linux? What distribution/version? -->
**Operating system and version:**
I am using macOS.

$ sw_vers ProductName: macOS ProductVersion: 14.0 BuildVersion: 23A5286i


**Alda version:**
<!--- Run `alda version` in your terminal and copy-paste the output below -->

$ alda version alda 2.2.6 Aug 29 16:54:32 WRN alda.io/client/cmd/root.go:80 > Failed to fill player pool. error="exit status 126"


<!--- Run `alda-player info` in your terminal and copy-paste the output below -->

$ alda-player info /usr/local/bin/alda-player: line 3: /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home/bin/java: No such file or directory /usr/local/bin/alda-player: line 3: exec: /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home/bin/java: cannot execute: No such file or directory


**Health check:**
<!--- Run `alda doctor` in your terminal and copy-paste the output below -->

$ alda doctor


**Logs:**
<!--- On macOS and Linux, you can find Alda's logs in either -->
<!---   ~/.cache/alda (Linux), or -->
<!---   ~/Library/Caches/alda (macOS), or -->
<!---   $XDG_CACHE_HOME (if you have that set) -->
I couldn't find any logs.

<!--- On Windows, look in: -->
<!---   %LOCALAPPDATA%\alda\cache or -->
<!---   C:\Users\yourname\AppData\Local\alda\cache -->

<!--- Do you see any logs that might be relevant to the problem? -->
<!--- If so, copy-paste what you found below -->
alpineyahoo commented 1 year ago

java -version output here:

openjdk version "20.0.2" 2023-07-18
OpenJDK Runtime Environment Temurin-20.0.2+9 (build 20.0.2+9)
OpenJDK 64-Bit Server VM Temurin-20.0.2+9 (build 20.0.2+9, mixed mode, sharing)

I have temurin installed. (I mean, I did brew install temurin.)

daveyarwood commented 1 year ago

Hi!

I double-checked the build script for alda-player, and it's literally putting exec java into the executable. I think the issue that you're running into is that exec is choosing the wrong location for the java executable. It's attempting to find it in a Java 17 specific path, which you appear not to have on your system.

You do have Java 20 installed, so I think what you need to do to resolve this is figure out how to get exec to resolve java to the correct path where your Java 20 java executable is located.

I'm not a Mac user, so I'm not really sure what the best recommended way of doing that is on a Mac. I did find a couple of StackOverflow discussions that might be helpful:

I saw some people recommending jenv, and I can vouch for that approach. I've been using jenv for a long time to manage having multiple versions of Java installed, and it's always worked well for me.

daveyarwood commented 1 year ago

This simple approach looks promising too.

alpineyahoo commented 1 year ago

Thanks, @daveyarwood. I'll take a look at java version managers to solve this. I'll close this issue.