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

Lazy macro loading seems to be breaking on Julia v1.9.0-rc1 #11

Closed
singularitti opened this issue Mar 18, 2023 · 7 comments · Fixed by #12
Closed

Lazy macro loading seems to be breaking on Julia v1.9.0-rc1 #11

singularitti opened this issue Mar 18, 2023 · 7 comments · Fixed by #12

Comments

@singularitti
Copy link
Contributor

I am trying this in my startup.jl:

@lazy_startup using Unitful @u_str

But it does not seem to be loaded on Julia v1.9+.

Julia Version 1.9.0-rc1
Commit 3b2e0d8fbc1 (2023-03-07 07:51 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.4.0)
  CPU: 10 × Apple M1 Pro
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, apple-m1)
  Threads: 1 on 8 virtual cores
@wangl-cc
Copy link
Owner

Hey, I can't reproduce it.

julia> versioninfo()
Julia Version 1.9.0-rc1
Commit 3b2e0d8fbc1 (2023-03-07 07:51 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin21.4.0)
  CPU: 8 × Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, apple-m1)
  Threads: 1 on 4 virtual cores

julia> isdefined(Main, :Unitful)
false

julia> u"m"
m

julia> isdefined(Main, :Unitful)
true

@singularitti
Copy link
Contributor Author

OK, it seems to be happening since I have the following lines in my startup.jl:

using REPL
atreplinit() do repl
    if !isdefined(repl, :interface)
        repl.interface = REPL.setup_interface(repl)
    end
    REPL.ipython_mode!(repl)
end

This is the IPython mode that v1.9 introduced (see JuliaLang/julia#46474). It may change the environment in REPL. I tried to put these lines before using LazyStartup: @lazy_startup, but no effect.

@singularitti
Copy link
Contributor Author

I have met a similar issue before, maybe this link will help: KristofferC/OhMyREPL.jl#279

@wangl-cc
Copy link
Owner

Thanks, I will look into it later.

@wangl-cc
Copy link
Owner

I believe that the reason for the issue is due to the ipython_mode which breaks the ability to load a package and using macros provided by that package in a single input line in the REPL. See JuliaLang/julia#49041.

@wangl-cc
Copy link
Owner

Please try 0.2.0 with

atreplinit() do repl
    if !isdefined(repl, :interface)
        repl.interface = REPL.setup_interface(repl)
    end
    REPL.ipython_mode!(repl)
    lazy_startup_init!()
end

Note, the lazy_startup_init! must be after the REPL.ipython_mode!.

@singularitti
Copy link
Contributor Author

It works for me, thank you!

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