redruin1 / factorio-draftsman

A complete, well-tested, and up-to-date module to manipulate Factorio blueprint strings. Compatible with mods.
MIT License
94 stars 17 forks source link

draftsman.error.MissingModError: ExplosiveExcavation #49

Closed theunkn0wn1 closed 2 years ago

theunkn0wn1 commented 2 years ago

Factorio Version 1.1.65 (build 59990, linux64) Modpack: Seablock

Actions taken:

created virtual environment in project path .venv and installed factorio-draftsman. sourced venv source .venv/bin/activate Set draftstman factorio-mods folder to be a symlink to factorio install

~/projects/cractorio ⌚ 15:59:37
$ cd .venv/lib/python3.8/site-packages/draftsman/                                
(.venv) 
~/projects/cractorio/.venv/lib/python3.8/site-packages/draftsman ⌚ 16:03:32
$ ls
blueprintable.py  constants.py  env.py         factorio-mods         prototypes     tile.py      warning.py
classes           data          error.py       _factorio_version.py  __pycache__    utils.py
compatibility     entity.py     factorio-data  __init__.py           signatures.py  _version.py
(.venv) 
~/projects/cractorio/.venv/lib/python3.8/site-packages/draftsman ⌚ 16:03:42
$ ln -s ~/.factorio/mods factorio-mods

Verified path resolves and contains the offending mod:

~/projects/cractorio ⌚ 16:04:35
$ ls -l .venv/lib/python3.8/site-packages/draftsman/factorio-mods/ | grep -i expl
-rw-r--r-- 1 orion orion     65024 Dec 26  2020 Explosive Excavation_1.1.8.zip

Attempted draftsman-update from within the venv:

~/projects/cractorio ⌚ 16:05:17
$ draftsman-update --verbose
Reading mods from: /home/orion/projects/cractorio/.venv/lib/python3.8/site-packages/draftsman/factorio-mods

Discovering mods...

ScienceCostTweakerM
boblogistics
WARNING: Duplicate of mod 'boblogistics' found (1.1.2)
    Skipping older version (1.1.2) in favor of newer version (1.1.3)
SeaBlockMetaPack
reskins-library
angelsrefining
underground-pipe-pack
KS_Power
bobwarfare
miniloader
Explosive Excavation
bobplates
WARNING: Duplicate of mod 'bobplates' found (1.1.3)
    Overwriting older version (1.1.2) with newer version (1.1.3)
bobmining
angelsbioprocessing
bobenemies
angelspetrochem
reskins-bobs
flib
Squeak Through
WARNING: Duplicate of mod 'flib' found (0.9.2)
    Skipping older version (0.9.2) in favor of newer version (0.10.1)
WARNING: Duplicate of mod 'bobplates' found (1.1.5)
    Overwriting older version (1.1.3) with newer version (1.1.5)
LtnManager
bobelectronics
bobinserters
AutoDeconstruct
WARNING: Duplicate of mod 'bobwarfare' found (1.1.5)
    Overwriting older version (1.1.3) with newer version (1.1.5)
LogisticTrainNetwork
angelsaddons-storage
bobrevamp
WARNING: Duplicate of mod 'angelsaddons-storage' found (0.0.9)
    Overwriting older version (0.0.4) with newer version (0.0.9)
PickerAtheneum
bobores
SeaBlock
WARNING: Duplicate of mod 'LogisticTrainNetwork' found (1.15.0)
    Skipping older version (1.15.0) in favor of newer version (1.16.7)
factoryplanner
WARNING: Duplicate of mod 'angelspetrochem' found (0.9.17)
    Skipping older version (0.9.17) in favor of newer version (0.9.21)
WARNING: Duplicate of mod 'SeaBlockMetaPack' found (1.1.1)
    Skipping older version (1.1.1) in favor of newer version (1.1.3)
boblibrary
bobequipment
bobassembly
WARNING: Duplicate of mod 'angelsbioprocessing' found (0.7.21)
    Skipping older version (0.7.21) in favor of newer version (0.7.22)
WARNING: Duplicate of mod 'SeaBlock' found (0.5.10)
    Skipping older version (0.5.10) in favor of newer version (0.5.11)
