Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Error when building for prod #56

Closed
snewcomer opened this issue Mar 15, 2017 · 5 comments
Closed

Error when building for prod #56

snewcomer opened this issue Mar 15, 2017 · 5 comments

Comments

@snewcomer
Copy link

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.

@snewcomer
Copy link
Author

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
Copy link
Owner

cpjk commented Mar 29, 2017

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.

@snewcomer
Copy link
Author

@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)

@snewcomer
Copy link
Author

snewcomer commented Mar 29, 2017

@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

@snewcomer
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants