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

problem locating wolfram installation on Linux #27

Closed
strelda opened this issue Dec 10, 2022 · 6 comments
Closed

problem locating wolfram installation on Linux #27

strelda opened this issue Dec 10, 2022 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@strelda
Copy link

strelda commented Dec 10, 2022

Hi,
the program has trouble locating Wolfram Language installation on Linux. Locating Wolfram application using wolfram_app_discovery::WolframApp leads to an error

thread 'main' panicked at 'unable to locate any Wolfram applications: Error(UnsupportedPlatform { operation: "WolframApp::from_installation_directory()" })' 

According to the section Configuration it should be sufficient to add the correct path to .bashrc, such as
export WOLFRAM_APP_DIRECTORY="/usr/local/Wolfram/Mathematica/13.0/Executables/"
this also leads to the error above.

  • Installing wolframscript does not fix the problem,
  • using Arch Linux, Mathematica 13.0, rustc 1.65.0, wolfram-app-discovery = "0.3.0"

For more details, the result from RUST_BACKTRACE=1:

thread 'main' panicked at 'unable to locate any Wolfram applications: Error(UnsupportedPlatform { operation: "WolframApp::from_app_directory()" })', src/main.rs:8:6
stack backtrace:
   0: rust_begin_unwind
             at /rustc/1.65.0/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/1.65.0/library/core/src/panicking.rs:142:14
   2: core::result::unwrap_failed
             at /rustc/1.65.0/library/core/src/result.rs:1785:5
   3: core::result::Result<T,E>::expect
             at /rustc/1.65.0/library/core/src/result.rs:1064:23
   4: tutorial::main
             at ./src/main.rs:7:15
   5: core::ops::function::FnOnce::call_once
             at /rustc/1.65.0/library/core/src/ops/function.rs:248:5
          

Thanks for any advice on fixing this issue.

@ConnorGray
Copy link
Collaborator

Hi @strelda, thanks for filing this high quality issue!

There are a few inherent complications with app discovery on Linux that make it somewhat trickier than on macOS and Windows, but it should in principle be possible for this to work when you've supplied an explicit WOLFRAM_APP_DIRECTORY value.

I'll begin working on a fix, and update this issue once I've finished.

@ConnorGray ConnorGray self-assigned this Dec 13, 2022
@ConnorGray ConnorGray added the bug Something isn't working label Dec 13, 2022
@ConnorGray
Copy link
Collaborator

ConnorGray commented Dec 15, 2022

Hi @strelda, I've just published v0.4.0 of wolfram-app-discovery, which adds support for Linux.

Edit: You can update to the latest version by executing:

$ cargo update -p wolfram-app-discovery

I'll note that the WOLFRAM_APP_DIRECTORY value you set in your issue description is not quite correct; it should point at the root directory of the application, not the Executables/ subdirectory. The correct value is:

WOLFRAM_APP_DIRECTORY="/usr/local/Wolfram/Mathematica/13.0/"

Please try it out and let me know if it works, so I'll know if I can mark this issue as resolved. Thanks!

@strelda
Copy link
Author

strelda commented Dec 15, 2022

Thanks for your help, indeed you are right. Running export WOLFRAM_APP_DIRECTORY="/usr/local/Wolfram/Mathematica/" fixes the error. But then the code can't find LICENSE.txt, leading to an error

thread 'main' panicked at 'unable to locate any Wolfram applications: Error(UnexpectedLayout { resource_name: "LICENSE.txt file", path: "/usr/local/Wolfram/Mathematica/LICENSE.txt" })'

Essentially there are two problems with the function in src/os/linux.rs, as you call it a "very hacky way of getting information about an app on Linux" :) it is indeed a good idea but seems to break when either user has more Mathematica licenses or it is a Student license*. I might try to add rules which will fix my problem, but instead, it might be better to add an option to set this path manually (this might be just a workaround for specific use cases, of course, the meaning of the code is to find it).

*In my case there is no LICENSE.txt, and the version folder /13.0/ is ignored in the code, so it searches the executable as /usr/local/Wolfram/Mathematica/Executables/WolframKernel, instead of /usr/local/Wolfram/Mathematica/13.0/Executables/WolframKernel.

@ConnorGray
Copy link
Collaborator

Hi @strelda, I think there may be a conceptual confusion or miscommunication here regarding what we each think the "application directory" is; I'll offer my understanding, and let me know if that helps.

My understanding is that:

  • /usr/local/Wolfram/Mathematica/ is NOT an application directory; it is an arbitrary directory that happens to contain different unrelated copies of the Mathematica application.

  • /usr/local/Wolfram/Mathematica/13.0/ is an application directory.

    • (And there are also alternative application directories as well: /usr/local/Wolfram/Mathematica/13.1/ would potentially also be another valid value for WOLFRAM_APP_DIRECTORY if you have Mathematica v13.1 installed.)

Based on that understanding, I would set WOLFRAM_APP_DIRECTORY to the specific version of Mathematica that I want to use:

WOLFRAM_APP_DIRECTORY="/usr/local/Wolfram/Mathematica/13.0/"

Setting WOLFRAM_APP_DIRECTORY equal to /usr/local/Wolfram/Mathematica/ as you mention is therefore an invalid value. The /13.0/ component is required to fully specify the application you want to use.

Therefore, I'd expect that 'UnexpectedLayout' error shown in your previous comment to go away if you were to set:

WOLFRAM_APP_DIRECTORY="/usr/local/Wolfram/Mathematica/13.0/"

Does app discovery succeed if you set the value above?

@strelda
Copy link
Author

strelda commented Dec 15, 2022

Ok, sure. Sorry for the misunderstanding, and thanks for the quick help.

@ConnorGray
Copy link
Collaborator

No worries, and you're welcome! Thanks again for the issue and feedback :)

It sounds like this is working for you now? So I'll presume that this issue is resolved, but feel free to re-open or file another issue if you run into any more problems.

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

2 participants