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

stack ghci should be usable with minimal dependencies #817

Closed
rpglover64 opened this issue Aug 18, 2015 · 16 comments
Closed

stack ghci should be usable with minimal dependencies #817

rpglover64 opened this issue Aug 18, 2015 · 16 comments

Comments

@rpglover64
Copy link

After upgrading to the newest version of stack (prompted by @chrisdone in the thread for #665), I ran stack ghci in the turtle project directory. Rather than failing (which was the previous undesirable behavior), it started building the dependencies for the test and bench suites. While this is clearly an improvement, I expect to be able to run ghci without necessarily installing the dependencies for the test and bench suites, and I think that should be the default behavior.

@chrisdone chrisdone self-assigned this Aug 18, 2015
@chrisdone chrisdone added this to the GHCi milestone Aug 18, 2015
@chrisdone
Copy link
Member

Running it with stack ghci turtle:lib loads up just the library. The default behaviour for stack build means "all targets", stack ghci behaves the same, I think this is consistent.

@chrisdone
Copy link
Member

Hm, or it's supposed to. It seems not to be working properly:

chris@ubuntu:~/Repos/turtle$ stack ghci turtle:lib
Configuring GHCi with the following packages: turtle
GHCi, version 7.10.2: http://www.haskell.org/ghc/  :? for help
<command line>: cannot satisfy -package criterion-1.1.0.0
    (use -v for more information)

@chrisdone
Copy link
Member

I made a spin-off issue here: #818

@rpglover64
Copy link
Author

The default behaviour for stack build means "all targets", stack ghci behaves the same, I think this is consistent.

Makes sense. I don't agree with this default, though. (Has it always been this way?) I believe that people will be using stack as package end-users (e.g. for local installs of packages) more than as package developers, so I'd optimize for the former case while keeping the latter case in easy reach.

Here's behavior I'd expect (I don't know how much of it is already implemented but I couldn't find in the documentation, or how much of it is even a good idea):

  • stack build and stack ghci only build the package itself; that is, they default to only the lib target
  • There is more documentation about targets; the section of the FAQ that deals with them doesn't mention anything that suggests turtle:lib as a target
  • There is a command to list available targets for a given package
  • There is a virtual target, e.g. "all", that builds all targets
  • stack build --test, stack test, stack bench, etc. build the targets necessary for them to work
  • stack ghci won't compile the library, then launch ghci to ignore the compiled files and just interpret the sources
  • There's a way to specify the ":lib" part without specifying the "turtle" part; I tried .:lib but that didn't work.

@chrisdone
Copy link
Member

Okay, #818 is fixed.

@chrisdone
Copy link
Member

stack build and stack ghci only build the package itself; that is, they default to only the lib target

Actually, thinking about it, stack build differs in that it does only build executables and libraries at the moment. Then --test and --bench will build benchmarks. We can enable this behaviour for stack ghci. I think that would satisfy you and be consistent with stack build.

There is more documentation about targets; the section of the FAQ that deals with them doesn't mention anything that suggests turtle:lib as a target

There is a command to list available targets for a given package

Agree, but that's separate work from this ticket.

There is a virtual target, e.g. "all", that builds all targets

Not necessary if we implement as above.

@chrisdone
Copy link
Member

There is an ongoing discussion in #815 which will need to be resolved first.

@rpglover64
Copy link
Author

Okay.

Agree, but that's separate work from this ticket.

Is that ticket already opened? Should I open it?

@snoyberg
Copy link
Contributor

This may be relevant for target syntax:
https://github.com/commercialhaskell/stack/wiki/Build-command

On Tue, Aug 18, 2015, 11:44 PM Chris Done notifications@github.com wrote:

stack build and stack ghci only build the package itself; that is, they
default to only the lib target

Actually, thinking about it, stack build differs in that it does only
build executables and libraries at the moment. Then --test and --bench
will build benchmarks. We can enable this behaviour for stack ghci. I
think that would satisfy you and be consistent with stack build.

There is more documentation about targets; the section of the FAQ that
deals with them doesn't mention anything that suggests turtle:lib as a
target

There is a command to list available targets for a given package

Agree, but that's separate work from this ticket.

There is a virtual target, e.g. "all", that builds all targets

Not necessary if we implement as above.


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

@rpglover64
Copy link
Author

@snoyberg That was helpful. There doesn't seem to be a way to do something like stack build :lib, though.

@snoyberg
Copy link
Contributor

Well, no. It could be added, and would be known to only work for the case
of a single package with a library. But is it really a common case to have
that and want to avoid building the executables?

On Tue, Aug 18, 2015, 11:56 PM Alex R notifications@github.com wrote:

@snoyberg https://github.com/snoyberg That was helpful. There doesn't
seem to be a way to do something like stack build :lib, though.


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

@chrisdone
Copy link
Member

Is that ticket already opened? Should I open it?

Not that I know of, feel free to open separate issues for those things!

@chrisdone
Copy link
Member

I'm ambivalent; I think if you're loading up a package source tree into GHCi then you're developing on it and you probably want the test suite ready to go. If you just want to try out a package, like turtle, you can do stack install turtle from the command line and then stack ghci / import Turtle:

chris@ubuntu:~$ stack install turtle
Run from outside a project, using implicit global config
Using resolver: lts-3.1 from global config file: /home/chris/.stack/global/stack.yaml
NOTE: the install command is functionally equivalent to 'build --copy-bins'
turtle-1.2.1: download
turtle-1.2.1: configure
turtle-1.2.1: build
turtle-1.2.1: install
chris@ubuntu:~$ stack ghci
Run from outside a project, using implicit global config
Using resolver: lts-3.1 from global config file: /home/chris/.stack/global/stack.yaml
Configuring GHCi with the following targets: 
GHCi, version 7.10.2: http://www.haskell.org/ghc/  :? for help
Prelude> import Turtle
Prelude Turtle> 

@chrisdone
Copy link
Member

OTOH loading just the lib and exes would be consistent with stack build... until that PR gets merged.

chrisdone added a commit that referenced this issue Aug 18, 2015
Fixes regression caused by adding the build line.
@rpglover64
Copy link
Author

Not so much "want to avoid building executables" as "the package doesn't provide executables"; I feel like even if it's redundant, it's good to have an explicit way to do the default behavior, especially if the default may change.

@borsboom borsboom modified the milestones: GHCi, P2 Sep 12, 2015
@snoyberg
Copy link
Contributor

snoyberg commented Oct 9, 2015

Closing due to lack of activity. Also, it seems like the original issue was resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants