2024-05-01 20:21:51 +03:00
# Developer FAQ
This is just getting started. It will absorb some of the other [Developer docs ](dev.md ).
2024-05-02 08:05:27 +03:00
<!-- toc -->
2024-05-02 02:50:36 +03:00
<!-- ## Developing hledger -->
2024-05-01 20:21:51 +03:00
2024-05-23 02:06:08 +03:00
## How do I get/build the hledger source ?
2024-05-01 20:21:51 +03:00
```cli
$ git clone https://github.com/simonmichael/hledger
$ stack build
```
You can specify `hledger` , `hledger-ui` or `hledger-web` as an argument to build just that executable.
Please see [Install > Build from source ](install.md#build-from-source ) for more details and other build methods.
2024-05-23 02:06:08 +03:00
## What other repos are there ?
2024-05-01 20:21:51 +03:00
There are three official repos:
- < https: // github . com / simonmichael / hledger > - the main hledger repo, for hledger, hledger-ui and hledger-web. Shortcut url: < https: // code . hledger . org >
- < https: // github . com / simonmichael / hledger_site > - the hledger.org website
- < https: // github . com / simonmichael / hledger_finance > - the hledger project's financial ledger
And third-party add-ons and tools (hledger-iadd, hledger-utils, full fledged hledger, hledger-flow, etc.) have their own repos.
2024-05-23 02:06:08 +03:00
## How do I run a build in place ?
2024-05-01 20:21:51 +03:00
After building with stack,
```cli
$ stack exec -- hledger [ARGS] # or hledger-ui, hledger-web
```
Or after building with cabal,
```cli
$ cabal exec -- hledger [ARGS]
```
2024-05-23 02:06:08 +03:00
## How do I install a build in PATH ?
2024-05-01 20:21:51 +03:00
```cli
$ stack install
```
This installs the hledger executables to `~/.local/bin` . You should have this directory configured in $PATH.
Or you can install to another directory with `--local-bin-path` .
It builds the executables first if needed; see [Install > Build from source ](install.md#build-from-source ) for more about building.
You can specify `hledger` , `hledger-ui` or `hledger-web` as an argument to build/install just that executable.
If you use cabal, it has a similar command; the argument is required.
It will install executables to `~/.cabal/bin` :
```cli
$ cabal install all:exes
```
2024-05-02 02:47:02 +03:00
2024-05-23 02:06:08 +03:00
## How do I build/run with ghc-debug support ?
2024-05-02 02:47:02 +03:00
2024-05-02 05:21:24 +03:00
You might need to stop background builders like HLS, to avoid a fight over the build flag
(in VS Code, run the command "Haskell: Stop Haskell LSP server").
2024-05-02 05:36:25 +03:00
2024-05-02 05:21:24 +03:00
Then build lib and executable(s) with the `ghcdebug` flag:
2024-05-02 02:47:02 +03:00
```cli
2024-05-02 11:46:09 +03:00
$ stack build --flag='*:ghcdebug'
2024-05-02 02:47:02 +03:00
```
2024-05-02 04:27:42 +03:00
2024-05-02 05:21:24 +03:00
When the build is right, --version should mention ghc-debug:
2024-05-02 02:47:02 +03:00
```
$ stack exec -- hledger --version
2024-05-02 05:21:24 +03:00
... with ghc debug support
2024-05-02 02:47:02 +03:00
```
2024-05-02 04:27:42 +03:00
2024-05-02 05:36:25 +03:00
And when you run at debug level -1, -2 or -3 the output should mention ghc-debug:
2024-05-02 02:47:02 +03:00
```cli
2024-05-02 05:21:24 +03:00
$ hledger CMD --debug=-1 # run normally, and listen for ghc-debug commands
2024-05-02 06:39:33 +03:00
$ hledger CMD --debug=-2 # pause for ghc-debug commands at program start (doesn't work)
$ hledger CMD --debug=-3 # pause for ghc-debug commands at program end (doesn't work)
2024-05-02 05:21:24 +03:00
Starting ghc-debug on socket: ...
2024-05-02 02:47:02 +03:00
```
2024-05-02 04:27:42 +03:00
2024-05-02 06:39:33 +03:00
Now in another window, you can run [ghc-debug-brick ](https://hackage.haskell.org/package/ghc-debug-brick ) and it will show the hledger process (until it ends). Press enter to connect. If it fails,
2024-05-02 05:21:24 +03:00
- you might need to clear out stale sockets: `rm -f ~/.local/share/ghc-debug/debuggee/sockets/*`
- you might need to kill stale hledger processes: `pkill -fl hledger`
2024-05-02 06:39:33 +03:00
- with --debug=-2 or -3 it fails with `rts_resume: called from a different OS thread than rts_pause` ,
so use --debug=-1 instead. This works best with the long-running hledger-ui or hledger-web;
with hledger, you'll need a big enough data file so that you have time to connect before it finishes.
Once connected, press `p` to pause the program.
2024-05-02 05:21:24 +03:00
At this point, you can explore memory/profile information, save snapshots, resume execution, etc.
Or, instead of ghc-debug-brick you can write a [ghc-debug-client ](https://hackage.haskell.org/package/ghc-debug-client ) script to extract specific information.