typelead/etlas

etlas repl/install doenst work outside a project dir (global variant)

jneira opened this issue · 11 comments

(pointed by @rahulmutt in gitter)

  • If you run etlas install <package.name> or etlas repl in a directory without any config file and without any subdir with them, it fails with:
C:\> etlas install pandoc
etlas: There is no etlas.dhall, <pkgname>.etlas, <pkgname>.cabal package file
or cabal.project file. To build packages locally you need at minimum an
etlas.dhall, <pkgname>.etlas or <pkgname>.cabal file. You can use 'etlas init'
to create one.

For non-trivial projects you will also want a cabal.project file in the root
directory of your project. This file lists the packages in your project and
all other build configuration. See the Etlas user guide for full details.
  • I tested it with master version of etlas and the version 1.5.0.0 downloaded from the web.
  • cabal new-install and cabal new-repl works as intended (tested with cabal-2.4.0.0)
    • for cabal new-repl it uses a dummy package:
C:\>cabal new-repl
Resolving dependencies...
Build profile: -w ghc-8.6.3 -O1
In order, the following will be built (use -v for more details):
 - fake-package-0 (lib) (first run)
Configuring library for fake-package-0..
Preprocessing library for fake-package-0..
Warning: No exposed modules
GHCi, version 8.6.3: http://www.haskell.org/ghc/  :? for help
Prelude>

The relevant pr adding the feature of global repl in cabal is: haskell/cabal#5454

Maybe the etlas install global part is related to typelead/eta#920

The etlas install outside a project should be fixed with #91. Only left etlas repl

etlas repl should be fixed fixed with #92

@jneira I've built your changes and I'm still getting this:

$ etlas repl
etlas: No targets given and there is no package in the current directory. Use
the target 'all' for all packages in the project or specify packages or
components by name or location. See 'etlas build --help' for more details on
target options.

Mmm, is there some subfolder with config files?, i've tested it in a empty dir and works for me:

D:\dev\lang\eta>mkdir empty

D:\dev\lang\eta>cd empty

D:\dev\lang\eta\empty>etlas repl

Prelude> import Data.Maybe

Prelude Data.Maybe> :t fromJust
fromJust :: Maybe a -> a

Yes, you're right - thanks for catching that! Doing that worked for me as well. I wonder if global repl should be triggered if there's no package description file OR a cabal.project in the current folder.

For example I just ran etlas repl in my home directory which has neither cabal.project or a .cabal file in the current directory, but yet it caused an issue. I found that to be rather counterintuitive.

I get the error when running etlas repl in a dir with subdirectories containing config files:

D:\dev\lang\eta\eta-test-multi>etlas repl
etlas: No targets given and there is no package in the current directory. Use
the target 'all' for all packages in the project or specify packages or
components by name or location. See 'etlas build --help' for more details on
target options.

D:\dev\lang\eta\eta-test-multi>tree
Listado de rutas de carpetas para el volumen DATA
El número de serie del volumen es E2A2-4E65
D:.
├───dist
│   └───cache
├───package1
│   ├───dist
│   │   └───cache
│   └───src
└───package2
    └───src

D:\dev\lang\eta\eta-test-multi>etlas repl package1
Resolving dependencies...
In order, the following will be built (use -v for more details):
 - package1-0.1.0.0 (lib) (first run)
Configuring library for package1-0.1.0.0..
Preprocessing library for package1-0.1.0.0..


╭─── Welcome to Eta REPL v0.8.6b4! ────────────────────────╮
│                                                          │
│ :help for help                                           │
│ :exit to exit                                            │
│ :type [expr] for type of expression                      │
│ :kind [type] for kind of type                            │
│ :kind! [type] for kind of simplified type                │
│                                                          │
│ it refers to the last expression                         │
│                                                          │
│ For more details, check out https://eta-lang.org         │
│                                                          │
╰──────────────────────────────────────────────────────────╯

[1 of 1] Compiling Example

Successful! One module loaded.

*Example> [0m[0m

For example I just ran etlas repl in my home directory which has neither cabal.project or a .cabal file in the current directory, but yet it caused an issue. I found that to be rather counterintuitive.

I think it is caused by the default project config. It actually has:

projectPackagesOptional = [ "./*.cabal", "./*.etlas", "./etlas.dhall"
                                  , "./*/*.cabal", "./*/*.etlas", "./*/etlas.dhall" ]

The ./*/file make any dir with package subdirs an implicit project based directory. Cabal works in a similar way (but only with ./*.cabal, ./*/*.cabal in projectPackages)

Hmm I guess that's OK for now. Being able to pick up packages like that is nice.

Closing this, going forward to make new-clean the default!