rcst / rim

rim provides an interface to Maxima for R. Maxima is a powerful and fairly complete computer algebra system.
10 stars 3 forks source link

"Could not find Maxima executable" on MacOS #30

Closed sebastian-gerdes closed 1 year ago

sebastian-gerdes commented 1 year ago

Dear all,

I would really like to use the rim package, however, I can't get it to work.

I have installed maxima 5.43.0 on my computer (macOS 12.6.2, M1 Pro) and have added the following line to the file ~/.zshrc:

export PATH=${PATH}:/Applications/Maxima.app/Contents/Resources/opt/bin

I can open maxima in the terminal with the command maxima, however, the rim package seems to not find the executable, printing the message "Could not find Maxima executable" on attaching.

Does anyone know how I can get it to work? Any help would be greatly appreciated, thanks a lot!

Best greetings, Sebastian

rcst commented 1 year ago

Hi,what’s the response from running Sys.which(“maxima”) in your R session?Am 26.01.2023 um 11:09 schrieb Sebastian Gerdes @.***>: Dear all, I would really like to use the rim package, however, I can't get it to work. I have installed maxima 5.43.0 on my computer (macOS 12.6.2, M1 Pro) and have added the following line to the file ~/.zshrc: export PATH=${PATH}:/Applications/Maxima.app/Contents/Resources/opt/bin I can open maxima in the terminal with the command maxima, however, the rim package seems to not find the executable, printing the message "Could not find Maxima executable" on attaching. Does anyone know how I can get it to work? Any help would be greatly appreciated, thanks a lot! Best greetings, Sebastian

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

sebastian-gerdes commented 1 year ago

Dear rcst,

thanks for your question, it helped me to work out a solution (which is not optimal yet though). Here is what I found out:

In RStudio, Sys.which("maxima") gave me an empty string, since RStudio did not use the path variables as indicated in ~/.zshrc:.

When I started R from a zsh terminal, it did have the right path variable as set in ~/zshrc and I rim worked as desired, Sys.which("maxima") providing the correct path.

I wanted to make the maxima path available in the $PATH variable systemwide and used these instructions: https://www.bounga.org/tips/2020/04/07/instructs-mac-os-gui-apps-about-path-environment-variable/ However, it did not work.

How could make rim work from RStudio: I put a shell script called maxima into a folder that was in the search path of the RStudio $PATH variable

#!/bin/sh
/Applications/Maxima.app/Contents/Resources/opt/bin/maxima $1 $2 $3 $4 $5 $6 $7

and made it executable with sudo chmod +x maxima

Now it works, although not a very "clean" solution in my taste.

Would it be an option to provide a method to provide the path to maxima to rim?

Thanks and best greetings, Sebastian

rcst commented 1 year ago

Glad you figured it out. Yes, to provide a user-defined path should be simple. I’ll reference this issue in the respective commit. It’s a helpful suggestion, thank you!Am 26.01.2023 um 14:00 schrieb Sebastian Gerdes @.***>: Dear rcst, thanks for your question, it helped me to work out a solution (which is not optimal yet though). Here is what I found out: In RStudio, Sys.which("maxima") gave me an empty string, since RStudio did not use the path variables as indicated in ~/.zshrc:. When I started R from a zsh terminal, it did have the right path variable as set in ~/zshrc and I rim worked as desired, Sys.which("maxima") providing the correct path. I wanted to make the maxima path available in the $PATH variable systemwide and used these instructions: https://www.bounga.org/tips/2020/04/07/instructs-mac-os-gui-apps-about-path-environment-variable/ However, it did not work. How could make rim work from RStudio: I put a shell script called maxima into a folder that was in the search path of the RStudio $PATH variable

!/bin/sh

/Applications/Maxima.app/Contents/Resources/opt/bin/maxima $1 $2 $3 $4 $5 $6 $7

and made it executable with sudo chmod +x maxima Now it works, although not a very "clean" solution in my taste. Would it be an option to provide a method to provide the path to maxima to rim? Thanks and best greetings, Sebastian

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

sebastian-gerdes commented 1 year ago

Thanks a lot! Yeah, and it would be nice to have the possibility of a user-defined path some time in the future!

Best greetings, Sebastian

rcst commented 1 year ago

You can now set in your R session the environment variable RIM_MAXIMA_PATH, for instance

Sys.setenv("RIM_MAXIMA_PATH" = "/Applications/Maxima.app/Contents/Resources/opt/bin/maxima")

If you attach the package or run the knitr engine, rim first looks up whether this variable has been set (and whether it matches the pattern "maxima") and if so uses it. If no, rim searches the System via Sys.which("maxima") as before.

Let me know if this works for you.

sebastian-gerdes commented 1 year ago

This works, thanks a lot for the quick solution!