cabal new-repl outside the project cwd is /tmp/....

Created on 24 Aug 2018  路  4Comments  路  Source: haskell/cabal

So I cannot :l mySmallExample.hs as easily

cmrepl nix-local-build enhancement

Most helpful comment

This is indeed an issue. But I have to wonder: if you're firing up cabal new-repl with the immediate intention of just :loading a single file, perhaps we should allow new-repl to support this use case directly? For example, you might have a cabal script like this:

{- cabal:
build-depends: base       >= 4.9
             , QuickCheck >= 2.12
             , sop-core   >= 0.4
-}
module Main where
...

Currently, you can cabal new-run Main.hs and it'll take care of the rest, but sadly, there does not appear to be a counterpart for new-repl. AFAICT, you have to perform all of the following steps:

  1. Run cabal new-repl -b QuickCheck -b sop-core. (Yes, you have to specify all of the dependencies as flags, despite the fact that they're already stated in the file itself. Urk.)
  2. Run :cd ... to get back to the directory you were in (due to this bug described in this issue).
  3. Run :load Main.hs.
  4. Pray that you remembered to include all of the dependencies when you ran new-repl in step 1. If you accidentally forgot one, prepare to Ctrl+D and start all over again from step 1.

This feels excessively complicated. Why can't we just say cabal new-repl Main.hs? (Or perhaps --file Main.hs, if folks feel that this behavior should be behind a flag.)

All 4 comments

/cc @typedrat

just for the record, inside a project, cabal new-repl typically will chdir into the folder of the respective package whose component was requested for the repl session

For a project-less new-repl invocation I too would expect ghci to be invoked with the original CWD you invoked cabal with

This is somewhat tricky to handle, because there are a lot of layers of stuff between where we know if we are using new-repl at all and if we are in a project or outside of one and the place where we decide what the CWD should be.

This is indeed an issue. But I have to wonder: if you're firing up cabal new-repl with the immediate intention of just :loading a single file, perhaps we should allow new-repl to support this use case directly? For example, you might have a cabal script like this:

{- cabal:
build-depends: base       >= 4.9
             , QuickCheck >= 2.12
             , sop-core   >= 0.4
-}
module Main where
...

Currently, you can cabal new-run Main.hs and it'll take care of the rest, but sadly, there does not appear to be a counterpart for new-repl. AFAICT, you have to perform all of the following steps:

  1. Run cabal new-repl -b QuickCheck -b sop-core. (Yes, you have to specify all of the dependencies as flags, despite the fact that they're already stated in the file itself. Urk.)
  2. Run :cd ... to get back to the directory you were in (due to this bug described in this issue).
  3. Run :load Main.hs.
  4. Pray that you remembered to include all of the dependencies when you ran new-repl in step 1. If you accidentally forgot one, prepare to Ctrl+D and start all over again from step 1.

This feels excessively complicated. Why can't we just say cabal new-repl Main.hs? (Or perhaps --file Main.hs, if folks feel that this behavior should be behind a flag.)

Was this page helpful?
0 / 5 - 0 ratings