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

Haskell-mode not respecting cabal sandboxes #253

Closed
dmjio opened this issue Mar 21, 2014 · 15 comments
Closed

Haskell-mode not respecting cabal sandboxes #253

dmjio opened this issue Mar 21, 2014 · 15 comments

Comments

@dmjio
Copy link

dmjio commented Mar 21, 2014

After cabal-installing my project inside of a cabal sandbox (1.18.0.3) I am able to open a cabal repl and inspect the packages. When I open up emacs w/ haskell-mode and C-c C-l to send to ghci I get :

Prelude> :cd /Users/dmj/Project/
Prelude> :load "Main.hs"

ST/Common/Types.hs:37:18:
    Could not find module `Web.Stripe.Customer'
    Use -v to see a list of the files searched for.
Failed, modules loaded: none.
Prelude>

How do I get haskell-mode to respect cabal sandboxes?

@Eilie
Copy link

Eilie commented Mar 23, 2014

Having this issue too. Fix needed.

@dmjio
Copy link
Author

dmjio commented Mar 28, 2014

@Eilie change your repl to cabal repl in your haskell-mode config and it will respect your sandbox

@dmjio
Copy link
Author

dmjio commented Mar 30, 2014

You can do it if you go M - x apropos and type haskell-mode and look for inferior haskell mode then change ghci to cabal repl. Note this means that you will always need a cabal sandbox when loading a project.
screen shot 2014-03-29 at 2 21 34 am

@Eilie
Copy link

Eilie commented Jun 1, 2014

It doesn't help. I've changed ghci to cabal repl and after loading file within cabal sandbox I'm getting "cannot find module" errors for all external dependencies file having like "Data.Aeson".

@dmjio
Copy link
Author

dmjio commented Jun 1, 2014

@ellie, I stopped doing it the way I was previous (shown above). Use the following in your .emacs to rebind.

;; rebind inferior mode to interactive mode
(eval-after-load "haskell-mode"
  '(progn
     (define-key haskell-mode-map (kbd "C-c C-l") 'haskell-process-load-or-reload)
     (define-key haskell-mode-map (kbd "C-`") 'haskell-interactive-bring)
     (define-key haskell-mode-map (kbd "C-c C-t") 'haskell-process-do-type)
     (define-key haskell-mode-map (kbd "C-c C-i") 'haskell-process-do-info)
     (define-key haskell-mode-map (kbd "C-c C-c") 'haskell-process-cabal-build)
     (define-key haskell-mode-map (kbd "C-c C-k") 'haskell-interactive-mode-clear)
     (define-key haskell-mode-map (kbd "C-c c") 'haskell-process-cabal)
     (define-key haskell-mode-map (kbd "SPC") 'haskell-mode-contextual-space)))

;; custom haskell-mode settings
(custom-set-variables
 '(haskell-process-log t)
 '(haskell-process-type (quote cabal-repl)) ;; mui importante
 '(inferior-haskell-wait-and-jump t))

@Eilie
Copy link

Eilie commented Jun 1, 2014

@dmijo Thank you! That works fine for library(code inside "library" section of cabal file) but for executables(I have couple of executable with different main files) it fails when executable having additional build-depends. Haskell-mode suggests to add these dependencies from executable to library but that's not quite right since library doesn't actually depends on what executable depends if that makes sense.

@dmjio
Copy link
Author

dmjio commented Jun 1, 2014

yea, you might have to manually intervene in some cases. Or just split the executables into their own projects.

@hvr
Copy link
Member

hvr commented Jun 1, 2014

@dmjio you might wanna point out that by doing that, you change to the totally different haskell-interactive-mode. This issue was about the older so-called inferior-haskell-mode which has different trade-offs.

@dmjio
Copy link
Author

dmjio commented Jun 1, 2014

@hvr, good point. I believe inferior-haskell-mode is deprecated, at least, not in active dev. compared to haskell-interactive-mode.

@ivan-m
Copy link
Contributor

ivan-m commented Jun 2, 2014

You can switch to different item in the .cabal file with haskell-session-change-target, but it's a little clumsy to use (ideally it would give you an ido list of possible completions).

You also need to remember to do a cabal configure && cabal install --only-dependencies when using sandboxes before trying to load a file with cabal repl.

@Eilie
Copy link

Eilie commented Jun 2, 2014

@ivan-m,

Thanks for pointing haskell-session-change-target out.

@gracjan
Copy link
Contributor

gracjan commented Mar 1, 2015

@dmjio: Do you consider this fixed for your case? Can we close this issue or should there be a follow up pull request?

@dmjio dmjio closed this as completed Mar 1, 2015
@DanielAtSamraksh
Copy link

To change the haskell-program-name variable, do:
C-h v haskell-program-name RET

Change 'ghci' to 'cabal repl'. Click the 'Apply and Save' button.

@DanielAtSamraksh
Copy link

To change haskell-program-name from 'ghci' to 'cabal repl':

C-h v haskell-program-name RET

Click 'customize'.
Change 'ghci' to 'cabal repl'.
Click 'Apply and Save'.

@gracjan
Copy link
Contributor

gracjan commented Aug 13, 2015 via email

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

7 participants