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

startup.jl bug? #9

Open
AlexisRenchon opened this issue Mar 14, 2023 · 5 comments
Open

startup.jl bug? #9

AlexisRenchon opened this issue Mar 14, 2023 · 5 comments

Comments

@AlexisRenchon
Copy link

having
using ReplGPT
in my startup.jl file does not work (typing } in the REPL doesn't go into ChatGPT mode)
also, if I explicitly type using ReplGPT, it still won't work if it was in startup.jl

julia> }
ERROR: syntax: unexpected "}"
Stacktrace:
 [1] top-level scope
   @ none:1

julia> using ReplGPT

julia> }
ERROR: syntax: unexpected "}"
Stacktrace:
 [1] top-level scope
   @ none:1

It all works well if NOT in startup.jl though.

julia> using ReplGPT
┌ Warning: REPL key '}' overwritten.
└ @ ReplMaker ~/.julia/packages/ReplMaker/ViCwA/src/ReplMaker.jl:96
REPL mode ChatGPT_mode initialized. Press } to enter and backspace to exit.

julia>

ChatGPT>
@ThatcherC
Copy link
Owner

ThatcherC commented Mar 14, 2023

Interesting! It looks like this has to do with how startup.jl works. The ReplMaker.jl README had some helpful tips and I've implemented them in #10. Seems to work! Want to try out that branch and see if it works for you too?

The quick test would:

pkg> add https://github.com/ThatcherC/ReplGPT.jl.git#work-in-startup-jl

Then quit Julia, start it a few times with and without startup.jl, see if it works.

And then pkg> free ReplGPT to return to the main package version.

If that works well for you I'll merge it and tag a new release!

@AlexisRenchon
Copy link
Author

Does it work for you?
It didn't for me:

   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.9.0-rc1 (2023-03-07)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

REPL mode ChatGPT_mode initialized. Press } to enter and backspace to exit.
(@v1.9) pkg> status
Status `~/.julia/environments/v1.9/Project.toml`
  [5fb14364] OhMyREPL v0.5.18
  [8ef5fce9] ReplGPT v0.2.0 `https://github.com/ThatcherC/ReplGPT.jl.git#work-in-startup-jl`
  [295af30f] Revise v3.5.1

julia> }
ERROR: syntax: unexpected "}"
Stacktrace:
 [1] top-level scope
   @ none:1

@ThatcherC
Copy link
Owner

Huh, weird. It does work for me, both on 1.8 and 1.9:

thatch@bend:~$ ~/Programs/julia-1.9.0-rc1/bin/julia 
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.9.0-rc1 (2023-03-07)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

┌ Warning: OpenAI API key not found! Please set with `ReplGPT.setAPIkey("<YOUR OPENAI API KEY>")` or set the environment variable OPENAI_API_KEY=<YOUR OPENAI API KEY>
└ @ ReplGPT ~/.julia/packages/ReplGPT/UQVnT/src/ReplGPT.jl:97
REPL mode ChatGPT_mode initialized. Press } to enter and backspace to exit.
(@v1.9) pkg> status
Status `~/.julia/environments/v1.9/Project.toml`
  [8ef5fce9] ReplGPT v0.2.0 `https://github.com/ThatcherC/ReplGPT.jl.git#work-in-startup-jl`

(@v1.9) pkg> 

julia> 
# ^ here I type '}' and drop into the ChatGPT shell
ChatGPT> 

I wonder if the conflict is with OhMyREPL. (Turns out it is!)


When have using OhMyREPL; using ReplGPT in my startup.jl, I get the same error you're seeing - the } just doesn't work:

thatch@bend:~$ ~/Programs/julia-1.9.0-rc1/bin/julia 
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.9.0-rc1 (2023-03-07)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

┌ Warning: OpenAI API key not found! Please set with `ReplGPT.setAPIkey("<YOUR OPENAI API KEY>")` or set the environment variable OPENAI_API_KEY=<YOUR OPENAI API KEY>
└ @ ReplGPT ~/.julia/packages/ReplGPT/UQVnT/src/ReplGPT.jl:97
REPL mode ChatGPT_mode initialized. Press } to enter and backspace to exit.
julia> }               # fails to enter ChatGPT shell]

However, when I have using ReplGPT; using OhMyREPL, I get a note from ReplMaker saying that the } key has been overwritten:

thatch@bend:~$ nano ~/.julia/config/startup.jl   # "using OhMyREPL; using ReplGPT"
thatch@bend:~$ ~/Programs/julia-1.9.0-rc1/bin/julia 
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.9.0-rc1 (2023-03-07)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

┌ Warning: OpenAI API key not found! Please set with `ReplGPT.setAPIkey("<YOUR OPENAI API KEY>")` or set the environment variable OPENAI_API_KEY=<YOUR OPENAI API KEY>
└ @ ReplGPT ~/.julia/packages/ReplGPT/UQVnT/src/ReplGPT.jl:97
┌ Warning: REPL key '}' overwritten.
└ @ ReplMaker ~/.julia/packages/ReplMaker/ViCwA/src/ReplMaker.jl:96
REPL mode ChatGPT_mode initialized. Press } to enter and backspace to exit.
julia> 

So there's some kind of conflict there. I'll check it out! It might have something to do with this atreplinit tip mentioned on the OhMyREPL docs.

@svilupp
Copy link

svilupp commented Mar 19, 2023

Perhaps this might help... I tend to add a small delay for secondary packages to be activated only once other packages have done their bit.

startup.jl

# this isn't necessary, I use it to get rid of the logs during initialization
using Suppressor

Base.atreplinit() do repl
    @eval begin
        # other stuff
        
        #ReplGPT
        @async begin
            sleep(1)
            @suppress @eval using ReplGPT
            @suppress ReplGPT.init_repl()
        end
    end
end

@AlexisRenchon
Copy link
Author

sorry neither of your solution work for me

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

3 participants