The Quickstart doesn't seem to work.
Hi guys,
I hope one of you can help me to get the project up and running. These are the steps I have taken:
- git clone https://github.com/JackHopkins/factorio-learning-environment.git
- cd factorio-learning-environment
- python -m venv venv
- pip install -e .
- pip install psycopg2 lupa
- pip install -r .\env\src\requirements.txt (it is not in the guide, but I get multiple dependencies missing if I don't)
- cd cluster/docker
- docker build -t factorio .
- cd ../local
- ./run-envs.sh
- Start Factorio and connect to the server
- python run.py --run_config=eval/open/independent_runs/run_config_example_lab_play.json (the readme says python eval/open/independent_runs/run.py --run_config=eval/open/independent_runs/run_config_example_lab_play.json, but that errors with a module missing due to paths).
- I know that I should configure the DB, but I don't really want to be forced to do that and I will make some changes to make it optional. It furthermore doesn't seem to be the reason for the error.
Following these steps it seems like all the dependencies have been installed, the server is running, and I can connect to it using Factorio, but I get an error in step 12 which seems to be related to the score tool. ... 27000: Loading action agent\sleep/server.lua into game Traceback (most recent call last): File "D:\Projects\factorio-learning-environment\eval\open\independent_runs\run.py", line 40, in main instance = create_factorio_instance(0, num_agents) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Projects\factorio-learning-environment\eval\open\independent_runs\trajectory_runner.py", line 332, in create_factorio_instance instance = FactorioInstance( ^^^^^^^^^^^^^^^^^ File "D:\Projects\factorio-learning-environment\env\src\instance.py", line 123, in init ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Projects\factorio-learning-environment\env\src\instance.py", line 282, in wrapper result = original_callable(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\Projects\factorio-learning-environment\env\src/tools\agent\score\client.py", line 25, in call return response['player'], goal ~~~~~~~~^^^^^^^^^^ KeyError: 'player'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Projects\factorio-learning-environment\run.py", line 15, in
The score() function is called just as a check with instance is initialized (instance.py:123).I had seen this error earlier where the score tool returned an empty dictionary while the expected output has keys 'player', 'enemy' and 'neutral' (different forces), so it didn't trigger the exception at score/client.py:23. It was due to something I had done while development and I undid that and everything was fine. So not sure why it's happening to you. I would try filling score/server.lua with game.print() to trace out what's going on in the server-side code.
With some further debugging I would guess that all tools fail with an error similar to this: 'Cannot execute command. Error: [string "a, b = pcall(global.actions.clear_collision_b..."]:1: attempt to call global 'dump' (a nil value)'
I will dig a little further, but if you know why this error might happen I would appreciate the help. :)
Can you type game.print(dump()) into the game console? It's very strange that its not found.
That does seem to work or at least it doesn't throw an error.
I have noticed that the server log registers when I manually send rcon requests to it, but it doesn't register anything when I use run.py.
/c game.print(dump("test"))
You need to prefix with /c to run as a command.
That's a little embarrassing. :D
I get the same error:
Okay, so dump is an FLE method. This indicates that we are not actually loading in the FLE scripts. @kantneel we shouldn't silence these loading methods with /silent-command as it makes it harder to debug these situations (if this change is still in?)
@MortenTobiasNielsen can you run any of the tests in /tests/actions?
I think the issue could be that the mods aren't transferred to the server when run-envs.sh is used in the local folder. At least they don't seem to be present in the instance created by that script:
I don’t think that is the issue - the mods are loaded into memory, not onto the filesystem, so you shouldn’t expect to see them in the container.
On 28 May 2025, at 15:45, MortenTobiasNielsen @.***> wrote:
MortenTobiasNielsen left a comment (JackHopkins/factorio-learning-environment#208) https://github.com/JackHopkins/factorio-learning-environment/issues/208#issuecomment-2916619437 I think the issue could be that the mods aren't transferred to the server when run-envs.sh is used in the local folder. At least they don't seem to be present in the instance created by that script:
image.png (view on web) https://github.com/user-attachments/assets/ca3ecbc4-3e46-4da8-a7c6-e092f4463707 — Reply to this email directly, view it on GitHub https://github.com/JackHopkins/factorio-learning-environment/issues/208#issuecomment-2916619437, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA5T6OSZMRRWFTVHUQXCNX33AXDZNAVCNFSM6AAAAAB56DZXYKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSMJWGYYTSNBTG4. You are receiving this because you commented.
Okay. I have run one of the tests and get this error:
We could un-silence the mod-loading, but they get loaded so quickly and the game console chat doesn't allow scrolling so I don't know if that's the best approach for debugging. I'd rather that the LuaScriptManager verifies correct loading and doesn't simply print lines of 27000: Loading action agent\sleep/server.lua into game with silent errors happening in the background.
@kantneel I agree that it would be better to handle it outside of the game, a real error while setting up the environment would be nice - when it doesn't do what it is supposed to.
@JackHopkins The "change to \" plan unfortunately didn't work. When are initialise.lua supposed to be loaded in, or for that matter any of the files in the lib folder? I don't see any of them in the list of "27000: Loading ...".
Hey guys been trying to follow the quickstart guide and ive finally reached this error as well.
27000: Loading action agent/pickup_entity/server.lua into game
Traceback (most recent call last):
File "/Users/harshitsharma/Code/exp/factorio-learning-environment/eval/open/independent_runs/run.py", line 40, in main
instance = await create_factorio_instance(0, num_agents)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/harshitsharma/Code/exp/factorio-learning-environment/eval/open/independent_runs/trajectory_runner.py", line 358, in create_factorio_instance
instance = FactorioInstance(**common_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/harshitsharma/Code/exp/factorio-learning-environment/env/src/instance.py", line 127, in __init__
self.initial_score, goal = self.first_namespace.score()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/harshitsharma/Code/exp/factorio-learning-environment/env/src/instance.py", line 295, in wrapper
result = original_callable(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/harshitsharma/Code/exp/factorio-learning-environment/env/src/tools/agent/score/client.py", line 25, in __call__
return response['player'], goal
~~~~~~~~^^^^^^^^^^
KeyError: 'player'
Got it to work !! i had so many setup issues ... :')
Hero. We are literally talking about this issue right now! How did you get it to work? How can we improve our quickstart?
So to reach the above error i had to:
- fix a run.py error, i faced an asyncio not being used correctly, which was fixed via importing it and using
asyncio.run(main()) - then the docker container was restarting with rosetta errors in docker's logs
- it was because for macbook m4 air, the arm64/v8 wasnt working, so i had to hardcode amd64 in the
script cluster/local/run-envs.shline 8.
After this, my container was working, so i wanted to sanity check if my factorio setup and container could sync via the multiplayer:
- on running factorio and connecting multiplayer using
localhost:34197, it told me there were mods sync issues - so i checked if the factorio mods were loading correctly in the container, they werent, i checked it in the container's terminal at
/opt/factorio/mods/mod-list.jsonthis was barebones and no mods were present, even tho they were listed in/factorio/config/mod-list.json - then claude found that the
cluster/docker/build_alternative_installation_location.shhas the steps to sync the mods - i did that, then i got a new popup saying some level mod was giving an issue, this was very weird and i was stumped for a bit but claude then found out that:
Error ClientMultiplayerManager.cpp:1101: level was registered for the following nth_ticks when the map was saved but has not re-registered them as a result of loading: 5 and 15saying
This is a common Factorio multiplayer issue that occurs when: The server has been running for a while with active scripts Those scripts registered event handlers during server startup A new client tries to join but can't recreate the same event handler state
- suggested a simple fix to restart the container and voila i was in !! i could join the multiplayer game
- after this on run.py for lab play i got
TypeError: SQLliteDBClient.get_resume_state() got an unexpected keyword argument 'agent_idx' - this was fixed by adding the missing parameter to SQLite's get_resume_state() method and updating the query
- after this i was able to launch the run.py successfully and the agent started building !
@kantneel you didn't update SQLliteDBClient!
Thanks for this report!
The level issue has been around for a while. I'm going to try and solve it next (#212 )
Regarding the mods, we should remove them entirely. They aren't necessary and just add confusion (#215 )
Do you mind pasting a snippet of the run.py with the changed async stuff? This seems useful to know.
🫡 here ya go
/run.py
#!/usr/bin/env python3
import os
import sys
import asyncio
# Add the necessary paths to sys.path
root_dir = os.path.dirname(os.path.abspath(__file__))
env_src_dir = os.path.join(root_dir, 'env', 'src')
# Add paths to sys.path if they're not already there
if root_dir not in sys.path:
sys.path.insert(0, root_dir)
if env_src_dir not in sys.path:
sys.path.insert(0, env_src_dir)
# Now import and run the actual script
from eval.open.independent_runs.run import main
if __name__ == "__main__":
asyncio.run(main())
Can I also ask which step above exactly fixed the 'player' key error? It feels like a docker/server setup issue as I'm also running windows and can't reproduce
The error just popped up again, after i had restarted the containers and made some changes to installed modules (idk what caused it, but unlikely to be the module changes). It started working after i launched factorio and connected to the multiplayer again (i had to restart the container again because of the level sync issue).
this is sadly beyond my ability to model right now, as ive never worked with lua before.
If you restart the container you will need to login again to activate it.
I think what might be happening is that the server is not activated, and we are not throwing an error back in score for this case.
I am going to close this issue but it will likely be a good resource in the future to refer back to. I also wanted to note that there were issues with rosetta on mac m1 and the interaction with the headless linux server, which only runs on amd64. I solved the issue by using a separate vm as the headless server, therefore, the exact issue is still unknown (hopefully it was just a problem with my device specifically), but future users may encounter this problem which gives mod desynch issues as the client is not able to keep up with the server or vica versa. It is worth noting that Harshit was able to fix this issue by using the build alternative script.sh file but that did not work for me.