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

watcher does not work as expected #230

Closed
magmax opened this issue Jan 1, 2019 · 9 comments · Fixed by #232
Closed

watcher does not work as expected #230

magmax opened this issue Jan 1, 2019 · 9 comments · Fixed by #232

Comments

@magmax
Copy link

magmax commented Jan 1, 2019

Hello, I'm having the next problem:

$ mix meditate --no-clear-screen                                                                                          
Compiling 1 file (.ex)                                                                                                                                                   
warning: function Code.compile_file/1 is undefined or private. Did you mean one of:                                                                                      

      * compile_quoted/1
      * compile_quoted/2
      * compile_string/1
      * compile_string/2
      * compiler_options/0

  lib/watcher.ex:27


Now meditate upon Strings
|>                             | 10 of 211
----------------------------------------
Or pulled apart into a list when needed
Assertion failed in lib/koans/02_strings.ex:18
["hello", "world"] == String.split(___, " ")

It is just a warning, but whenever I modify the code, I see this error:

** (UndefinedFunctionError) function Code.compile_file/1 is undefined or private. Did you mean one of:                                                                   

      * compile_quoted/1
      * compile_quoted/2
      * compile_string/1
      * compile_string/2
      * compiler_options/0

    (elixir) Code.compile_file("/home/.../elixir-koans/lib/koans/01_equalities.ex")                                                                               
    (elixir_koans) lib/watcher.ex:27: Watcher.reload/1

And it doesn't work as expected.

I'm using:

$ elixir --version                                                                                                      
Erlang/OTP 20 [erts-9.3.3.3] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]                                                       

Elixir 1.6.5 (compiled with OTP 20)                  

On ubuntu 18.10 and use vim to edit (tested with gedit too).

@felipesere
Copy link
Collaborator

Can you try with Erlang 21?

@Nagasaki45
Copy link
Contributor

The issue was introduced in 8c0c314. Code.compile_file was added in elixir 1.7. Before that we used Code.load_file which is now deprecated. Don't really know what should be the best solution to keep supporting older elixir versions...
@magmax, you can upgrade to elixir 1.7. Not that this is a proper solution to this issue, just a hacky workaround.

@felipesere
Copy link
Collaborator

Hmmm... Now that I look a bit closer, I don't think our travis run would have caught it.
We don't have any tests for lib/watcher.ex 😭

From what I can see in the Ubuntu package index, you might not be able to upgrade using apt.
An alternative I have used on CI has been to use asdf as desribed here: https://gist.github.com/beaorn/7b90a21b7e80e7744d8d2d08e49efcee#erlang-elixir-and-phoenix

@magmax
Copy link
Author

magmax commented Jan 1, 2019

Yes, it works with 1.7.

I'm a completely newby with elixir (and erlang in general). I suppose that this is the usual profile for koans users XD, so it is a little frustrating to see anything not working as expected. This is just to require to add the elixir 1.7 requirement to the README, because I tried the one available in ubuntu, thinking it was the last one.

In addition, thank you very much for these koans. They make reading documentation much funnier.

@iamvery
Copy link
Collaborator

iamvery commented Jan 2, 2019

Well sorry about this, folks!

Hmmm... Now that I look a bit closer, I don't think our travis run would have caught it.
We don't have any tests for lib/watcher.ex 😭

I thought I had checked, but honestly I probably just assumed CI was a good enough 👍. Since the call is only deprecated at this point, we could revert the changes and use the mean time to iterate on a more robust fix. I'm pretty sure there are options for conditionally including code based on Elixir version. I feel like I've seen this before...

@iamvery
Copy link
Collaborator

iamvery commented Jan 2, 2019

h/t @michalmuskala for this potential solution:

Michał Muskała [8:46 AM]
Or use something like:

if Version.match?(System.version(), "> 1.4.0") do
 def foo(...), do: # use new code
else
 def foo(...), do: # use old code
end

Because all libraries are recompiled every time a version changes anyway, that's a good enough solution

@mparker3
Copy link

mparker3 commented Jan 4, 2019

I'm using the provided Docker.sh script and Dockerfile to run this. If Elixir 1.7 is the supported version, would it make sense to update the Dockerfile to reflect this?

@iamvery
Copy link
Collaborator

iamvery commented Jan 4, 2019

@mparker3 I tend to agree that we should keep the provided environments up to date, however I also think we want to make the koans as approachable as possible. I proposed a solution to make this work without deprecations on versions <= 1.7 in #232. Please have a look!

@felipesere
Copy link
Collaborator

felipesere commented Jan 4, 2019 via email

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

Successfully merging a pull request may close this issue.

5 participants