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

zsh:1: command not found: julia [Mac] #8

Closed
70Gage70 opened this issue May 10, 2023 · 2 comments
Closed

zsh:1: command not found: julia [Mac] #8

70Gage70 opened this issue May 10, 2023 · 2 comments

Comments

@70Gage70
Copy link

I put jcall.m into a folder, opened it, and ran

jlcall('sort', {rand(2,5)}, struct('dims', int64(2)))

Immediately, it returns zsh:1: command not found: julia. This is confusing since which julia in the terminal returns /opt/homebrew/bin/julia. This appears to be related to a general issue with MATLAB with respect to calling system commands.

What worked for me was replacing the function try_find_julia_runtime() with the following

function runtime = try_find_julia_runtime()
    setenv('PATH','/opt/homebrew/bin')
    runtime = 'julia';
end

Obviously that's not a very generic solution but I'm not really a MATLAB expert.

@jondeuce
Copy link
Owner

Unfortunately I don't have access to a Mac to test this out, but yes that seems rather inconvenient.

From the referenced link, it seems like you probably should be able to run the setenv command in the console, so you shouldn't have to modify try_find_julia_runtime(). Or perhaps more conveniently, add the following line to your startup.m file:

  • setenv('PATH', [getenv('PATH') ':/opt/homebrew/bin']);

Note that typically you want to append to the current PATH environment variable, not replace it entirely.

You also have the option to pass the Julia runtime path to jlcall explicitly:

  • jlcall('sort', {rand(2,5)}, struct('dims', int64(2)), 'runtime', '/opt/homebrew/bin/julia')

This will override try_find_julia_runtime(). I should add an example highlighting this flag in the README, since this flag was also useful in a previous issue.

@70Gage70
Copy link
Author

Thanks for the detailed response, modifying startup.m seems like the best solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants