commercialhaskell / commercialhaskell/stack

Extend `stack script --package` to local packages

Open
#5,146 1 comment 0 reactions 0 assignees View on GitHub
component: script type: enhancement
Dominant language
Haskell
Stars
4.1k
Forks
850
Avg merge
10h 37m
Merged PRs (30d)
4

Description

### General summary/comments (optional)

I'd like to write a script using the stack shebang which imports some modules from my tests. (I have some setup code in my tests to do things like set up fixtures, and it would be convenient to be able to spin up the fixtures independently of tests using scripts for manual work.) However, it seems to be impossible to add a `--package` flag that works for this.

### Steps to reproduce

For example:

1. `git clone https://github.com/thomasjm/shebang-with-tests.git`
2. `cd shebang-with-tests`
3. `./script.hs`

### Expected

I would expect to see what the script tries to print:

```
Running the script!
foo
```

### Actual

The script seems to run the main function of the test suite. In this case, it prints the following:

```
Test suite not yet implemented
```

(It may also say `Could not find package id of package shebang-with-tests:test`. Not sure what that's about, it didn't happen in my original situation.)

### Stack version

```
$ stack --version
Version 2.1.3, Git revision 636e3a759d51127df2b62f90772def126cdf6d1f (7735 commits) x86_64 hpack-0.31.2
```

### Method of installation

* Official binary, downloaded from stackage.org or fpcomplete's package repository

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the behavior with the linked shebang-with-tests example and the `stack script --package` command. Read the Stack CLI implementation for script package handling and the local test-package setup; done means a script can import modules from a local test package and prints `Running the script!` followed by `foo` instead of running the test-suite main function.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system, cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.