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

A trick to bypass julia #14577? #42

Closed
Non-Contradiction opened this issue Apr 2, 2018 · 1 comment
Closed

A trick to bypass julia #14577? #42

Non-Contradiction opened this issue Apr 2, 2018 · 1 comment

Comments

@Non-Contradiction
Copy link
Collaborator

Because of julia issue #14577,
non-precompiled packages cannot be imported in embedding julia v0.6,
so currently using XXX in JuliaCall doesn't work if package XXX is non-precompiled.
This problem results in many other problems, related to #10 #34 #40 for example.

This problem exists because of the incorrect JULIA_HOME for embedding julia.
I read the source of julia, and find that functions like Base.compilecache depends on function julia_cmd, and inspired by Revise.jl, we can actually use @eval Base julia_cmd() = ..... to modify this function to be the correct version to "solve" this problem in a tricky way, for example:

> julia_command('Base.compilecache("Suppressor")')
INFO: Precompiling module Suppressor.
Error happens in Julia.
could not spawn `/Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia -Ccore2 -J/Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/sys.dylib --compile=yes --depwarn=yes -O0 --output-ji /Users/lichangcheng/.julia/lib/v0.6/Suppressor.ji --output-incremental=yes --startup-file=no --history-file=no --color=no --eval 'while !eof(STDIN)
    eval(Main, deserialize(STDIN))
end
'`: permission denied (EACCES)
Stacktrace:
 [1] _jl_spawn(::String, ::Array{String,1}, ::Ptr{Void}, ::Base.Process, ::Base.PipeEndpoint, ::Ptr{Void}, ::Ptr{Void}) at ./process.jl:360
 [2] #374 at ./process.jl:512 [inlined]
 [3] setup_stdio(::Base.##374#375{Cmd}, ::Tuple{Pipe,Base.PipeEndpoint,Base.PipeEndpoint}) at ./process.jl:499
 [4] #spawn#373(::Nullable{Base.ProcessChain}, ::Function, ::Cmd, ::Tuple{Pipe,Base.PipeEndpoint,Base.PipeEndpoint}) at ./process.jl:511
 [5] (::Base.#kw##spawn)(::Array{Any,1}, ::Base.#spawn, ::Cmd, ::Tuple{Pipe,Base.PipeEndpoint,Base.Pip
> julia_command('Base.julia_cmd()')
`/Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia -Ccore2 -J/Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/sys.dylib --compile=yes --depwarn=yes`
  
> julia_command('@eval Base julia_cmd() = `/Applications/Julia-0.6.app/Contents/Resources/julia/bin/julia -Ccore2 -J/Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/sys.dylib --compile=yes --depwarn=yes`')
WARNING: Method definition julia_cmd() in module Base at util.jl:604 overwritten at none:1.
julia_cmd (generic function with 2 methods)
  
> julia_command('Base.compilecache("Suppressor")')
INFO: Precompiling module Suppressor.
"/Users/lichangcheng/.julia/lib/v0.6/Suppressor.ji"

I'm wondering if this kind of method worths the trouble it may bring.
Any opinion is welcomed.

Non-Contradiction added a commit that referenced this issue Apr 3, 2018
@Non-Contradiction Non-Contradiction changed the title A dirty trick to bypass julia #14577? A trick to bypass julia #14577? Apr 3, 2018
Non-Contradiction added a commit that referenced this issue Apr 3, 2018
@Non-Contradiction
Copy link
Collaborator Author

After consideration and testing, I think the approach is okay, because it just does what should be done, and it is really useful. Commit 3167c5a implements the approach.

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

No branches or pull requests

1 participant