bobtech
railloader
WARNING: Duplicate of mod 'angelsrefining' found (0.11.19)
    Skipping older version (0.11.19) in favor of newer version (0.12.1)
PickerPipeTools
WARNING: Duplicate of mod 'bobores' found (1.1.0)
    Skipping older version (1.1.0) in favor of newer version (1.1.5)
WARNING: Duplicate of mod 'flib' found (0.6.0)
    Skipping older version (0.6.0) in favor of newer version (0.10.1)
WARNING: Duplicate of mod 'underground-pipe-pack' found (1.1.0)
    Skipping older version (1.1.0) in favor of newer version (1.1.2)
WARNING: Duplicate of mod 'ScienceCostTweakerM' found (1.1.10)
    Overwriting older version (1.1.2) with newer version (1.1.10)
WARNING: Duplicate of mod 'angelspetrochem' found (0.9.22)
    Overwriting older version (0.9.21) with newer version (0.9.22)
WARNING: Duplicate of mod 'boblogistics' found (1.1.5)
    Overwriting older version (1.1.3) with newer version (1.1.5)
FNEI
WARNING: Duplicate of mod 'bobores' found (1.1.3)
    Skipping older version (1.1.3) in favor of newer version (1.1.5)
WARNING: Duplicate of mod 'bobtech' found (1.1.2)
    Skipping older version (1.1.2) in favor of newer version (1.1.5)
bobpower
SpaceMod
WARNING: Duplicate of mod 'bobpower' found (1.1.1)
    Skipping older version (1.1.1) in favor of newer version (1.1.3)
WARNING: Duplicate of mod 'SpaceMod' found (1.1.1)
    Overwriting older version (1.1.0) with newer version (1.1.1)
Factorissimo2
WARNING: Duplicate of mod 'SeaBlock' found (0.5.1)
    Skipping older version (0.5.1) in favor of newer version (0.5.11)
angelssmelting
WARNING: Duplicate of mod 'boblibrary' found (1.1.5)
    Overwriting older version (1.1.4) with newer version (1.1.5)
WARNING: Duplicate of mod 'bobelectronics' found (1.1.5)
    Overwriting older version (1.1.2) with newer version (1.1.5)
WARNING: Duplicate of mod 'bobelectronics' found (1.1.3)
    Skipping older version (1.1.3) in favor of newer version (1.1.5)
WARNING: Duplicate of mod 'angelsrefining' found (0.12.2)
    Overwriting older version (0.12.1) with newer version (0.12.2)
WARNING: Duplicate of mod 'bobassembly' found (1.1.5)
    Overwriting older version (1.1.3) with newer version (1.1.5)
WARNING: Duplicate of mod 'LogisticTrainNetwork' found (1.16.10)
    Overwriting older version (1.16.7) with newer version (1.16.10)
CircuitProcessing
WARNING: Duplicate of mod 'bobrevamp' found (1.1.5)
    Overwriting older version (1.1.3) with newer version (1.1.5)
reskins-angels
WARNING: Duplicate of mod 'angelssmelting' found (0.6.19)
    Overwriting older version (0.6.18) with newer version (0.6.19)
train-log
reskins-compatibility
WARNING: Duplicate of mod 'bobassembly' found (1.1.2)
    Skipping older version (1.1.2) in favor of newer version (1.1.5)
ltn-cleanup
bobmodules
WARNING: Duplicate of mod 'CircuitProcessing' found (0.4.4)
    Overwriting older version (0.4.0) with newer version (0.4.4)
WARNING: Duplicate of mod 'angelssmelting' found (0.6.14)
    Skipping older version (0.6.14) in favor of newer version (0.6.19)
WARNING: Duplicate of mod 'bobrevamp' found (1.1.2)
    Skipping older version (1.1.2) in favor of newer version (1.1.5)
WARNING: Duplicate of mod 'bobpower' found (1.1.5)
    Overwriting older version (1.1.3) with newer version (1.1.5)
WARNING: Duplicate of mod 'angelsaddons-storage' found (0.0.8)
    Skipping older version (0.0.8) in favor of newer version (0.0.9)
LandfillPainting
stdlib
helmod
TogglePeacefulMode
WARNING: Duplicate of mod 'boblibrary' found (1.1.2)
    Skipping older version (1.1.2) in favor of newer version (1.1.5)
WARNING: Duplicate of mod 'Factorissimo2' found (2.5.3)
    Overwriting older version (2.5.1) with newer version (2.5.3)
WARNING: Duplicate of mod 'FNEI' found (0.4.1)
    Overwriting older version (0.4.0) with newer version (0.4.1)
WARNING: Duplicate of mod 'bobtech' found (1.1.3)
    Skipping older version (1.1.3) in favor of newer version (1.1.5)
WARNING: Duplicate of mod 'bobwarfare' found (1.1.2)
    Skipping older version (1.1.2) in favor of newer version (1.1.5)
WARNING: Duplicate of mod 'bobmining' found (1.1.1)
    Skipping older version (1.1.1) in favor of newer version (1.1.3)
WARNING: Duplicate of mod 'angelsbioprocessing' found (0.7.17)
    Skipping older version (0.7.17) in favor of newer version (0.7.22)
WARNING: Duplicate of mod 'LandfillPainting' found (0.5.0)
    Skipping older version (0.5.0) in favor of newer version (0.5.2)

Determining dependency tree...

ScienceCostTweakerM 1.1.10
archive? True
dependencies:
       base >= 1.1.0
     ? omnimatter_science >= 3.0.3
     ? pycoalprocessing >= 1.2.0
     ? bobtech  
     ? aai-industry  
     ? omnimatter_energy  
boblogistics 1.1.5
archive? True
dependencies:
       base >= 1.1.0
       boblibrary >= 1.1.0
     ? bobplates >= 1.1.0
     ? bobinserters >= 1.1.0
SeaBlockMetaPack 1.1.3
archive? True
dependencies:
       base  
       angelsaddons-storage  
       angelsbioprocessing  
       angelspetrochem  
       angelsrefining  
       angelssmelting  
       bobassembly  
       bobelectronics  
       bobenemies  
       bobequipment  
       bobinserters  
       boblibrary  
       boblogistics  
       bobmining  
       bobmodules  
       bobores  
       bobplates  
       bobpower  
       bobrevamp  
       bobtech  
       bobwarfare  
       CircuitProcessing  
       ExplosiveExcavation  
Traceback (most recent call last):
  File "/home/orion/projects/cractorio/.venv/bin/draftsman-update", line 8, in <module>
    sys.exit(main())
  File "/home/orion/projects/cractorio/.venv/lib/python3.8/site-packages/draftsman/env.py", line 1777, in main
    update(verbose=args.verbose, show_logs=args.log, no_mods=args.no_mods)
  File "/home/orion/projects/cractorio/.venv/lib/python3.8/site-packages/draftsman/env.py", line 1548, in update
    raise MissingModError(dep_name)
draftsman.error.MissingModError: ExplosiveExcavation
(.venv) 
theunkn0wn1 commented 2 years ago

Looks like this is caused by Explosive Excavation calling itself with a space but Seablock defines its dependency without one (ExplosiveExcavation). strangely Factorio has no trouble with this discrepancy and successfully installs Explosive Excavation.

If i symlink the zip, Draftsman crashes with an (seemingly?) unrelated exception. Unfortunately, this symlink does cause a Factorio game assertion to fail.

~/.factorio/mods ⌚ 16:16:02
$ ln -s Explosive\ Excavation_1.1.8.zip ExplosiveExcavation_1.1.8.zip 
Traceback (most recent call last):
  File "/home/orion/projects/cractorio/.venv/bin/draftsman-update", line 8, in <module>
    sys.exit(main())
  File "/home/orion/projects/cractorio/.venv/lib/python3.8/site-packages/draftsman/env.py", line 1777, in main
    update(verbose=args.verbose, show_logs=args.log, no_mods=args.no_mods)
  File "/home/orion/projects/cractorio/.venv/lib/python3.8/site-packages/draftsman/env.py", line 1718, in update
    load_stage(lua, mods, mod, stage)
  File "/home/orion/projects/cractorio/.venv/lib/python3.8/site-packages/draftsman/env.py", line 259, in load_stage
    lua.execute(mod.data[stage])
  File "lupa/_lupa.pyx", line 308, in lupa._lupa.LuaRuntime.execute
  File "lupa/_lupa.pyx", line 1324, in lupa._lupa.run_lua
  File "lupa/_lupa.pyx", line 1333, in lupa._lupa.call_lua
  File "lupa/_lupa.pyx", line 1359, in lupa._lupa.execute_lua_call
  File "lupa/_lupa.pyx", line 1295, in lupa._lupa.raise_lua_error
