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

Can't load modules from modules #149

Closed
lihaoyi opened this issue Aug 9, 2015 · 3 comments
Closed

Can't load modules from modules #149

lihaoyi opened this issue Aug 9, 2015 · 3 comments
Milestone

Comments

@lihaoyi
Copy link
Owner

@lihaoyi lihaoyi commented Aug 9, 2015

This doesn't seem to behave correctly in the following case:

// LimitImports.scala
val res = 1
@
val asd = 1
// Foo.scala
import ammonite.ops._

load.module(wd/"LimitImports.scala")

@

println(res)
println(asd)
@ // Repl Session
@ import ammonite.ops._
@ load.module(wd/"Foo.scala")
ammonite.repl.CompilationError: Compilation Failed
Main.scala:174: not found: value res
println(res)
        ^
Main.scala:177: not found: value asd
println(asd)
        ^
    ammonite.repl.interp.Interpreter.loop$1(Interpreter.scala:97)
    ammonite.repl.interp.Interpreter.processScript(Interpreter.scala:86)
    ammonite.repl.interp.Interpreter.processModule(Interpreter.scala:67)
    ammonite.repl.interp.Interpreter$$anon$1$load$.module(Interpreter.scala:134)
    cmd4$$anonfun$1.apply$mcV$sp(Main.scala:110)
    cmd4$.<init>(Main.scala:111)
    cmd4$.<clinit>(Main.scala:-1)

This should work. Will take some refactoring to make load.module put the imports in the right place depending on whether it's being called in a module or directly from the REPL, but shouldn't be hard in principle

@lihaoyi
Copy link
Owner Author

@lihaoyi lihaoyi commented Aug 9, 2015

@laci37 this is probably on you when you come back, since you own much of the module/script loading stuff =)

@lihaoyi lihaoyi added this to the 0.5.0 milestone Aug 16, 2015
@lihaoyi lihaoyi closed this Aug 23, 2015
@dynofu
Copy link

@dynofu dynofu commented Mar 8, 2020

it's broken again

// Foo.scala
import ammonite.ops._
interp.load.module(pwd/"LimitImports.sc")

@
import ammonite.$file.dummy.LimitImports._
println(res)
import ammonite.$file.dummy.LimitImports_2._
println(asd)

this makes writing script compatible with different versions through interp.load.module really hard.
as old version e.g. 1.6.7 does not support import ammonite.$file.dummy.LimitImports_2._
need 1.6.7 to support scala 2.11 and spark.

@dynofu
Copy link

@dynofu dynofu commented Mar 9, 2020

1.6.7 does support import ammonite.$file.dummy.LimitImports_2._ as long as you clear the cache in the start, rm -rf ~/.ammonite/cache

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

Successfully merging a pull request may close this issue.

None yet
2 participants