Fork me on GitHub
#cider
<
2023-10-27
>
john2x03:10:35

I'm having trouble getting my CIDER REPL session to work with AWS credentials (I'm using the Cognitect AWS API library). For context, I'm using AWS SSO and don't want to use API keys. I found this old https://github.com/cognitect-labs/aws-api/issues/182 about AWS SSO not supported by the Cognitect library. I'm now trying to use aws-vault which has a --server option which basically emulates the EC2 metadata http endpoint for fetching tokens locally. But this method only seems to works in the shell session where it was launched, so my CIDER REPL isn't able to use it. Any suggestions?

john2x03:10:50

Hmm I could perhaps start the REPL in the shell session and jack into that from CIDER

vemv03:10:23

Yes, staring a cider/nrepl server from your terminal and cider-connect ing later would seem simplest

john2x03:10:22

sweet that seems to work. Not ideal, kinda liked jack-in, but it'll do for now

vemv03:10:15

Perhaps you'll get to appreciate it ๐Ÿ˜ I favor it (maybe 80-20% vs jack in) as it survives emacs crashes

john2x03:10:43

That's a good point ๐Ÿ™‚

jumar09:10:07

Exactly this (well, I do it more than 80%) > I favor it (maybe 80-20% vs jack in) as it survives emacs crashes

oyakushev09:10:26

@U050S5ZET There is another way. The default credentials provider also looks at these system properties:

aws.accessKeyId
aws.secretKey
aws.sessionToken
You can set those within the REPL, taking the values from the respective env variables in a shell that is logged in:
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_SESSION_TOKEN
I like this approach better because my AWS session is short-lived, and I hate to restart the REPL just to refresh the credentials. To facilitate this approach I wrote a couple of helper scripts and functions for myself, it's too specific to share but I'm sure you can do something similar if you want to go this way.

oyakushev09:10:00

One caveat: credentials provider checks system properties after env variables, so you have to make sure that the REPL process is started where those envs are NOT set, otherwise the properties will be ignored.

hifumi12318:10:15

Is it possible to remove the new syntax highlighting on protocols inside deftype forms? Not sure if this is a CIDER or clojure-mode issue

vemv18:10:21

mind to share a screenshot? we haven't changed that area

vemv18:10:03

also, please M-x describe-char to provide diagnostic info

hifumi12319:10:22

and IAtom in particular has the face of font-lock-variable-face

vemv19:10:56

that's cljs, right?

hifumi12319:10:11

This is CIDER 1.8.4-snapshot, no idea on the exact commit but I will look for it soon

vemv19:10:12

what's your cider-font-lock-dynamically value?

hifumi12319:10:08

(macro core deprecated)

vemv19:10:20

I can repro. The logic responsible for this is (and do-var (not is-function) (not is-macro)) in cider-mode.el That do-var is truthy should not happen given your custom cider-font-lock-dynamically . Do you set it in a funny way? I set it via custom-set-variables in init.el before CIDER is started

vemv19:10:19

I hint this b/c we have this logic

(let ((cider-font-lock-dynamically (if (eq cider-font-lock-dynamically t)
                                       '(function var macro core deprecated)
                                     cider-font-lock-dynamically)))
  ...)
so make sure it's not t at any point. Try debugging to confirm

hifumi12319:10:40

The way I have CIDER (and clojure-mode) set up is with straight.el and use-package like so

(use-package cider
  :commands cider-jack-in
  :config 
  (setq cider-use-tooltips    nil
        cider-lein-parameters "with-profile +dev repl :headless :host localhost"))

hifumi12319:10:49

So I want to believe most of CIDER is in its default configuration

vemv19:10:55

Right, '(macro core deprecated) is the default value

hifumi12319:10:42

For what itโ€™s worth, CIDER 1.7.0 release does not have this problem. Unfortunately, that does not help us bisect the bug much ๐Ÿ˜„

hifumi12319:10:01

I am going to try looking at syntax highlighting by progressively updating versions of CIDER from 1.7.0 and let you know when I first see the change

vemv19:10:43

Oh please don't bother :)

vemv19:10:13

We'll refined cljs a lot. In fact I can confidently state that a few things worked by chance, others were plain broken A side-effect is that if you were very used to this or that aspect, now it may be different

vemv20:10:08

Truth be told the 'bug' seems a feature to me. Which doesn't mean we can't investigate it At *nrepl-messages* level, you'll see a changed-namespaces property with IAtom in it Its value is: (dict doc "\"Marker protocol indicating an atom.\"") It lacks fn "true" or macro "true" indicators. Which seems correct for a defprotocol

hifumi12320:10:35

yeah, I was used to the protocols simply not having any highlighting, but now that only happens to Object (at least in the case of CLJS)

vemv20:10:08

probably because Object is not a var

vemv20:10:58

I'll give it a 10-20m debugging session, else chances are I'll have to give up, it's a comparatively minor problem. Let's see!

hifumi12320:10:45

No need. I understand that supporting the case of Object is tricky since this is CLJS-specific. IIRC JVM Clojure has its own way to add custom methods to a type, but itโ€™s probably using a different symbol

vemv20:10:08

yeah I don't mind about Object, I was talking about OP

vemv20:10:43

Debugged โœ… and, as suspected, nothing was really broken... rather, things are starting to look as intended This section is the responsible for the behavior you're seeing https://github.com/clojure-emacs/cider/blob/6baa3c3f315f1dc822d39a90dd5840386f97e954/cider-mode.el#L809-L811 The rationale, I guess, is that core means all of clj/s core, no exceptions. Users in principle don't get a say as to what belongs to core . You are free to remove core from cider-font-lock-dynamically - it's a defcustom ๐Ÿ™‚

hifumi12320:10:02

Thanks!

๐Ÿ™Œ 1