Skip to content

Conversation

@FGasper
Copy link

@FGasper FGasper commented Sep 10, 2025

No description provided.

@FGasper FGasper requested a review from a team as a code owner September 10, 2025 18:06
arch=arm64
esac

urls=$(curl -fsSL https://api.github.com/repos/mongodb-js/mongosh/releases/latest | jq -r '.assets[] | .browser_download_url' | grep -v -e \.sig -e shared -e openssl)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's use https://downloads.mongodb.com/compass/mongosh.json for this rather than GH

Copy link
Author

Choose a reason for hiding this comment

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

Definitely better, yes. Adjusted jq query accordingly.

@FGasper FGasper requested a review from addaleax September 11, 2025 13:00
Copy link
Collaborator

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

I don't know if we need to have some sort of triage conversation in the team here, we don't typically add this type of feature on a very ad-hoc basis but this does make sense to me to add in general


curl -fsSL "$url" | tar -xzf - \
--transform "s/.*\///" \
--wildcards "**/mongosh"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We'd probably want mongosh_crypt_v1.so to be extracted next to mongosh

Copy link
Author

Choose a reason for hiding this comment

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

I should maybe know this, but: why so? What breaks if it’s not there? (It worked for me without.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Automatic encryption for Queryable Encryption & CSFLE don't – not everybody cares about those, but I don't think we'd like to ship "partially broken" versions of mongosh if we don't need to

Copy link
Author

Choose a reason for hiding this comment

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

OK, the script now downloads both the executable and the shared library.

FGasper and others added 2 commits September 11, 2025 10:46
Co-authored-by: Anna Henningsen <github@addaleax.net>
Co-authored-by: Anna Henningsen <github@addaleax.net>
@FGasper
Copy link
Author

FGasper commented Sep 11, 2025

@addaleax Triage: by all means. I just wanted to PoC the idea to get the ball rolling.

@addaleax addaleax changed the title Add a download script to facilitate easy use in CI. feat: add a download script to facilitate easy use in CI MONGOSH-2687 Sep 11, 2025
@FGasper FGasper requested a review from addaleax September 12, 2025 13:33
esac

jq_query=$(cat <<EOF
.versions[0].downloads[] |
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can't really do a semver comparison here, right? Otherwise I think that would be highly preferable.

If we leave this as-is, I'd leave a comment in

currentVersions.sort((a, b) => semver.rcompare(a.version, b.version));
about this script depending on that specific ordering

select(
.distro == "$os" and
.arch == "$arch" and
(has("sharedOpenssl") | not)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Generally the sharedOpenssl versions are mildly preferable – we could test for the presence on the current system through e.g. ldd $(which curl) | grep -q libssl.so.3?

Copy link
Author

Choose a reason for hiding this comment

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

Are they preferable because we want updates from system library maintenance?

I get antsy testing for anything OpenSSL-related. macOS’s default curl actually uses SecureTransport, so I’m not sure testing curl is the best approach.

Does mongosh always require OpenSSL?

Copy link
Author

Choose a reason for hiding this comment

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

Would it maybe suffice merely to output a sufficiently-loud warning in the console that the downloaded mongosh uses a static OpenSSL & thus is only recommended for short-term usage?

zip)
file=$(mktemp)

echo "Downloading $url to $file"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would keep using >&2 like above for all diagnostic information

Copy link
Author

Choose a reason for hiding this comment

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

fixed

exit 1
esac

echo "✅ Success! 'mongosh' and its crypto library are now saved in this directory."
Copy link
Collaborator

Choose a reason for hiding this comment

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

(including this line)

Copy link
Author

Choose a reason for hiding this comment

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

fixed

[installation documentation](https://www.mongodb.com/docs/mongodb-shell/install#mdb-shell-install).

You can also run `download_latest.sh` to download a `mongosh` binary. You can use
this script without cloning the repository thus:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd mention npx mongosh here, since that's probably easier for most people who don't truly need a local installation

Copy link
Author

Choose a reason for hiding this comment

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

I pushed something … it may not be the best verbiage.

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