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

nREPL server #412

Closed
chrisrink10 opened this issue Jul 28, 2019 · 2 comments
Closed

nREPL server #412

chrisrink10 opened this issue Jul 28, 2019 · 2 comments
Labels
component:contrib.nrepl-server Issues pertaining the nREPL server contrib module issue-type:enhancement New feature or request

Comments

@chrisrink10
Copy link
Member

Basilisp should have an nREPL server implementation so it can be used with Emacs.

@chrisrink10 chrisrink10 added issue-type:enhancement New feature or request component:repl Issue pertaining to Basilisp REPL (not nREPL) labels Jul 28, 2019
@chrisrink10
Copy link
Member Author

May possibly rely on #408

@chrisrink10 chrisrink10 added this to the Release v0.1.dev15 milestone Jun 18, 2020
@chrisrink10 chrisrink10 removed this from the Release v0.1.dev15 milestone Dec 24, 2020
chrisrink10 added a commit that referenced this issue Dec 28, 2023
chrisrink10 added a commit that referenced this issue Dec 28, 2023
Hi,

could you please review patch to port
[nbb](https://github.com/babashka/nbb)'s build in nrepl-server to
basilisp contrib. It addresses #412.

`nbb` has the same EPL-1.0 license as `basilisp` so I believe using its
code as the base for this PR should not cause licensing issues.

The nbb `bencode` module which is a dependency was ported as well.
Extensive tests were written for both.

The server has been tested to work with both
[CIDER](https://github.com/clojure-emacs/cider) and
[Calva](https://github.com/BetterThanTomorrow/calva) in VS-Code.

The server can be invoked with `baslisp nrepl-server`:
```
$ poetry run basilisp nrepl-server -h
usage: basilisp.cmd nrepl-server [-h] [--host HOST] [--port PORT] [--port-filepath PORT_FILEPATH]

Start the nREPL server.

optional arguments:
  -h, --help            show this help message and exit
  --host HOST           the interface address to bind to, defaults to 127.0.0.1.
  --port PORT           the port to connect to, defaults to 0 (random available port).
  --port-filepath PORT_FILEPATH
                        the file path where the server port number is output to, defaults to ".nrepl-port".
```

Several fixes were required to make it work, which are included as
separate commits in this PR prior to the main bencode and nrepl-server
commits. They address the following issues

- ~~Fixed issue with sort-* fns returning an error on empty seqs
(#716)~~
- Fix issue with `ns` being unavail after `in-ns` during `eval` (#718)
- Fixed issue with import modules aliasing using ns eval (#719)
- Fixed issue with `ns-resolve` throwing error on macros (#720)

support for the `basilisp.stacktrace/print-cause-trace` is also added
because it is requested by CIDER when an exception is thrown to show to
the user, which is essential, it partially addresses #721.

In addition, two issues were observed while running the tests in CI
- ~~The 1.6.0 was released few days ago and complains for an additional
type error in the generator, which is now ignored with this patch~~

``` 
Traceback (most recent call last):
#...
py311-mypy: commands[0]> mypy --config-file=C:\src\basilisp/pyproject.toml -p basilisp
src\basilisp\lang\compiler\generator.py:3530: error: Argument 1 to "fields" has incompatible type "type[IType]"; expected an attrs class  [misc]
src\basilisp\lang\compiler\generator.py:3530: note: Error code "misc" not covered by "type: ignore" comment
``` 

- The nrepl-server tests which are using threads were failing due to
trying to release an rlock which has been already released whose essence
is captured in #722, and is fixed with this patch as described in the
ticket by using `with self._lock.gen_rlock()` instead of a single
instance of `with self._rlock()`. The error was
```
    File "/home/runner/work/basilisp/basilisp/.tox/py39/lib/python3.9/site-packages/basilisp/lang/runtime.py", line 706, in find
    return v
   File "/home/runner/work/basilisp/basilisp/.tox/py39/lib/python3.9/site-packages/readerwriterlock/rwlock.py", line 49, in __exit__
    self.release()
   File "/home/runner/work/basilisp/basilisp/.tox/py39/lib/python3.9/site-packages/readerwriterlock/rwlock.py", line 344, in release
    if not self.v_locked: raise RELEASE_ERR_CLS(RELEASE_ERR_MSG)
 RuntimeError: release unlocked lock
```

I understand this could be a lot to go through and there likely to be
multiple iterations while I update the code with your feedback, of which
I'm looking forward to.

I have not written a nrepl-server section for the manual yet. I plan to
do this after a successful review, and will also update the changelog.

Thanks

---------

Co-authored-by: ikappaki <[email protected]>
Co-authored-by: Chris Rink <[email protected]>
@chrisrink10
Copy link
Member Author

Completed in #723

@chrisrink10 chrisrink10 added component:contrib.nrepl-server Issues pertaining the nREPL server contrib module and removed component:repl Issue pertaining to Basilisp REPL (not nREPL) labels Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:contrib.nrepl-server Issues pertaining the nREPL server contrib module issue-type:enhancement New feature or request
Projects
Development

No branches or pull requests

1 participant