Skip to content

Conversation

@pyrmont
Copy link
Contributor

@pyrmont pyrmont commented Oct 25, 2025

Note

This post has been edited from the original. Comments prior to this comment refer to the earlier version of this post.

This PR changes the error message produced during bundle installation if a bundle directory does not contain a bundle script (i.e. ./bundle.janet or ./bundle/init.janet).

To assist with testing, it also adds a new assert-error-value macro to test/helpers.janet.

Background

If a user attempts to install a bundle that does not contain a bundle script, the bundle/install function can fail with an error message that does not clearly explain that the error is that this file is missing.

The error will occur in get-bundle-module and look like this:


error: could not find module @syspath/bundle/example:
    <syspath>/bundle/example.jimage
    <syspath>/bundle/example.janet
    <syspath>/bundle/example/init.janet
    <syspath>/bundle/example.so
  in require-1 [boot.janet] (tail call) on line 3126, column 20            
  in defer [boot.janet] on line 4200, column 7                             
  in get-bundle-module [boot.janet] on line 4192, column 5
  in edefer [boot.janet] on line 4351, column 19
  in bundle/install [boot.janet] (tail call) on line 4339, column 5
  [...]

Implementation

This PR changes the error message in get-bundle-module to specifically refer to the absence of a bundle script. There are some related clean-ups of the bundle/install logic (notably, initfile is changed to bscript to avoid visual confusion with infofile).

To assist with testing, this PR also adds an assert-error-value macro to test/helpers.janet so that tests can check that the error they are expecting is raised as opposed to a different kind of error.

@sogaiu
Copy link
Contributor

sogaiu commented Oct 26, 2025

I might be misunderstanding, but the original code looks like it went to some trouble to allow the possibility of an optional info file.

I wonder if there is a use for that kind of arrangement.

Guesses anyone?

@sogaiu
Copy link
Contributor

sogaiu commented Oct 26, 2025

Perhaps a minor point but I find infofile-* and initfile-* to be pretty easy to confuse in the context of the code in question.

I wonder if it's worth doing one of:

  • inserting a hyphen (e.g. infofile-* -> info-file-*)
  • removing file (e.g. infofile-src1 -> info-src)
  • truncating file to f (e.g. infofile-src1 -> infof-src1)

or some other helpful thing :)

@pyrmont pyrmont marked this pull request as draft October 27, 2025 00:23
@pyrmont
Copy link
Contributor Author

pyrmont commented Oct 27, 2025

After further review, I realised that it's almost certainly intentional that you can call bundle/install for a bundle that does not include an info file. I've reverted the changes that required this file to exist and instead changed the error message thrown in get-bundle-module to more helpfully explain the problem. I've rewritten the OP to reflect this new version.

@pyrmont pyrmont marked this pull request as ready for review October 27, 2025 00:41
@pyrmont pyrmont changed the title Confirm necessary files during bundle installation Clarify error message for missing bundle script during bundle installation Oct 27, 2025
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