Elixir v1.7.0-rc.0 released

elixir-release

#4

[Code] Add Code.purge_compiler_modules/0 that purges any compiler module left behind. This is useful for live systems dynamically compiling code

Does this mean that this call is recommended for projects that use fastglobal? Probably immediately after calling FastGlobal.put?

Apologies if it’s a stupid question.


#5

This is generally only required if the compiler cannot automatically release the compiler modules - this is the case if the module body contain anonymous functions (because we don’t know if they wen’t used for spawning processes or stored somewhere). I don’t think it’s required for fastglobal.

EDIT: I’ve just checked the fastglobal code and it compiles the data modules using Erlang compiler and not the elixir one, so it does not affect it in any way.


#6

The new --cover seems to work well. :slight_smile:


#7

Hey @josevalim it seems that Absinthe schemas are entirely broken on the RC, I’m trying to trace down what the root issue here, but I’m not seeing any notable changes to macros or module attributes.

I have a __using__ macro that returns

quote do
  Module.register_attribute(__MODULE__, :foo, accumulate: true)
end

which seems to be behaving differently now. If I change that call to Module.register_attribute(__CALLER__.module, :foo, accumulate: true) in the macro body it seems to work better, although that doesn’t totally fix the issue.


#8

@benwilson512 We did refactor this part of the codebase, so I will gladly take a look if you have failing tests in Absinthe’s suite or a small file I can run with mix run inside Absinthe.


#9

Thanks! Use the 1.7-issue branch which disables certain validations, otherwise the project doesn’t compile. Then in iex -S mix do:

defmodule Foo do
  use Absinthe.Schema.Notation

  object :user do
    field :foo, :string
  end
end

You’ll get some debug output from an IO.inspect function I’ve added here: https://github.com/absinthe-graphql/absinthe/blob/1.7-issue/lib/absinthe/schema/notation/writer.ex#L75

If you mess with that file you’ll run into Bug #1 we’ve actually had a while, where editing the Writer module file requires rm -rf _build or you get a compilation error for some reason.

The new issue however is that if you look at the debug output, the definitions list is empty. “there should be stuff but there isn’t stuff” is one of the less easy things to debug I realize. You can find the first usage of that module attribute here: https://github.com/absinthe-graphql/absinthe/blob/1.7-issue/lib/absinthe/schema/notation.ex#L25


Elixir 1.7.4, Absinthe compilation error: The root query type must be implemented and be a of type Object
#10

I’ll apologize ahead of time for the complexity of the module, the schema building code is some of the oldest in Absinthe. We’re in the middle of reworking it to be simpler and more data driven but it’s still a ways from being ready to ship.


#11

@benwilson512 Thanks. I will investigate. You should probably consider have an optional build on Travis for Absinthe that runs on Elixir master. This way we can find this failures earlier. :slight_smile:


#12

Very cool! :heart_eyes:


Question about the changelog:

In ‘Documentation metadata’, the following example is used:

@moduledoc "A brand new module"
@moduledoc authors: ["Jane", "Mary"], since: "1.4.0"

Right below that, it states that Elixir currently supports the keys :deprecated and :since.

What about the :authors-key that is used in the example?


#13

We support any metadata but only the keys :deprecated and :since are printed in ExDoc and IEx and so on. We will clarify the examples.


#14

So I understand the current behaviour and why accumulate did not work in previous Elixir versions.

It seems that you are calling put_definition many times before you invoke accumulate: true. If I do this:

if @absinthe_definitions do
  raise "omg"
end
Module.register_attribute(__MODULE__, :absinthe_definitions, accumulate: true)

You will see that @absinthe_definitions is not nil. The behaviour of setting an attribute to accumulate after it is set is “undefined”. In previous versions, we were still able of keeping whatever has been accumulated (with caveats) but in the new version we discard it.

However, I would say that the previous behaviour (in earlier Elixir versions) is also broken because your put_definition would lead to a bunch of duplicated definitions. When accumulate: true is false, put_definition works fine, but when it is enabled, you would end-up getting the whole list, prepending to it, and then adding it as an entry on top of the existing list. For example, imagine you had definitions x, y and z already stored. In the attribute, they would be stored as [:z, :y, :x]. Now imagine that you add :a, at the end you will end-up with [[:a, :z, :y, :x], :z, :y, :x]. However, it seems accumulate: true is only set too late in your suite, so this doesn’t happen there.


#15

Ahh yes this makes sense, thanks for explaining, I was able to fix the issues via: https://github.com/absinthe-graphql/absinthe/commit/8c622942364c585e30d2ef03256a9a7103861e7d

Any thoughts on the Writer module issue? I’ve hesitated to create an Elixir error before because I couldn’t reproduce it outside the Absinthe project.


