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

Error on loading stdlib_metta and corelib in a fresh Docker container #223

Closed
vsbogd opened this issue Dec 17, 2024 · 3 comments
Closed

Comments

@vsbogd
Copy link

vsbogd commented Dec 17, 2024

Running mettalog in Docker built from the latest HEAD d75836d gives the assert error:

$ docker run -it mettalog bash -l
PYTHONPATH=/home/user/metta-wam/tests/python_compat/metta-motto:/home/user/metta-wam/src
root@3cbdfab0f57e:~/metta-wam# mettalog
/home/user/metta-wam/mettalog: line 80: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
ERROR: Assertion failed: user:metta_atom('&corelib',[:,'Any','Type'])
  [29] prolog_stack:backtrace(10) at /usr/local/lib/swipl/library/prolog_stack.pl:494
  [28] prolog_debug:assertion_failed(fail,user:metta_atom('&corelib',[:,'Any','Type'])) at /usr/local/lib/swipl/library/debug.pl:393
  [27] prolog_debug:assertion(user:metta_atom('&corelib',[:,'Any','Type'])) at /usr/local/lib/swipl/library/debug.pl:379
  [26] load_corelib_file at /home/user/metta-wam/src/canary/metta_loader.pl:3672
  [25] really_use_corelib_file at /home/user/metta-wam/src/canary/metta_loader.pl:3614
  [24] use_corelib_file at /home/user/metta-wam/src/canary/metta_loader.pl:3603
  [23] '$run_init_goal'('<garbage_collected>') at /usr/local/lib/swipl/boot/init.pl:826
  [22] catch(system:'$run_init_goal'(user:use_corelib_file),_71852,system:'$initialization_error'(_71920,user:use_corelib_file,'/home/user/metta-wam/src/canary/metta_interp.pl':2226)) at /usr/local/lib/swipl/boot/init.pl:565
  [21] catch_with_backtrace('<garbage_collected>','<garbage_collected>','<garbage_collected>') at /usr/local/lib/swipl/boot/init.pl:645
  [20] '$run_init_goal'(user:use_corelib_file,'/home/user/metta-wam/src/canary/metta_interp.pl':2226) at /usr/local/lib/swipl/boot/init.pl:815
ERROR: /home/user/metta-wam/src/canary/metta_interp.pl:2226: Initialization goal raised exception:
ERROR: Unknown error term: assertion_error(fail,user:metta_atom('&corelib',[:,'Any','Type']))
ERROR: In:
ERROR:   [29] throw(error(assertion_error(fail,user:metta_atom('&corelib',[:,'Any','Type'])),_186986))
ERROR:   [27] prolog_debug:assertion(user:metta_atom('&corelib',[:,'Any','Type'])) at /usr/local/lib/swipl/library/debug.pl:379
ERROR:   [26] load_corelib_file at /home/user/metta-wam/src/canary/metta_loader.pl:3672
ERROR:   [25] really_use_corelib_file at /home/user/metta-wam/src/canary/metta_loader.pl:3614
ERROR:   [24] use_corelib_file at /home/user/metta-wam/src/canary/metta_loader.pl:3603
ERROR:   [23] '$run_init_goal'('<garbage_collected>') at /usr/local/lib/swipl/boot/init.pl:826
ERROR:   [22] catch(system:'$run_init_goal'(user:use_corelib_file),_187228,system:'$initialization_error'(_187256,user:use_corelib_file,'/home/user/metta-wam/src/canary/metta_interp.pl':2226)) at /usr/local/lib/swipl/boot/init.pl:565
ERROR:   [21] catch_with_backtrace('<garbage_collected>','<garbage_collected>','<garbage_collected>') at /usr/local/lib/swipl/boot/init.pl:645
ERROR: 
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
% 23,758 inferences, 0.008 CPU in 0.008 seconds (100% CPU, 3124193 Lips)

Manual search for (: Any Type) in &corelib after the error also doesn't return results:

metta+>!(match &corelib (: Any Type) Ok)
[]
metta+>!(match &self (: Any Type) Ok)
[]

At the same time &corelib atom exists but it is empty:

metta+>!(get-type &corelib)
[hyperon::space::DynSpace]
metta+>!(get-atoms &corelib)
[]

This behaviour repeats if mettalog is restarted.

If I comment two last lines in load_corelib_file on src/canary/metta_loader.pl:3672

load_corelib_file :-
              % Load the standard Metta logic file from the source directory.
              is_metta_src_dir(Dir), really_use_corelib_file(Dir, 'stdlib_mettalog.metta'), !.
              %assertion(metta_atom('&corelib', [':', 'Any', 'Type'])),
              %really_use_corelib_file(Dir, 'corelib.metta').

then it loads stdlib_mettalog successfully and corelib is loaded as well:

root@3cbdfab0f57e:~/metta-wam# mettalog
/home/user/metta-wam/mettalog: line 80: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
% 36,789 inferences, 0.262 CPU in 0.262 seconds (100% CPU, 140537 Lips)
metta+>!(match &corelib (: Any Type) Ok)
[Ok]

Moreover after first successful start the error is gone and now both stdlib_mettalog.metta and corelib.metta are loaded successfully on start:

root@3cbdfab0f57e:~/metta-wam# mettalog
/home/user/metta-wam/mettalog: line 80: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Info: File /home/user/metta-wam/src/canary/stdlib_mettalog.metta is 87.0K bytes (2.30K lines)
Info: File /home/user/metta-wam/src/canary/corelib.metta is 34 bytes (1 lines)
% 36,586 inferences, 0.266 CPU in 0.266 seconds (100% CPU, 137608 Lips)
metta+>Info: Processing progress: 100% [4] current_output closed; set to user_output
 - Stopping reporting on /home/user/metta-wam/src/canary/stdlib_mettalog.metta progress.
Info: Processing progress: 100% [5] current_output closed; set to user_output
 - Stopping reporting on /home/user/metta-wam/src/canary/corelib.metta progress.
metta+>!(match &corelib (: Any Type) Ok)
[Ok]
@TeamSPoon
Copy link
Collaborator

Very good troubleshooting above!

I did notice your running from /home/user/metta-wam/src/canary/metta_loader.pl

Recently we had to switch to a new branch master since we had to perform GIT surgery to move large testing files into their own repository. At that time we started using more standarized paths choosen by the SWI-Prolog package manager.

So all the files have moved.. For exmaple that file is now at /home/user/metta-wam/prolog/metta_lang/metta_loader.pl

So make sure you checkout master . hrrm I wonder if docker is going to be happy with new paths

@vsbogd
Copy link
Author

vsbogd commented Dec 17, 2024

Ah ok, one issue I see with my local code is that I used main branch instead and it looks like it is removed already, so I built docker from incorrect commit. Let me check whether it works in master branch then.

@vsbogd
Copy link
Author

vsbogd commented Dec 17, 2024

Thanks @TeamSPoon looks like it is not an issue on a latest HEAD. Closing it. Sorry for a false alarm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants