fgardt / factorio-scanner

Factorio tools to render and work with blueprint strings, (de)serialize prototype dumps and more
MIT License
13 stars 2 forks source link

Assumptions about mod folder location are wrong on Mac #134

Closed mkfmnn closed 2 months ago

mkfmnn commented 2 months ago

Hi! This seems like a cool project. As far as I understand things, you're writing your own blueprint renderer because you want to be able to support mods, which the other renderers (Teoxoy's and FBSR — are there any others) don't. I like that yours is written in Rust which seems to offer more options for portability.

I tried to get this running on my Mac but first ran into the following error:

 ERROR scanner > setup error
├╴at /Users/miles/Code/factorio-scanner/scanner/src/lib.rs:338:52
│
╰─▶ failed to read file: No such file or directory (os error 2)
    ╰╴at /Users/miles/Code/factorio-scanner/scanner/src/lib.rs:338:52

After a long interlude trying to figure out why location information for the OS error wasn't showing up* and digging into the internals of error_stack and thiserror, I traced the error to this line:

https://github.com/fgardt/factorio-scanner/blob/eada07a0a7c3f553366a9b6c88c522a17757b38f/mod_util/src/mod_list.rs#L194

factorio-scanner assumes that the "data" and "mods" folders are colocated within the same directory, which isn't the case on Mac: https://wiki.factorio.com/Application_directory

I know the instructions say "Download the archive/portable version of factorio for your platform" but there is no such version for Mac.

If you're open to making changes to this package that generalize it a little beyond your current use case (I know you have the Blueprint Radar discord bot, I'm not sure if you have any other plans for it), I can send you a pull request to fix this issue.

fgardt commented 2 months ago

The idea of this repo is to provide the rendering functionality as a standalone CLI tool so please feel free to open a PR to fix this!

You did compile it yourself from the current main branch state right? The last release I did is quite old now.

fgardt commented 2 months ago

I think the best way to go about this is to change the call that generates the ModList from generate to generate_custom here: https://github.com/fgardt/factorio-scanner/blob/7c40c5b70a97f03c93a3e0a47fc1fa607bd3984a/scanner/src/lib.rs#L338

You'd also need to change the targeted folder for downloading missing mods here: https://github.com/fgardt/factorio-scanner/blob/7c40c5b70a97f03c93a3e0a47fc1fa607bd3984a/scanner/src/lib.rs#L374

Providing the correct path to these 2 spots should do the trick I think.