Skip to content

Conversation

@afucher
Copy link
Contributor

@afucher afucher commented Oct 24, 2025

What has changed?

  • Jack-in now auto-fetches the latest nREPL, cider-nrepl, and piggieback versions on first startup (via clojure/deps; falls back to deps.clj), caches them in global state, and falls back to built-in defaults if fetching fails.
    • The fall back to deps.clj is because Calva already have deps.clj.jar, but can be removed. I added because I thought that was a nice quickwin here.
  • User overrides remain the highest priority; effective resolution is: overrides → cached latest → built-in defaults.
  • New module src/nrepl/jack-in-dependency-versions.ts implements fetching, EDN parsing, persistence, and a single-flight refresh to avoid duplicate requests.
  • Added jackInVersionFor helper in project-types and removed direct dependency on raw config for version lookup.
  • Activation now triggers a background refresh of missing versions after deps.clj is downloaded; this is non-blocking for startup.
  • Built-in default versions (used only if needed): nrepl 1.3.1, cider-nrepl 0.55.4, piggieback 0.6.0. (can be defined to be the latest before merge this PR)
  • Backwards compatible: existing pinned versions and workflows continue to work unchanged.

Fixes #2959

My Calva PR Checklist

I have:

  • Read How to Contribute.
  • Directed this pull request at the dev branch. (Or have specific reasons to target some other branch.)
  • Made sure I have changed the PR base branch, so that it is not published. (Sorry for the nagging.)
  • Made sure there is an issue registered with a clear problem statement that this PR addresses, (created the issue if it was not present).
    • Updated the [Unreleased] entry in CHANGELOG.md, linking the issue(s) that the PR is addressing.
  • Figured if anything about the fix warrants tests on Mac/Linux/Windows/Remote/Whatever, and either tested it there if so, or mentioned it in the PR.
  • Added to or updated docs in this branch, if appropriate
  • Tests
    • Tested the particular change
    • Figured if the change might have some side effects and tested those as well.
  • Formatted all JavaScript and TypeScript code that was changed. (use the prettier extension or run npm run prettier-format)
  • Confirmed that there are no linter warnings or errors (use the eslint extension, run npm run eslint before creating your PR, or run npm run eslint-watch to eslint as you go).

@netlify
Copy link

netlify bot commented Oct 24, 2025

Deploy Preview for calva-docs ready!

Name Link
🔨 Latest commit 12ba8ba
🔍 Latest deploy log https://app.netlify.com/projects/calva-docs/deploys/6900b292a2d38d0008c94644
😎 Deploy Preview https://deploy-preview-2960--calva-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

src/extension.ts Outdated
void depsClj
.downloadDepsClj(context.extensionPath)
.finally(() => {
void refreshJackInDependencyVersions();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added here the code to get latest versions, because of the fallback to use deps.clj

const NREPL_VERSION = () => getConfig().jackInDependencyVersions['nrepl'],
CIDER_NREPL_VERSION = () => getConfig().jackInDependencyVersions['cider-nrepl'],
PIGGIEBACK_VERSION = () => getConfig().jackInDependencyVersions['cider/piggieback'];
const jackInVersionFor = (key: JackInDependencyKey) => getEffectiveJackInDependencyVersions()[key];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid get all config, and use directly the function that return the versions

Comment on lines +96 to +113
const depsCljJarPath = getDepsCljJarPath();
if (depsCljJarPath) {
try {
const { stdout } = await execFileAsync('java', ['-jar', depsCljJarPath, ...args]);
const version = parseFindVersionsOutput(stdout);
if (version) {
return version;
}
errors.push(`deps.clj output missing version for ${library}`);
} catch (error) {
errors.push(`deps.clj failed: ${(error as Error).message}`);
}
} else {
errors.push('deps.clj.jar not available');
}

throw new Error(errors.join(' | '));
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since Calva already download deps.clj jar, added this fallback to try to get the versions if the first approach fails.
I don't know if is needed to be honest, adds more complexity and I can't argue if when it fails by any reason using clojure cli, if this will be a good fallback.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is great. So if someone is using Leiningen and do not have clojure they will still be running with latest jack-in dependencies.

Comment on lines 23 to 25
'nrepl': '1.3.1',
'cider-nrepl': '0.55.4',
'cider/piggieback': '0.6.0',
Copy link
Contributor Author

@afucher afucher Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These versions can be bumped to the latest (or any other specific version), before we merge the PR

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which are the latest now? I think we should use latest. And in the changelog we can put the versions used in Calva currently, so that someone who wants to configure those can easily find them.

Copy link
Contributor Author

@afucher afucher Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PEZ the latest are:

cider-nrepl = '0.58.0'
cider/piggieback = '0.6.1'
nrepl = '1.5.1'

in the changelog we can put the versions used in Calva currently

So, do you want to bump the default versions to the latest and add to the changelog which versions? The ones that were before the bump? or the latest?

@PEZ
Copy link
Collaborator

PEZ commented Oct 24, 2025

Thanks! This is so wonderful. And so wonderfully summarized. I will look closer tomorrow, late here now. =)

@PEZ
Copy link
Collaborator

PEZ commented Oct 24, 2025

The build is failing because of formatting btw. You can install the Prettier extension and it will run as a watcher if you are using the Build task. Then code will always be formatted on save.

@afucher afucher marked this pull request as ready for review October 27, 2025 19:32
@PEZ
Copy link
Collaborator

PEZ commented Oct 27, 2025

Thanks. Looks fabulous!

I've suggested an update to the changelog entry.

Only other thing I think we want is that we log the checking to the console, also when things go well. Which versions we find and when global storage is updated. Good when developing on Calva and also for users to check when they report any problems.

We could also log latest versions to Calva says, together with the effective version, and from where the effective versions are decided (like “latest known by Calva”, “user configured override”, "Calva defaults fallback”).

I love the integration tests! ❤️

@afucher
Copy link
Contributor Author

afucher commented Oct 28, 2025

@PEZ added the logs and messages to Calva says
Also, fixed the integration test because it was flaky

@PEZ
Copy link
Collaborator

PEZ commented Oct 28, 2025

Sweet!

@PEZ PEZ merged commit 5489a94 into BetterThanTomorrow:dev Oct 28, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants