Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Allow `MathCATRulesDir` to override the rules directory without code changes

Open
#771 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
72/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
rust
Domain
build-system, cli

Research direction

Start by reading the rules-directory setup in src/main.rs and tests/common/mod.rs, then inspect how MathCATRulesDir is currently used. Run the test suite with a custom MathCATRulesDir path. Done means the environment variable can provide the rules directory without patching those files, and the installed mathcat binary uses the configured path.

Written by the indexing model from the issue text.

Description

Originally posted by @theCapypara in #749

No, just adding the Cargo.lock is enough for us in that regard. Just tested your PR, builds fine! Thanks!

I just noticed Orca actually vendors MathCAT itself and provides its own Cargo.lock we can use. While I'll use that for Orca, I'll probably still package MathCAT for NixOS as a standalone package, because why not :).

The only other somewhat annoying thing for that is the way that the path to the rules directory is currently somewhat hardcoded and the MathCATRulesDir env variable only being read when a code change is made.

For various reasons we need to provide a custom path to MathCAT.

This requires us to do these patches to make it work:

{
  postPatch = ''
    substituteInPlace src/main.rs \
      --replace-fail 'set_rules_dir(get_rules_dir())' 'set_rules_dir("".to_string())'
    substituteInPlace tests/common/mod.rs \
      --replace-fail 'set_rules_dir(abs_rules_dir_path())' 'set_rules_dir("".to_string())'
  '';

  preCheck = ''
    export MathCATRulesDir="$src/Rules"
  '';

  postInstall = ''
    install -dm755 "$out/rules"
    cp -a ./Rules "$out/rules"
    wrapProgram $out/bin/mathcat --set MathCATRulesDir "$out/rules"
  '';
}
  • The "postPatch" section here replaces set_rules_dir(get_rules_dir()) with set_rules_dir("".to_string()) (and does the same for the tests)
  • In "preCheck" we make sure the tests see the rules
  • In "postInstall" we install the rules and make sure the final mathcat binary actually sees them

Ideally for us, the "postPatch" section would not be needed.

Originally posted by @theCapypara in #749

Dominant language
Rust
Stars
114
Forks
85
Avg merge
1d 12h
Merged PRs (30d)
76

Getting set up

We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from daisy/MathCAT

All issues in daisy/MathCAT

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.