#16

Folks, please let us know if you tried the release candidate and if everything is fine. Even if you found no regressions, say so in the comments, otherwise we can’t know if everyone is quiet because nobody tried it yet or if because nobody found bugs. Hoping for the latter. :slight_smile:


#17

The Meeseeks tests run fine using the RC and OTP21.

Edit: And a larger Phoenix 1.2 project with a bunch of deps also runs its tests fine (RC and OTP21), though it did complain that I shouldn’t use length(res) > 0 in my tests. :smiley:


#18

Seems to work with Caravan and a Phoenix 1.3 app that we have. My Phoenix project using Abinsthe won’t compile for what l assume are the reasons that Ben mentioned.


#19

I tested it with Conduit. I had to fix a warning related to System.stacktrace(). I was doing the equivalent of:

def try_a_thing do
  # something might fail
rescue error ->
  log_error(error)
end

def log_error(error) do
  Exception.format(:error, error, System.stracktrace())
  |> Logger.error()
end

Which I changed to:

def try_a_thing do
  # something might fail
rescue error ->
  log_error(error, System.stracktrace())
end

def log_error(error, stacktrace) do
  Exception.format(:error, error, stracktrace)
  |> Logger.error()
end

Otherwise everything was fine.


#20

I just tried it on a project of mine and found it to not work with ex_cldr's compiler task:

could not compile dependency :ex_cldr_dates_times, "mix compile" failed. You can recompile this dependency with "mix deps.compile ex_cldr_dates_times", update it with "mix deps.update ex_cldr_dates_times" or clean it with "mix deps.cleanex_cldr_dates_times"
** (FunctionClauseError) no function clause matching in Mix.Dep.loaded/1

    The following arguments were given to Mix.Dep.loaded/1:

        # 1
        [env: :prod]

    Attempted function clauses (showing 1 out of 1):

        def loaded([])

    (mix) lib/mix/dep.ex:156: Mix.Dep.loaded/1
    lib/mix/tasks/compile.cldr.ex:86: Mix.Tasks.Compile.Cldr.compile_cldr_files/0
    lib/mix/tasks/compile.cldr.ex:67: Mix.Tasks.Compile.Cldr.run/1
    (mix) lib/mix/task.ex:316: Mix.Task.run_task/3
    (mix) lib/mix/tasks/compile.all.ex:68: Mix.Tasks.Compile.All.run_compiler/2
    (mix) lib/mix/tasks/compile.all.ex:52: Mix.Tasks.Compile.All.do_compile/4
    (mix) lib/mix/tasks/compile.all.ex:23: anonymous fn/1 in Mix.Tasks.Compile.All.run/1
    (mix) lib/mix/tasks/compile.all.ex:39: Mix.Tasks.Compile.All.with_logger_app/1

Seems like the function is deprecated: @kip


#21

@LostKobrakai Mix.Dep.loaded/1 was private API, so folks should not be invoking it in the first place. :slight_smile:

EDIT: I have added it back with a warning but it will be removed in the future.


#22

I have an application that doesn’t want to start:

13:41:22.543 [info]  Application schema exited: Schema.Application.start(:normal, []) returned an error: shutdown: failed to start child: Schema.Repo
    ** (EXIT) exited in: GenServer.call(Ecto.Registry, {:associate, #PID<0.356.0>, {Schema.Repo, Schema.Repo.Pool, [name: Schema.Repo.Pool, otp_app: :schema, repo: Schema.Repo, timeout: 15000, pool_timeout: 5000, adapter: Ecto.Adapters.Postgres, database: "argus_dev", username: "postgres", password: "secret", hostname: "localhost", pool_size: 10, pool: DBConnection.Poolboy]}}, 5000)
        ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started
** (Mix) Could not start application schema: Schema.Application.start(:normal, []) returned an error: shutdown: failed to start child: Schema.Repo
    ** (EXIT) exited in: GenServer.call(Ecto.Registry, {:associate, #PID<0.356.0>, {Schema.Repo, Schema.Repo.Pool, [name: Schema.Repo.Pool, otp_app: :schema, repo: Schema.Repo, timeout: 15000, pool_timeout: 5000, adapter: Ecto.Adapters.Postgres, database: "argus_dev", username: "postgres", password: "secret", hostname: "localhost", pool_size: 10, pool: DBConnection.Poolboy]}}, 5000)
        ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started

Schema is a path dependency. The weird thing is that I have an other application that also has a dependency on Schema and that one works fine.

Not much info here, except the above error, so not sure if this is an issue, but because I have an other application that does start and switching back to 1.6.6 fixes things, it might be an issue with rc?


#23

This does not look like an issue with Elixir 1.7. The error is most likely caused by the :ecto application not being started before starting repos.