Skip to content

Features extending instance hooks #952

Closed
Closed

Description

@PixelBedrock

Is your suggested enhancement related to a problem? Please describe.

Modrinth doesn't give any documentation towards the hooks for instances. My test script fails with error code 2 with zero logging from within the Modrinth app itself, except for the toast telling me it failed with error code 2.

Describe the solution you'd like

Some documentation towards the hooks and environment variables (or command line args) provided by Modrinth for the instance to use. I have provided some example images from MultiMC for reference towards what I would like to be added to Modrinth.

image

image

Describe alternatives you've considered

I have attempted to create a script that tells me what environment variables and command line arguments are available, but fails with error code 2 with zero explanation from the Modrinth app. The script works perfectly fine outside of Modrinth, but refuses to run and exits with error code 2 when used as a hook.

Additional context

N/A, all screenshots and context have been included above.

Activity

  1. changed the title [-]Features towards extending instance hooks[/-] [+]Features extending instance hooks[/+] on Dec 21, 2023
  2. EchoEllet commented on Jun 24, 2024

    @EchoEllet

    That's usually because those environment variables might not be supported yet or have a different name than the other launchers.

  3. Prospector commented on Jun 24, 2024

    @Prospector
    Member

    I believe the hooks in the Modrinth App currently don't support any variables, they're basically just triggers for running commands. They probably can be made more powerful in the future

  4. EchoEllet commented on Jul 6, 2024

    @EchoEllet

    It seems that this feature request is already in the TODO list in code:

    if let Some(hook) = pre_launch_hooks {
    // TODO: hook parameters
    let mut cmd = hook.split(' ');
    if let Some(command) = cmd.next() {
    let full_path = path.get_full_path().await?;
    let result = Command::new(command)
    .args(&cmd.collect::<Vec<&str>>())
    .current_dir(&full_path)
    .spawn()
    .map_err(|e| IOError::with_path(e, &full_path))?
    .wait()
    .await
    .map_err(IOError::from)?;
    if !result.success() {
    return Err(crate::ErrorKind::LauncherError(format!(
    "Non-zero exit code for pre-launch hook: {}",
    result.code().unwrap_or(-1)
    ))
    .as_error());
    }
    }
    }

  5. added a commit that references this issue on Oct 16, 2024
  6. Prospector commented on Aug 18, 2026

    @Prospector
    Member

    these were added in #5916

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    appRelates to Modrinth App

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions