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

Definitions not available from repl.load.exec in home predef #658

Open
ches opened this issue Jul 8, 2017 · 1 comment
Open

Definitions not available from repl.load.exec in home predef #658

ches opened this issue Jul 8, 2017 · 1 comment

Comments

@ches
Copy link

ches commented Jul 8, 2017

I noticed the entry in the release notes of 1.0.0 (congrats on the release 🎉 ):

interp.load.exec and interp.load.apply have been moved to repl.load.exec and repl.load.apply, and are now not available when running scripts: they never had a really well-defined semantic when run within scripts. Using repl.load.exec or repl.load.apply within the predef.sc of your REPL is still possible

I updated my predef.sc accordingly and the file I exec is executed, but its definitions aren't available in the REPL session as expected. My predef.sc is as follows:

repl.prompt() = "\n> "
interp.configureCompiler(_.settings.nowarnings.value = false)

// Load utility definitions I share with default scala REPL
try repl.load.exec(ammonite.ops.home/".config"/'scala/"replinit.scala")
catch { case _: Exception => println("=== replrc not loaded! ===") }

If the replinit.scala contains this:

println("===== Running replinit exec =====")
val accessible = "yay"

Then:

$ amm
Loading...
Compiling /Users/ches/(console)
===== Running replinit exec =====
Welcome to the Ammonite Repl 1.0.0
(Scala 2.12.2 Java 1.8.0_112)
If you like Ammonite, please support our development at www.patreon.com/lihaoyi

> accessible
cmd1.sc:1: not found: value accessible
val res1 = accessible
           ^
Compilation Failed

> repl.load.exec(ammonite.ops.home/".config"/'scala/"replinit.scala")
Compiling /Users/ches/(console)
===== Running replinit exec =====


> accessible
res3: String = "yay"
ches added a commit to ches/dotfiles that referenced this issue Jul 8, 2017
Though repl.load.exec seems broken at the moment:

  com-lihaoyi/Ammonite#658
@lihaoyi
Copy link
Member

lihaoyi commented Jul 8, 2017

huhh i thought i made it work, clearly i must've messed up somwhere. Thanks for the report!

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