lupa._lupa.LuaError: .../factorio-data/core/lualib/circuit-connector-sprites.lua:15: attempt to perform 'n%0'
stack traceback:
    .../factorio-data/core/lualib/circuit-connector-sprites.lua:15: in local 'get_frame'
    .../factorio-data/core/lualib/circuit-connector-sprites.lua:24: in upvalue 'make_circuit_connector_sprites'
    .../factorio-data/core/lualib/circuit-connector-sprites.lua:80: in field 'create'
    [string "prototypes/entity/circuitconnectors"]:31: in main chunk
    [C]: in upvalue 'old_require'
    [string "<python>"]:173: in global 'require'
    [string "prototypes/entity/railloader"]:1: in main chunk
    [C]: in upvalue 'old_require'
    [string "<python>"]:173: in global 'require'
    [string "<python>"]:2: in main chunk
redruin1 commented 2 years ago

That is indeed strange. Changing the mod name to automatically trim spaces completely fixes the problem:

mod_name = m.group(1).replace(" ", "")
Reading mods from: D:\SourceCode\repos\Python\factorio-draftsman\draftsman\factorio-mods

...

Load order:
['base', 'ExplosiveExcavation', 'FNEI', 'KS_Power', 'bobenemies', 'bobinserters', 'boblibrary', 'flib', 'helmod', 'bobequipment', 'bobores', 'bobtech', 'ScienceCostTweakerM', 'bobplates', 'bobassembly', 'bobelectronics', 'bobpower', 'bobrevamp', 'boblogistics', 'bobwarfare', 'bobmining', 'bobmodules', 'angelsrefining', 'LandfillPainting', 'SpaceMod', 'angelspetrochem', 'reskins-library', 'angelsaddons-storage', 'angelssmelting', 'angelsbioprocessing', 'CircuitProcessing', 'reskins-bobs', 'SeaBlock', 'reskins-angels', 'reskins-compatibility', 'SeaBlockMetaPack']

SETTINGS.LUA:
        mod: bobenemies
        mod: bobinserters
        mod: boblibrary
        mod: flib
        mod: helmod
        mod: bobores
        mod: bobtech
        mod: ScienceCostTweakerM
        mod: bobplates
        mod: bobassembly
        mod: bobelectronics
        mod: bobpower
        mod: bobrevamp
        mod: boblogistics
        mod: bobwarfare
        mod: bobmining
        mod: bobmodules
        mod: angelsrefining
        mod: LandfillPainting
        mod: SpaceMod
        mod: angelspetrochem
        mod: reskins-library
        mod: angelsaddons-storage
        mod: angelsbioprocessing
        mod: CircuitProcessing
        mod: reskins-bobs
        mod: SeaBlock
        mod: reskins-angels
        mod: reskins-compatibility
SETTINGS-UPDATES.LUA:
        mod: angelsrefining
        mod: angelspetrochem
        mod: reskins-library
        mod: angelsaddons-storage
        mod: angelssmelting
        mod: angelsbioprocessing
        mod: CircuitProcessing
        mod: reskins-bobs
        mod: SeaBlock
        mod: reskins-angels
        mod: reskins-compatibility
SETTINGS-FINAL-FIXES.LUA:
        mod: reskins-library
DATA.LUA:
        mod: base
        mod: ExplosiveExcavation
        mod: FNEI
        mod: KS_Power
        mod: bobenemies
        mod: bobinserters
        mod: boblibrary
        mod: flib
        mod: helmod
        mod: bobequipment
        mod: bobores
        mod: bobtech
        mod: ScienceCostTweakerM
        mod: bobplates
        mod: bobassembly
        mod: bobelectronics
        mod: bobpower
        mod: bobrevamp
        mod: boblogistics
        mod: bobwarfare
        mod: bobmining
        mod: bobmodules
        mod: angelsrefining
        mod: LandfillPainting
        mod: SpaceMod
        mod: angelspetrochem
        mod: reskins-library
        mod: angelsaddons-storage
        mod: angelssmelting
        mod: angelsbioprocessing
        mod: CircuitProcessing
        mod: reskins-bobs
        mod: SeaBlock
        mod: reskins-angels
        mod: reskins-compatibility
DATA-UPDATES.LUA:
        mod: base
        mod: KS_Power
        mod: bobenemies
        mod: bobinserters
        mod: bobequipment
        mod: bobores
        mod: bobtech
        mod: ScienceCostTweakerM
        mod: bobplates
        mod: bobassembly
        mod: bobelectronics
        mod: bobpower
        mod: bobrevamp
        mod: boblogistics
        mod: bobwarfare
        mod: bobmining
        mod: bobmodules
        mod: angelsrefining
        mod: LandfillPainting
        mod: angelspetrochem
        mod: reskins-library
        mod: angelsaddons-storage
        mod: angelssmelting
        mod: angelsbioprocessing
        mod: CircuitProcessing
        mod: reskins-bobs
        mod: SeaBlock
        mod: reskins-angels
        mod: reskins-compatibility
DATA-FINAL-FIXES.LUA:
        mod: boblibrary
        mod: bobtech
        mod: ScienceCostTweakerM
        mod: bobplates
        mod: bobpower
        mod: angelsrefining
        mod: LandfillPainting
        mod: SpaceMod
        mod: angelspetrochem
        mod: reskins-library
        mod: angelssmelting
        mod: reskins-bobs
        mod: SeaBlock
        mod: reskins-angels
        mod: reskins-compatibility

Extracted mods...
Extracted entities...
Extracted instruments...
Extracted items...
Extracted modules...
Extracted recipes...
Extracted signals...
Extracted tiles...

Update finished.
hella slick; nothing broke!

As to when this normalization takes place in the actual Factorio load process, I have no idea; only the dependency list actually trims the whitespace. From this page I was under the impression that such filenames were prohibited from loading in Factorio, though clearly this is not the case. The only downside to doing this is that you would have to query the mod data from Draftsman as "ExplosiveExcavation" instead of "Explosive Excavation". Of course, this fix will only work for spaces as well.

The reason creating a symlink of the actual zip files doesn't work is because Draftsman preloads all archive files first before it resolves their dependencies, caching them. It loads a mod with the name "Explosive Excavation" internally; then, when it tries to resolve the dependencies, the name is listed as "ExplosiveExcavation", which doesn't match any of the cached mods.

Clever idea using a symlink to relate the Draftsman folder with the install folder. In this discussion I tossed out an idea for a method of specifying the mod folder path as an argument to draftsman-update; would that be more or less convenient for your particular situation?

theunkn0wn1 commented 2 years ago

Clever idea using a symlink to relate the Draftsman folder with the install folder. In https://github.com/redruin1/factorio-draftsman/discussions/36 discussion I tossed out an idea for a method of specifying the mod folder path as an argument to draftsman-update; would that be more or less convenient for your particular situation?

Yes, It would be more convenient for me to pass your tool a path to the mod directory than symlinking it. And put another way, what if the user has multiple factorio mod directories? the factorio executable itself supports it with a CLI argument, it would be beneficial if this tool did as well.

As for architecture-specific path oddities, most of those can be mitigated by using a platform-agnostic filesystem API like stdlib's pathlib.

redruin1 commented 2 years ago

And put another way, what if the user has multiple factorio mod directories? the factorio executable itself supports it with a CLI argument, it would be beneficial if this tool did as well.

Good point; I had no idea that Factorio itself let you do so. I'm convinced, I'll add this feature to the 1.0.2 release.

redruin1 commented 2 years ago

Closing this for now; getting rid of the spaces might cause problems further down the line, but it seems uncommon enough to patch like so right now. I'll reopen/mention this issue if any future problems crop up.