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

Implement a command-not-found-like feature #541

Open
cmarqu opened this issue Sep 8, 2024 · 1 comment
Open

Implement a command-not-found-like feature #541

cmarqu opened this issue Sep 8, 2024 · 1 comment

Comments

@cmarqu
Copy link
Contributor

cmarqu commented Sep 8, 2024

Is your feature request related to a problem? Please describe.

It is sometimes not at all easy to find out which module(s) would provide a certain executable.
In Linux distributions, there are tools like command-not-found which suggest which package to install in such a case.

Describe the solution you'd like

It would be nice if I could ask modules which specific module I need to load to get an executable in PATH.

Describe alternatives you've considered

Additional context

A very simplistic implementation would be to loop over all (or latest) modules, load each of them in a subshell, check if the binary is available (using command -v, which), and print the module name if so.

Speeding things up with e.g. parallel processing and/or caching could come later.

@xdelaruelle
Copy link
Member

Many thanks Colin for this suggestion. I have this use case in mind since a bit of time and it is good to see that someone else would like to see this use case covered in Modules.

The Mii tool (https://github.com/codeandkey/mii) implements such feature as an external tool using module command.

I think a find-and-exec sub-command may be added on Modules to cover this use case. It will parse the content of the directories added to PATH in all modulefiles. Cache will help to speed such lookup.

Then, autoinit sub-command may define command_not_found_handle bash/zsh shell function to call module find-and-exec to find executable and run it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants