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

Improve submodule error messages for Github archives #9571

Conversation

Harry-Ramsey
Copy link
Contributor

@Harry-Ramsey Harry-Ramsey commented Sep 17, 2024

This commit improves the error messages informing users that have downloaded Github archives to instead download a release archive. This is due to Github not supporting submodules within archives and no trivial way for users to use git to download them.

Issue: #9538.

PR checklist

Please remove the segment/s on either side of the | symbol as appropriate, and add any relevant link/s to the end of the line.
If the provided content is part of the present PR remove the # symbol.

Notes for the submitter

Please refer to the contributing guidelines, especially the
checklist for PR contributors.

Help make review efficient:

  • Multiple simple commits
    • please structure your PR into a series of small commits, each of which does one thing
  • Avoid force-push
    • please do not force-push to update your PR - just add new commit(s)
  • See our Guidelines for Contributors for more details about the review process.

@Harry-Ramsey Harry-Ramsey force-pushed the improve-submodule-error-messages-development branch from 7b6ef73 to 91f7ce6 Compare September 17, 2024 14:41
@Harry-Ramsey Harry-Ramsey added enhancement needs-review Every commit must be reviewed by at least two team members, needs-reviewer This PR needs someone to pick it up for review size-s Estimated task size: small (~2d) labels Sep 17, 2024
@Harry-Ramsey Harry-Ramsey self-assigned this Sep 17, 2024
CMakeLists.txt Outdated
@@ -301,7 +301,11 @@ if(LIB_INSTALL_DIR)
endif()

if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/framework/CMakeLists.txt")
message(FATAL_ERROR "${CMAKE_CURRENT_SOURCE_DIR}/framework/CMakeLists.txt not found. Run `git submodule update --init` from the source tree to fetch the submodule contents.")
if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git/")
message(FATAL_ERROR "${CMAKE_CURRENT_SOURCE_DIR}/.git/ not found. Please ensure you have downloaded a release version of MBedTLS from Github.")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
message(FATAL_ERROR "${CMAKE_CURRENT_SOURCE_DIR}/.git/ not found. Please ensure you have downloaded a release version of MBedTLS from Github.")
message(FATAL_ERROR "${CMAKE_CURRENT_SOURCE_DIR}/.git/ not found. Please ensure you have downloaded a release version of Mbed TLS from GitHub.")

Copy link
Contributor Author

@Harry-Ramsey Harry-Ramsey Sep 24, 2024

Choose a reason for hiding this comment

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

Thanks, I have fixed this now.

Makefile Outdated
ifeq (,$(wildcard .git))
define error_message
$(MBEDTLS_PATH)/.git/ not found.
Please ensure you have downloaded a release version of MbedTLS from Github.
Copy link
Contributor

Choose a reason for hiding this comment

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

In most of our docs we have Mbed TLS (with a space), might be good to keep it consistent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I have fixed this now.

@eleuzi01 eleuzi01 added needs-backports Backports are missing or are pending review and approval. priority-medium Medium priority - this can be reviewed as time permits labels Sep 24, 2024
@Harry-Ramsey Harry-Ramsey force-pushed the improve-submodule-error-messages-development branch from ef0d38b to 9dbc616 Compare September 24, 2024 14:48
@Harry-Ramsey Harry-Ramsey force-pushed the improve-submodule-error-messages-development branch from 9dbc616 to 4544666 Compare October 4, 2024 12:12
eleuzi01
eleuzi01 previously approved these changes Oct 14, 2024
Copy link
Contributor

@eleuzi01 eleuzi01 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

This commit improves the error messages informing users that have
downloaded Github archives to instead download a release archive. This
is due to Github not supporting submodules within archives and no
trivial way for users to use git to download them.

Signed-off-by: Harry Ramsey <[email protected]>
@Harry-Ramsey Harry-Ramsey force-pushed the improve-submodule-error-messages-development branch from 4544666 to e05cf2e Compare October 18, 2024 07:21
Copy link
Contributor

@davidhorstmann-arm davidhorstmann-arm left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@davidhorstmann-arm davidhorstmann-arm added approved Design and code approved - may be waiting for CI or backports and removed needs-review Every commit must be reviewed by at least two team members, needs-reviewer This PR needs someone to pick it up for review labels Oct 28, 2024
CMakeLists.txt Outdated
@@ -323,7 +323,11 @@ if(LIB_INSTALL_DIR)
endif()

if (NOT EXISTS "${MBEDTLS_FRAMEWORK_DIR}/CMakeLists.txt")
message(FATAL_ERROR "${MBEDTLS_FRAMEWORK_DIR}/CMakeLists.txt not found. Run `git submodule update --init` from the source tree to fetch the submodule contents.")
if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git/")
message(FATAL_ERROR "${CMAKE_CURRENT_SOURCE_DIR}/.git/ not found. Please ensure you have downloaded a release version of Mbed TLS from GitHub.")
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about the ".git not found" part of this error message, from a user's perspective: if I go and download a release tarball, it won't contain a .git subdirectory either, so there seems to be a mismatch between reported problem and suggested solution.

Suggestion: start this message with ""${MBEDTLS_FRAMEWORK_DIR}/CMakeLists.txt not found (and this does not appear to be a git checkout)." - and add "(and this appears to be a git checkout)" to the other one.

Not sure about the 2nd sentence either: most likely this will happen because people have downloaded an archive from github, except they've picked the wrong one. So I think the message should be more precise, like "Please ensure you have downloaded the right archive from the release page on github."

@@ -11,6 +11,19 @@ $(MBEDTLS_PATH)/framework/exported.make not found.
Run `git submodule update --init` to fetch the submodule contents.
This is a fatal error
endef
ifeq (,$(wildcard .git))
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the definition above (lines 9-13) is redundant with the one on lines 21-25. I'd keep only the second one.

@davidhorstmann-arm davidhorstmann-arm dismissed their stale review October 28, 2024 11:28

It appears @mpg has some suggested changes

This commit further improves error message clarity.

Signed-off-by: Harry Ramsey <[email protected]>
eleuzi01
eleuzi01 previously approved these changes Oct 28, 2024
Copy link
Contributor

@eleuzi01 eleuzi01 left a comment

Choose a reason for hiding this comment

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

LGTM, I think it might be a good time to start on the backport

@eleuzi01 eleuzi01 added needs-review Every commit must be reviewed by at least two team members, needs-ci Needs to pass CI tests and removed approved Design and code approved - may be waiting for CI or backports labels Oct 28, 2024
Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for addressing my feedback!

@eleuzi01 eleuzi01 removed the needs-review Every commit must be reviewed by at least two team members, label Oct 29, 2024
@eleuzi01 eleuzi01 added the approved Design and code approved - may be waiting for CI or backports label Oct 29, 2024
@gilles-peskine-arm gilles-peskine-arm removed the needs-ci Needs to pass CI tests label Oct 29, 2024
Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

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

Missed something earlier - only notice while looking at the 3.6 backport.

Makefile Outdated
Run `git submodule update --init` to fetch the submodule contents.
ifeq (,$(wildcard .git))
define error_message
${MBEDTLS_FRAMEWORK_DIR}/CMakeLists.txt not found (and does appear to be a git checkout). Run `git submodule update --init` from the source tree to fetch the submodule contents.
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I failed to noticed earlier: this should be framework/exported.make in order to match what we actually tested above.

@mpg mpg added needs-work and removed approved Design and code approved - may be waiting for CI or backports labels Nov 4, 2024
This commit improves the makefile error message when using make, it no
longer incorrectly reports that CMakeLists.txt cannot be found instead
of exported.make.

Signed-off-by: Harry Ramsey <[email protected]>
@Harry-Ramsey Harry-Ramsey force-pushed the improve-submodule-error-messages-development branch from 51b75a5 to 66ce986 Compare November 4, 2024 11:40
Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

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

Not there yet. I think we should manually test the error messages to make sure they work. I'm not sure what the consequence of trying to use ${MBEDTLS_FRAMEWORK_DIR} would be, but we don't want to find out from user reporting about confusing errors ;)

Makefile Outdated
Run `git submodule update --init` to fetch the submodule contents.
ifeq (,$(wildcard .git))
define error_message
${MBEDTLS_FRAMEWORK_DIR}/exported.make not found (and does appear to be a git checkout). Run `git submodule update --init` from the source tree to fetch the submodule contents.
Copy link
Contributor

Choose a reason for hiding this comment

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

${MBEDTLS_FRAMEWORK_DIR} is a cmake variable, not a make variable. The old message used $(MBEDTLS_PATH)/framework/exported.make which looks right to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hopefully all resolved now, thanks

This commit replaces an undefined variable ${MBEDTLS_FRAMEWORK_DIR} for
${MBEDTLS_PATH}.

Signed-off-by: Harry Ramsey <[email protected]>
Copy link
Contributor

@mpg mpg left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@mpg mpg added needs-review Every commit must be reviewed by at least two team members, and removed needs-work labels Nov 5, 2024
@mpg mpg requested a review from eleuzi01 November 5, 2024 08:35
@mpg
Copy link
Contributor

mpg commented Nov 5, 2024

@Harry-Ramsey A few minor points on PR management:

  • please apply labels on backport PRs too (I've just done it this time)
  • when a PR is linked to an issue that's on a board, the PR shouldn't go on that board too (as we already have the issue there). Instead PRs with priority high or very-high go on "Roadmap pull requests (new board)" and priority medium don't need to go on a board (again, assuming they fix an existing issue that's already on a board).

Copy link
Contributor

@eleuzi01 eleuzi01 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@eleuzi01 eleuzi01 added approved Design and code approved - may be waiting for CI or backports and removed needs-review Every commit must be reviewed by at least two team members, needs-backports Backports are missing or are pending review and approval. labels Nov 5, 2024
@mpg mpg added this pull request to the merge queue Nov 5, 2024
Merged via the queue into Mbed-TLS:development with commit e71f3c3 Nov 5, 2024
6 checks passed
@Harry-Ramsey Harry-Ramsey deleted the improve-submodule-error-messages-development branch November 5, 2024 13:04
define error_message
$(MBEDTLS_PATH)/framework/exported.make not found.
Run `git submodule update --init` to fetch the submodule contents.
ifeq (,$(wildcard .git))
Copy link
Contributor

Choose a reason for hiding this comment

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

Is something wrong with the error message selection? #9809 (comment)

Copy link
Contributor Author

@Harry-Ramsey Harry-Ramsey Dec 9, 2024

Choose a reason for hiding this comment

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

After testing and some initial digging, this seems to be an issue with Make wildcard checks. It appears that they are not useful for checking if a directory exists and instead a different approach will be needed. I shall investigate a bit further in the morning about it.

Copy link
Contributor

Choose a reason for hiding this comment

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

That test looks right for checking whether .git exists in the current directory. But isn't the condition inverted? $(wildcard .git) is empty when .git is missing. Also, do we want .git or $(MBEDTLS_PATH)/.git at this point?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Design and code approved - may be waiting for CI or backports enhancement priority-medium Medium priority - this can be reviewed as time permits size-s Estimated task size: small (~2d)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants