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

HdevtoolsType generates errors as if not configured using hdevtools_options #32

Open
EdmundsEcho opened this issue Apr 7, 2018 · 4 comments

Comments

@EdmundsEcho
Copy link

Hello, working with vim (nvim) with the integration of hdevtools improves my workflow a great deal. Thank you for this contribution.

Issue
When I call HdevtoolsType from vim's command line I get errors that say the binary can't find the modules in the project. I suspect this is an issue because of the following:

  1. in terminal, hdevtools check -g -isrc -g -Wall -g -hide-package -g transformers src/Render/Pre.hs works as expected
  2. in vim's command line, echo hdevtools_options I get what is expect: -g -isrc -g -Wall -g -hide-package -g transformers

... so why might I be getting the following when I call HdevtoolsType from vim's command line?

Failed to load targets
/Users/.../src/Render/Pre.hs:12:1: error:
    Could not find module ‘Models’
    Use -v to see a list of the files searched for.
/Users/.../src/Render/Pre.hs:13:1: error:
    Could not find module ‘Lib.Lens’
    Use -v to see a list of the files searched for.

Finally, when I look at the list of files searched, it seems to find them!

Failed to load targets
<no location info>: *** Chasing dependencies:
<no location info>:
    Chasing modules from: */Users/.../src/Render/Pre.hs
<no location info>:
    !!! Chasing dependencies: finished in 0.52 milliseconds, allocated 0.228 megabytes
<no location info>: *** Chasing dependencies:
<no location info>:
    Chasing modules from: */Users/.../src/Render/Pre.hs
<no location info>:
    !!! Chasing dependencies: finished in 0.52 milliseconds, allocated 0.225 megabytes
<no location info>:
    Stable obj: []
    Stable BCO: []
<no location info>:
    Ready for upsweep
      [NONREC
          ModSummary {
             ms_hs_date = 2018-04-07 13:34:20.687163728 UTC
             ms_mod = Render.Pre,
             ms_textual_imps = [(Nothing, Prelude), (Nothing, Lib.Lens),
                                (Nothing, Models)]
             ms_srcimps = []
          }]
<no location info>: *** Deleting temp files:
<no location info>: Deleting: 
<no location info>:
    compile: input file /Users/.../src/Render/Pre.hs
<no location info>:
    *** Checking old interface for Render.Pre (use -ddump-hi-diffs for more details):
<no location info>:
    [1 of 1] Compiling Render.Pre       ( /Users/.../src/Render/Pre.hs, nothing )
<no location info>: *** Parser [Render.Pre]:
<no location info>:
    !!! Parser [Render.Pre]: finished in 1.96 milliseconds, allocated 2.882 megabytes
<no location info>: *** Renamer/typechecker [Render.Pre]:
<no location info>:
    !!! Renamer/typechecker [Render.Pre]: finished in 0.04 milliseconds, allocated 0.020 megabytes
/Users/.../src/Render/Pre.hs:12:1: error:
    Could not find module ‘Models’
    Locations searched:
      Models.hs
      Models.lhs
      Models.hsig
      Models.lhsig
      src/Models.hs
      src/Models.lhs
      src/Models.hsig
      src/Models.lhsig
/Users/.../src/Render/Pre.hs:13:1: error:
    Could not find module ‘Lib.Lens’
    Locations searched:
      Lib/Lens.hs
      Lib/Lens.lhs
      Lib/Lens.hsig
      Lib/Lens.lhsig
      src/Lib/Lens.hs
      src/Lib/Lens.lhs
      src/Lib/Lens.hsig
      src/Lib/Lens.lhsig
<no location info>: Upsweep partially successful.
<no location info>: *** Deleting temp files:
<no location info>: Deleting: 

Thank you in advance for any pointers to resolving this issue.

- E

@bitc
Copy link
Owner

bitc commented Apr 8, 2018

It looks like the problem might be that hdevtools is being invoked from vim with the absolute path /Users/.../src/Render/Pre.hs rather than the relative path src/Render/Pre.hs

Note that it is important that you run vim from your project root directory, so that the relative paths will work

@EdmundsEcho
Copy link
Author

EdmundsEcho commented Apr 8, 2018

I normally do run vim from root... this said, not always. Thank you for reminding me. I'll try it out again and report back accordingly. This all said, my vim configuration enables the working directory to change based on the current buffer (autochdir). It is a vim state that augments the functionality of <C-x><C-f>.

Update: I tried it out making sure I started from root... it works. I opened vim from somewhere else, it fails. Thank you for figuring this out.

Key question: Does the plugin record the root directory once when first opened? In other words, can the plugin operate with the vim register autochdir?

@bitc
Copy link
Owner

bitc commented Apr 8, 2018

It is likely that autochdir will cause problems with this plugin.

During a single session, all invocations of the hdevtools command must be called from the same directory. The first time hdevtools is run, it creates a socket file in the current directory called .hdevtools.sock. All subsequent commands look for this file in the current directory.

The plugin uses expand("%") to get the path to the current file. You can see what this evaluates by running this in vim:

:echo expand("%")

It may be possible to modify this plugin to work well with autochdir, probably need to make use of hdevtool's --socket option.

@EdmundsEcho
Copy link
Author

When starting vim from the root project directly, to open a file elsewhere in the project, HdevtoolsType works. :echo expand('%') => the file name only. :echo expand('%:p') provides the file name and full path. Finally, :pwd confirms I'm in a directory that is no longer root... interesting.

I'll report back on what the output is when the plugin fails while using autochdir.

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

2 participants