Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Different behavior between launch stack exec hie and hie directly #87

Closed
JPMoresmau opened this issue Nov 21, 2015 · 13 comments · Fixed by #91
Closed

Different behavior between launch stack exec hie and hie directly #87

JPMoresmau opened this issue Nov 21, 2015 · 13 comments · Fixed by #91
Assignees
Milestone

Comments

@JPMoresmau
Copy link
Contributor

via stack:

jpmoresmau:~/Documents/haskell-ide-engine$ stack exec hie
{"cmd":"ghcmod:type","params":{"file":{"file":"/home/jpmoresmau/Documents/haskell-ide-engine/src/Haskell/Ide/Engine/Types.hs"},"start_pos":{"pos":[21,9]}}}
^B
{"type_info":"21 5 21 17 \"TChan ChannelResponse\"\n21 5 21 17 \"ChannelRequest -> TChan ChannelResponse\"\n21 5 21 17 \"ChannelRequest\"\n21 5 21 17 \"TChan ChannelResponse\"\n"}

This seems ok.
Via the executable directly:

jpmoresmau:~/Documents/haskell-ide-engine$ .stack-work/dist/x86_64-linux/Cabal-1.22.4.0/build/hie/hie
{"cmd":"ghcmod:type","params":{"file":{"file":"/home/jpmoresmau/Documents/haskell-ide-engine/src/Haskell/Ide/Engine/Types.hs"},"start_pos":{"pos":[21,9]}}}
^B
EXCEPTION: types:
       Could not find module ‘Data.Aeson’
       Perhaps you meant Data.Version (from base-4.8.1.0)
       Use -v to see a list of the files searched for.
       Could not find module ‘Control.Concurrent.STM.TChan’
       Perhaps you meant
         Control.Concurrent.Chan (from base-4.8.1.0)
         Control.Concurrent.MVar (from base-4.8.1.0)
       Use -v to see a list of the files searched for.
       Could not find module ‘Haskell.Ide.Engine.PluginDescriptor’
       Use -v to see a list of the files searched for.
{"type_info":""}

What does stack exec do that calling the executable directly doesn't do? Surely calling the executable directly should also work.

@alanz
Copy link
Collaborator

alanz commented Nov 21, 2015

Is this against master?

@JPMoresmau
Copy link
Contributor Author

Yep

@alanz
Copy link
Collaborator

alanz commented Nov 22, 2015

Ok, will have a look. Have been tied up this weekend

@cocreature
Copy link
Collaborator

I can reproduce this. Interestingly enough it also crashes for me when I don’t use stack exec because it still can’t find the PluginDescriptor module, but in that case it finds Data.Aeson.

This exception seems to be thrown by the ghc-mod plugin. stack exec sets some paths, so I suppose that causes ghc-mod to find them the module when used inside of stack exec.

@alanz
Copy link
Collaborator

alanz commented Nov 22, 2015

I know ghc-mod and stack are not always friends at the moment at runtime,
in terms of access to packages.

On Sun, Nov 22, 2015 at 7:35 PM, Moritz Kiefer notifications@github.com
wrote:

I can reproduce this. Interestingly enough it also crashes for me when I
don’t use stack exec because it still can’t find the PluginDescriptor
module, but in that case it finds Data.Aeson.

This exception seems to be thrown by the ghc-mod plugin. stack exec sets
some paths, so I suppose that causes ghc-mod to find them the module when
used inside of stack exec.


Reply to this email directly or view it on GitHub
#87 (comment)
.

@alanz
Copy link
Collaborator

alanz commented Nov 22, 2015

This may be pointing to a potential problem lying ahead, namely making sure the compiler, project and tools all agree on the versions of things to use.

@DanielG
Copy link
Collaborator

DanielG commented Nov 22, 2015

Are you running ghc-mod as an executable now or using the library?

@alanz
Copy link
Collaborator

alanz commented Nov 22, 2015

Library

@JPMoresmau
Copy link
Contributor Author

It's just a question of GHC_PACKAGE_PATH. If I set it as the value that stack uses, then things work. Of course, this begs the question, how should we handle this? Should the client IDE pass that value? Should we try to gather it ourselves from the path of the project (using .cabal-sandbox or stack.yml)

@cocreature
Copy link
Collaborator

Imho we should figure that out ourselves. This is something every IDE needs so leaving it up to the IDE only results in a lot of different implementations of the same thing.

@alanz
Copy link
Collaborator

alanz commented Nov 22, 2015

Agree, but it may depend on the O/S as well as what environment the
specific project is running in.

In general I would expect hie to be installed as a dev-machine level tool,
rather than an individual project tool.

So running it inside its own .stack-work may be an unusual/dev-only
situation

On Sun, Nov 22, 2015 at 11:14 PM, Moritz Kiefer notifications@github.com
wrote:

Imho we should figure that out ourselves. This is something every IDE
needs so leaving it up to the IDE only results in a lot of different
implementations of the same thing.


Reply to this email directly or view it on GitHub
#87 (comment)
.

@JPMoresmau JPMoresmau self-assigned this Nov 22, 2015
@JPMoresmau
Copy link
Contributor Author

So the status: ghc-mod requires the working directory to be the root directory of the project, period. You can run runGhcModT' and pass it a directory, but ghc-mod will throw an error if the working directory doesn't match the project root directory anyway. Which is why the current tests pass (ghc-mod finds a stack file and cabal file in the current directory, our own root directory), but calling the executable from anywhere else will fail, since we set the working directory to be the user home directory. So we basically have to call ghc-mod rootInfo function to get the working directory to use. Working on it.

@JPMoresmau JPMoresmau mentioned this issue Nov 22, 2015
@alanz
Copy link
Collaborator

alanz commented Nov 23, 2015

Thanks.

We need this functionality, to be able to work on different projects within
an IDE anyway.

On Mon, Nov 23, 2015 at 1:03 AM, JP Moresmau notifications@github.com
wrote:

So the status: ghc-mod requires the working directory to be the root
directory of the project, period. You can run runGhcModT' and pass it a
directory, but ghc-mod will throw an error if the working directory doesn't
match the project root directory anyway. Which is why the current tests
pass (ghc-mod finds a stack file and cabal file in the current directory,
our own root directory), but calling the executable from anywhere else will
fail, since we set the working directory to be the user home directory. So
we basically have to call ghc-mod rootInfo function to get the working
directory to use. Working on it.


Reply to this email directly or view it on GitHub
#87 (comment)
.

@alanz alanz closed this as completed in #91 Nov 23, 2015
@alanz alanz added this to the prehistory milestone Feb 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants