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

.mlc.toml options are not used #78

Open
nuke-web3 opened this issue Sep 3, 2023 · 9 comments
Open

.mlc.toml options are not used #78

nuke-web3 opened this issue Sep 3, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@nuke-web3
Copy link

The file is read correctly:

mlc/src/cli.rs

Lines 14 to 20 in 377d20f

let mut opt: OptionalConfig = match fs::read_to_string(CONFIG_FILE_PATH) {
Ok(content) => match toml::from_str(&content) {
Ok(o) => o,
Err(err) => panic!("Invalid TOML file {:?}", err),
},
Err(_) => OptionalConfig::default(),
};

I do get an error as expected with a bad TOML file passed in, but the settings are then not respected by the command. I suspect it's simply overridden by the opt var getting clobbered by nothing passed into the cli ars?

@becheran becheran added the bug Something isn't working label Sep 3, 2023
@becheran
Copy link
Owner

becheran commented Sep 3, 2023

@nukemandan I don't fully understand what you tried to do and what did not work?

You passed an invalid TOML file to mlc? Then the expected behavior would be a panic with no further actions.

You did not pass a TOML file? The expected behavior is to use default config variables if they are not overriden by the CLI args.

@nuke-web3
Copy link
Author

See how I invoke here: https://github.com/Polkadot-Blockchain-Academy/pba-book/blob/3dd5f5e087cf2250fe3a90d0e1722c629fbc3c35/Makefile.toml#L175-L185

When I run without flags set, I would expect https://github.com/Polkadot-Blockchain-Academy/pba-book/blob/main/.mlc.toml to be picked up, but I cannot seem to get the settings working from the config file no matter the variations I try on the command, from the TLD of the repo.

@becheran
Copy link
Owner

@nukemandan that is unexpected. Just coppied your config on my lokal setup and there I don't have the issue. When I set debug to true I get the following (expected) output:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+                                                          +
+            markup link checker - mlc v0.16.2             +
+                                                          +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

19:51:41 [DEBUG] (1) mlc::logger: Initialized logging
19:51:41 [INFO] Config:
Debug: true
Dir: .\
Types: ["Markdown", "Html"]
Offline: false
MatchExt: true
RootDir: ./content/
IgnoreLinks: *slides.md,*slides.html,*twitter.com*,*sec.gov*,*support.giphy.com*,*bitdefender.com*,*etherscan.io*,*cryptoslate.com*,*golden.com*,
IgnorePath: [""]
Throttle: 0 ms

On what system are you trying to execute mlc? Linux? What distro? Could you please run it with --debug and see if there is anything interesting in the logs?

@nuke-web3
Copy link
Author

Here is some output on my end

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+                                                          +
+            markup link checker - mlc v0.16.2             +
+                                                          +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

17:01:43 [DEBUG] (1) mlc::logger: Initialized logging
17:01:43 [INFO] Config:
Debug: true
Dir: ./
Types: ["Markdown", "Html"]
Offline: false
MatchExt: true
RootDir: ./content/
IgnoreLinks: *slides.md,*slides.html,*twitter.com*,*sec.gov*,*support.giphy.com*,*bitdefender.com*,*etherscan.io*,*cryptoslate.com*,*golden.com*,
IgnorePath: [""]
Throttle: 0 ms
17:01:43 [INFO] Search for files of markup types '[Markdown, Html]' in directory '"./"'
17:01:43 [DEBUG] (1) mlc::file_traversal: Found file: MarkupFile { markup_type: Markdown, path: "./content/polkadot/data-sharding/page.md" }.
17:01:43 [DEBUG] (1) mlc::file_traversal: Found file: MarkupFile { markup_type: Markdown, path: "./content/polkadot/data-sharding/slides.md" }.

As you can see, the root dir is ignored, and the current working dir is used. I think that is the real bug here.

@nuke-web3
Copy link
Author

nuke-web3 commented Sep 28, 2023

minimal example of the issue:

# from path with .mlc.toml in it:
# Overwrites the config for IgnoreLinks of the config file. Works as expected, skipping a dead link
mlc --debug content/xcm/config/page.md -i "*slides.html" | tee mlc.log

# Although IgnoreLinks in the debug is correctly set, errors
mlc --debug content/xcm/config/page.md | tee mlc.log
mlc --debug content/xcm/config/page.md | tee mlc.log

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+                                                          +
+            markup link checker - mlc v0.16.2             +
+                                                          +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

