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

Cannot Find Phoenix.Router, others in new Phoenix project. #5

Closed
Havvy opened this issue Dec 29, 2014 · 11 comments
Closed

Cannot Find Phoenix.Router, others in new Phoenix project. #5

Havvy opened this issue Dec 29, 2014 · 11 comments

Comments

@Havvy
Copy link
Contributor

Havvy commented Dec 29, 2014

In Phoenix projects, use Phoneix.X gives a lint warning saying that it cannot find the proper module.

Steps to reproduce:

  1. Download Phoenix has per their instructions.
  2. mix phoenix.new Test /path/to/test
  3. cd /path/to/test
  4. mix deps.get
  5. mix compile
  6. subl /path/to/test/web/router.ex

See a red dot on line 2 with statement "Error: module Phoenix.Router is not loaded and cannot be found.

@vishnevskiy
Copy link
Owner

I will look into but can you attempt instead.

  1. cd /path/to/test
  2. subl .

Then edit the file while the whole tree is open. It worked that way for me.

@Havvy
Copy link
Contributor Author

Havvy commented Dec 29, 2014

Same result.

@vishnevskiy
Copy link
Owner

What OS are you on? I am able to use this on both my OSX machine and an Ubuntu VM.

@Havvy
Copy link
Contributor Author

Havvy commented Dec 29, 2014

NixOS where both Elixir and SublimeText are installed via nix-env.

Edit: Note that outside of use statements, I do get autocompletion. I can autocomplete Phoenix.R[outer] for instance.

@rjsamson
Copy link

rjsamson commented Jan 7, 2015

I'm getting this same issue on OSX Yosemite

@hiphoox
Copy link

hiphoox commented Jan 9, 2015

yeah, I have the same problem with all my use statements.

Example: use Ecto.Repo, adapter: Ecto.Adapters.Postgres

I'm using Yosemite and I opened sublime in the project directory
repo_ex_ peopleware_and_cannot_find_phoenix_router__others_in_new_phoenix_project_ issue__5 _vishnevskiy_elixirsublime

@andref
Copy link

andref commented Jan 23, 2015

I had the same issue and discovered that the linter plugin cannot find the mix project. When elixirc runs, it doesn’t have a proper path where to find the modules.

That happens because find_mix_project uses os.getcwd if no argument is given as a starting point. However, there’s no guarantee that the current directory will be the phoenix project (in my case, it was the Sublime Text package folder or some such). I fixed it by changing elixir_sublime.py and feeding find_mix_project the file the linter is currently handling, self.filename:

  class ElixirLinter(Linter):
      ...
      def cmd(self):
          ...
          for path in find_ebin_folders(find_mix_project(self.filename)):
              command.extend(['-pa', path])

I’m not sure if this will break other stuff since I never wrote a sublime linter plugin (and that’s why I’m not making a PR), but it works for me.

@andreionut
Copy link

That fixed it for me @andref
I think you should put a PR

Havvy added a commit to Havvy/ElixirSublime that referenced this issue Aug 30, 2015
Because @andref didn't send a PR, and it works for me too...
vishnevskiy added a commit that referenced this issue Aug 30, 2015
@Havvy
Copy link
Contributor Author

Havvy commented Aug 30, 2015

Fixed by PR #13

@Havvy Havvy closed this as completed Aug 30, 2015
@vladra
Copy link

vladra commented Feb 24, 2016

I have same problem despite of this PR. With use Something.Web, :router and all other uses of use. Any tips how to solve this?

@aawilson
Copy link

aawilson commented May 1, 2016

To @vladra and others: When I ran into this same issue, it wasn't due to ElixirSublime, but instead from the SublimeLinter elixirc plugin in a Mix context. The appropriate config for a Mix project for that plugin is specified here: https://github.com/smanolloff/SublimeLinter-contrib-elixirc#example

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

No branches or pull requests

8 participants