bigmachine-io / taking-off

93 stars 27 forks source link

So confused... debugging chapter #13

Open SlowburnAZ opened 6 years ago

SlowburnAZ commented 6 years ago

At the start of the Debugging chapter, before doing anything, I'm just trying to run the tests, and I'm getting the following when running "mix test --trace":

warning: variable "deps" does not exist and is being expanded to "deps()", please use parentheses to remove the ambiguity or change the variable name
  mix.exs:10

Compiling 6 files (.ex)
warning: variable "val" is unused
  lib/converter.ex:3

warning: variable "val" is unused
  lib/converter.ex:7

warning: variable "val" is unused
  lib/converter.ex:11

warning: variable "val" is unused
  lib/converter.ex:15

warning: variable "earth" does not exist and is being expanded to "earth()", please use parentheses to remove the ambiguity or change the variable name
  lib/physics/rocketry.ex:9

warning: variable "mars" does not exist and is being expanded to "mars()", please use parentheses to remove the ambiguity or change the variable name
  lib/physics/rocketry.ex:14

warning: variable "moon" does not exist and is being expanded to "moon()", please use parentheses to remove the ambiguity or change the variable name
  lib/physics/rocketry.ex:19

warning: variable "newtons_gravitational_constant" does not exist and is being expanded to "newtons_gravitational_constant()", please use parentheses to remove the ambiguity or change the variable name
  lib/physics/rocketry.ex:31

warning: variable "earth" does not exist and is being expanded to "earth()", please use parentheses to remove the ambiguity or change the variable name
  lib/physics/rocketry.ex:31

warning: variable "newtons_gravitational_constant" does not exist and is being expanded to "newtons_gravitational_constant()", please use parentheses to remove the ambiguity or change the variable name
  lib/physics/rocketry.ex:40

warning: variable "earth" does not exist and is being expanded to "earth()", please use parentheses to remove the ambiguity or change the variable name
  lib/physics/rocketry.ex:40

warning: variable "earth" does not exist and is being expanded to "earth()", please use parentheses to remove the ambiguity or change the variable name
  lib/physics/rocketry.ex:46

warning: variable "newtons_gravitational_constant" does not exist and is being expanded to "newtons_gravitational_constant()", please use parentheses to remove the ambiguity or change the variable name
  lib/physics/rocketry.ex:50

Generated physics app

PhysicsTest
  * test escape velocity of planet X is correct (0.00ms)

  1) test escape velocity of planet X is correct (PhysicsTest)
     test/physics_test.exs:19
     ** (FunctionClauseError) no function clause matching in Converter.to_km/1

     The following arguments were given to Converter.to_km/1:

         # 1
         926.9623828717426

     Attempted function clauses (showing 1 out of 1):

         def to_km(val) when -is_integer(val)-

     code: ev =  %{mass: 4.0e22, radius: 6.21e6} |> Physics.Rocketry.escape_velocity
     stacktrace:
       (physics) lib/converter.ex:27: Converter.to_km/1
       (physics) lib/physics/rocketry.ex:25: Physics.Rocketry.escape_velocity/1
       test/physics_test.exs:20: (test)

  * test Converter one works (0.00ms)
  * test ConverterTwo works (0.00ms)

  2) test ConverterTwo works (PhysicsTest)
     test/physics_test.exs:35
     ** (UndefinedFunctionError) function ConverterTwo.to_light_seconds/2 is undefined (module ConverterTwo is not available)
     code: ls = ConverterTwo.to_light_seconds({:miles, 1000}, precision: 5)
     stacktrace:
       ConverterTwo.to_light_seconds({:miles, 1000}, [precision: 5])
       test/physics_test.exs:36: (test)

  * test ConverterTwo works with default values (15.0ms)

  3) test ConverterTwo works with default values (PhysicsTest)
     test/physics_test.exs:40
     ** (UndefinedFunctionError) function ConverterTwo.to_light_seconds/1 is undefined (module ConverterTwo is not available)
     code: ls = ConverterTwo.to_light_seconds({:miles, 1000})
     stacktrace:
       ConverterTwo.to_light_seconds({:miles, 1000})
       test/physics_test.exs:41: (test)

  * test escape velocity of earth is correct (0.00ms)

  4) test escape velocity of earth is correct (PhysicsTest)
     test/physics_test.exs:4
     ** (FunctionClauseError) no function clause matching in Converter.to_km/1

     The following arguments were given to Converter.to_km/1:

         # 1
         11183.2516621689

     Attempted function clauses (showing 1 out of 1):

         def to_km(val) when -is_integer(val)-

     code: ev = Physics.Rocketry.escape_velocity(:earth)
     stacktrace:
       (physics) lib/converter.ex:27: Converter.to_km/1
       (physics) lib/physics/rocketry.ex:25: Physics.Rocketry.escape_velocity/1
       test/physics_test.exs:5: (test)

  * test escape velocity of moon is correct (0.00ms)

  5) test escape velocity of moon is correct (PhysicsTest)
     test/physics_test.exs:14
     ** (FunctionClauseError) no function clause matching in Converter.to_km/1

     The following arguments were given to Converter.to_km/1:

         # 1
         2375.1809330874535

     Attempted function clauses (showing 1 out of 1):

         def to_km(val) when -is_integer(val)-

     code: ev = Physics.Rocketry.escape_velocity(:moon)
     stacktrace:
       (physics) lib/converter.ex:27: Converter.to_km/1
       (physics) lib/physics/rocketry.ex:25: Physics.Rocketry.escape_velocity/1
       test/physics_test.exs:15: (test)

  * test escape velocity of mars is correct (0.00ms)

  6) test escape velocity of mars is correct (PhysicsTest)
     test/physics_test.exs:9
     ** (FunctionClauseError) no function clause matching in Converter.to_km/1

     The following arguments were given to Converter.to_km/1:

         # 1
         5007.130210128

     Attempted function clauses (showing 1 out of 1):

         def to_km(val) when -is_integer(val)-

     code: ev = Physics.Rocketry.escape_velocity(:mars)
     stacktrace:
       (physics) lib/converter.ex:27: Converter.to_km/1
       (physics) lib/physics/rocketry.ex:25: Physics.Rocketry.escape_velocity/1
       test/physics_test.exs:10: (test)

  * test Converting to to_light_seconds (0.00ms)

Finished in 0.06 seconds
8 tests, 6 failures

Randomized with seed 272000

I've made sure all my code matches the code here: https://github.com/bigmachine-io/taking-off/tree/7c05b129cd6c9bf7fd95a3aadecd0472eb510408. I'm assuming that this code should basically be the ending code for the Orbital Distance chapter.

Any help?

robconery commented 6 years ago

The errors are telling you that your modules can't be found/loaded with the arity provided. Hard to offer any help unless I see the code that's failing. Gist maybe?

dalefrancis88 commented 5 years ago

So i am getting the same issues as @SlowburnAZ and I actually get thos same errors if i clone the code he references from this repo without any changes. I was able to fix it by referencing Planets directly and removing the import but my guess is that this is what you were intending to avoid.

Maybe could it have been a change in Elixir or is it possible that there is something we've missed in config? If it is it would likely be something really simple :)

robconery commented 5 years ago

Yeah that could be. Which version of Elixir are you on?

dalefrancis88 commented 5 years ago

Running elixir -v results in the following

Erlang/OTP 21 [erts-10.1] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1]

Elixir 1.8.1 (compiled with Erlang/OTP 20)
dalefrancis88 commented 5 years ago

Did you get a chance to work out what the issue may be? I appreciate that this is likely something on our end but any insights you might have would be amazing

robconery commented 5 years ago

Well... crap. The problem that I'm facing is non-trivial. Since the release of this course the language has bumped 5 or so major revs, Ecto has gone from 2.0 to > 3.0 and Postgrex (the DB driver) has overhauled its date system which messes with Timex, which is also a dependency, and has also bumped a release to > 3.x.

My problem is this: to update this I would need to do a full rewrite, which would disassociate it completely from the videos you guys are using, making it pointless. There is no "simple" fix here, that I can see. Amnesia, for instance, has a dependency on "exquisite" which fails compilation due to its own dependency problems. Amnesia itself hasn't been updated in 2 years and the only thing I can do here is to completely redo the bits on mnesia or to toss the whole thing out.

I took the Elixir course offline about 4 months ago because of issues like this in the Elixir landscape. I love the language but there are quite a few abandoned projects out there that are causing issues just like this one. I simply couldn't keep up.

To that end: if you'd like full refunds I'm happy to do that and you can, hopefully, put that money toward a more up-to-date resource such as Daily Drip.

dalefrancis88 commented 5 years ago

Nah man, I know how much work went into this course and it's structure is probably the favourite of all the courses I've done in my career. It shows a true quality of character that you'd offer a refund.

If I can convince you to re-write the course, i'd like to offer my help in doing so

foucist commented 1 year ago

I feel like it would be fairly straightforward to install the specific version of erlang & elixir & all the libraries that the course is designed for.