cpjk/canary

Error when building for prod

snewcomer opened this issue · 5 comments

After deploying to a server, I am getting:

Canada.Can.can?/3 is undefined (module Canada.Can is not available)
Canada.Can.can?(%App.User{...}, :update, %App.Location{...})

Abilities file:

defmodule Canary.Abilities do

  defimpl Canada.Can, for: User do

    def can?(%User{} = user, :update, %Location{}), do: LocationPolicy.update?(user)

Any thoughts on why this is failing after building and deploying (using distillery) to a server, but working locally? Not much to go on, but if you have encountered something similar, it would be great to hear! Otherwise will close this issue.

So what is interesting is building for production, I see this stack trace (_authorize_resource). This is pre this commit. However, locally I have the correct canary code in my deps folder. I am using {:canary, github: "cpjk/canary"},. Any thoughts on why this is occurring when building and deploying to prod?

screen shot 2017-03-28 at 5 53 01 pm

cpjk commented

If you're using Canary in production, I would recommend using the version on hex, rather than github, as it is more stable.

As for the error, would you mind posting the whole stack trace? https://github.com/cpjk/canary/blob/master/lib/canary/plugs.ex#L207 doesn't look like it's doing much.

@cpjk Definitely. Will do. I actually just realized it might be an old cached version (before the above commit ref) on my build server (rather than an unpublished pkg or something like that, if that is even possible)

@cpjk Sorry terrible theories on my part :). So here is the undefined function from my error log. Expands to Canada.Can.can?(%MyApp.User{...}, :update, %MyApp.Resource{...}). So it has an arity of 3, I'm passing 3 arguments, etc. It works locally but not after building and deploying (w/ distillery and edeliver) to a server. Any thoughts on other debugging techniques to figure out this problem?

Elixir 1.4.2
Erlang 19.2

screen shot 2017-03-29 at 10 41 02 am

screen shot 2017-03-29 at 10 50 29 am

Then when jumping into iex -S mix locally:

screen shot 2017-03-29 at 11 18 29 am

but on my server bin/myapp console or bin/myapp remote_console while it is running:

screen shot 2017-03-29 at 11 20 47 am

Turns out I had to add canada to extra_applications in my mix file.