22:52:04 [DEBUG] (1) mlc::logger: Initialized logging
22:52:04 [INFO] Config:
Debug: true
Dir: content/xcm/config/page.md
Types: ["Markdown", "Html"]
Offline: false
MatchExt: true
RootDir: ./content/
IgnoreLinks: *slides.md,*slides.html,*twitter.com*,*sec.gov*,*support.giphy.com*,*bitdefender.com*,*etherscan.io*,*cryptoslate.com*,*golden.com*,
IgnorePath: [""]
Throttle: 0 ms
22:52:04 [INFO] Search for files of markup types '[Markdown, Html]' in directory '"content/xcm/config/page.md"'
22:52:04 [DEBUG] (1) mlc::file_traversal: Found file: MarkupFile { markup_type: Markdown, path: "content/xcm/config/page.md" }.
22:52:04 [INFO] Scan file at path 'content/xcm/config/page.md' for links.
22:52:04 [WARN] Strip everything after #. The chapter part '#-how-to-use-revealjs-slides' is not checked.
22:52:04 [DEBUG] (1) mlc::link_validator::file_system: Check file system link target "../../contribute/how-to/page.md#-how-to-use-revealjs-slides"
22:52:04 [DEBUG] (1) mlc::link_validator::file_system: Check file system link target "slides.html"
22:52:04 [WARN] Strip everything after #. The chapter part '#top' is not checked.
22:52:04 [DEBUG] (1) mlc::link_validator::file_system: Check file system link target "#top"
22:52:04 [INFO] Throttle HTTP requests to same host: false
22:52:04 [INFO] Check link /home/nuke/git/book/content/xcm/config/../../contribute/how-to/page.md.
22:52:04 [DEBUG] (1) mlc::link_validator::file_system: Absolute target path Path { inner: "/home/nuke/git/book/content/xcm/config/../../contribute/how-to/page.md" }
22:52:04 [INFO] Check link /home/nuke/git/book/content/xcm/config/.
22:52:04 [DEBUG] (1) mlc::link_validator::file_system: Absolute target path Path { inner: "/home/nuke/git/book/content/xcm/config/" }
22:52:04 [INFO] Check link /home/nuke/git/book/content/xcm/config/slides.html.
22:52:04 [DEBUG] (1) mlc::link_validator::file_system: Absolute target path Path { inner: "/home/nuke/git/book/content/xcm/config/slides.html" }
[ OK ] content/xcm/config/page.md (7, 1) => ../../contribute/how-to/page.md#-how-to-use-revealjs-slides -
[Err ] content/xcm/config/page.md (8, 1) => slides.html - Target filename not found.[ OK ] content/xcm/config/page.md (16, 1) => #top -


Result (3 links):


OK       2
Skipped  0
Warnings 0
Errors   1

The following links could not be resolved:

content/xcm/config/page.md (8, 1) => slides.html

@becheran
Copy link
Owner

becheran commented Oct 7, 2023

@nukemandan reading your comments in the PR #80, can this issue be closed? Do you have a solution for your problem?

@nuke-web3
Copy link
Author

learned the hard way to RTFM 😜 sorry about that!

Sadly no, the last comment details what I still think is a bug. [Err ] content/xcm/config/page.md (8, 1) => slides.html - Target filename not found.[ OK ] content/xcm/config/page.md (16, 1) => #top - here I have explicitly stated to ignore this link in any file, but the error comes up only for the config file, not if set in the cli agrs.

@becheran
Copy link
Owner

@nukemandan I don't really know what the bug is? Can you provide me a minimal working example of what is not working with the toml file, but does work without it?

It is hard for me to reproduce since I don't see any differences once the file is parsed correctley (which you would see in the debug logs). Then the same config struct is used to run the code and it should always produce the same results.

@nuke-web3
Copy link
Author

So here is perhaps one: https://github.com/Cryptorado-Community/cryptorado-rs/pull/4/files#diff-001bc7edd34a2a3d34d6220d949af7ef1f2dd2818303d04c2a7cdab9c708bb7cR8

I want to ignore the output of cargo doc and set target to be explicitly ignored. Yet in any rust project I run with this minimal setting in .mlc.toml in the project root, I have mlc checking the rustdocs built. I can get the right behavior with the CLI flag set mlc --ignore-path target

Any chance you have a rust project with with mlc configured and built rustdocs? See it's it's just me 😭 (thanks for the support btw!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants