ShivyC icon indicating copy to clipboard operation
ShivyC copied to clipboard

FileNotFoundError No such file or directory

Open bensuperpc opened this issue 3 years ago • 3 comments

I have a problem, I installed the compiler via pip, it gives me this error, yet it generates the .s file well but not the a.out: /

I uses this command: shivyc hello.c

Traceback (most recent call last):
  File "/usr/bin/shivyc", line 33, in <module>
    sys.exit(load_entry_point('shivyc==0.5.0', 'console_scripts', 'shivyc')())
  File "/usr/lib/python3.8/site-packages/shivyc-0.5.0-py3.8.egg/shivyc/main.py", line 30, in main
    objs.append(process_file(file, arguments))
  File "/usr/lib/python3.8/site-packages/shivyc-0.5.0-py3.8.egg/shivyc/main.py", line 46, in process_file
    return process_c_file(file, args)
  File "/usr/lib/python3.8/site-packages/shivyc-0.5.0-py3.8.egg/shivyc/main.py", line 95, in process_c_file
    assemble(asm_file, obj_file)
  File "/usr/lib/python3.8/site-packages/shivyc-0.5.0-py3.8.egg/shivyc/main.py", line 153, in assemble
    subprocess.check_call(["as", "-64", "-o", obj_name, asm_name])
  File "/usr/lib/python3.8/subprocess.py", line 359, in check_call
    retcode = call(*popenargs, **kwargs)
  File "/usr/lib/python3.8/subprocess.py", line 340, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1704, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'as'

bensuperpc avatar Jun 06 '21 20:06 bensuperpc

Hey hey! From the stack trace, it looks like ShivyC tries to use as to assemble the output from x86 assembly to a binary. However, seems like the as binary is not available on your system.

As one fix, you could update line 153 of main.py to replace the as command with one that works on your system. (You can make a PR with a fix that works across systems if you'd like!)

Alternatively, you can assemble the generated .s file using your favorite assembler on your system.

ShivamSarodia avatar Jun 06 '21 20:06 ShivamSarodia

Hey hey! From the stack trace, it looks like ShivyC tries to use as to assemble the output from x86 assembly to a binary. However, seems like the as binary is not available on your system.

As one fix, you could update line 153 of main.py to replace the as command with one that works on your system. (You can make a PR with a fix that works across systems if you'd like!)

Alternatively, you can assemble the generated .s file using your favorite assembler on your system.

I installed binutils and gcc, but it still seems to be a problem, but it is progressing,

I'm trying to make a docker container with your compiler, if you want to see the code: https://github.com/bensuperpc/docker-ShivyC/blob/main/Dockerfile

as soon as it works i would do a PR to add github action to your git repository, this allows the code to be tested with each push. Sorry for my english, i'm french ^^"

WIth "as" command :

[bensuperpc@bensuperpc-luna ~]$ as -v
Version de l'assembleur GNU 2.36.1 (x86_64-pc-linux-gnu) utilisant la version BFD (GNU Binutils) 2.36.1

Now with the tests I get this :

Installed /usr/local/lib/python3.9/dist-packages/shivyc-0.5.0-py3.9.egg
Processing dependencies for shivyc==0.5.0
Finished processing dependencies for shivyc==0.5.0
EEEEEEEEEEEEE.................................EEEEEEEEEEEEEEEEEEEEEEEEEEE..............EEEEFFF
======================================================================
ERROR: test_addition (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_array (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_assignment (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_bitwise_shifts (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_bool (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_break_continue (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_cast (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_comparison (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_compound_assign (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_compound_statement (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_declaration (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_division (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_else (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_expr_comma (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_for (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_function_call (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_function_def (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_if (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_implicit_cast (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_include (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_incomplete_types (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_incr_decr (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_int_arithmetic (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_main_return (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_modulus (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_multiplication (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_pointer-1 (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_pointer-2 (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_pointer_math (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_sizeof (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_storage (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_string (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_struct (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_subtraction (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_type_qualifier (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_typedef (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_unary_arithmetic (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_union (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_while (tests.test_all.FeatureTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_empty_statement (tests.test_all.FrontendTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_identifier (tests.test_all.FrontendTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_lexer (tests.test_all.FrontendTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_spacing (tests.test_all.FrontendTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
ERROR: test_string (tests.test_all.FrontendTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 100, in test_function
    issue_list.append((issue.descrip, issue.range.start.line))
AttributeError: 'NoneType' object has no attribute 'start'

======================================================================
FAIL: test_count (tests.test_all.IntegrationTests)
Test the Count.c program from the first pset of CPSC 223 at Yale.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 212, in test_count
    self.io_test("general_tests/count", "Count.c", "input.c")
  File "/ShivyC/tests/test_all.py", line 188, in io_test
    self.assertEqual(error_collector.issues, [])
AssertionError: Lists differ: [CompilerError('could not find crt0.o, crt1.o, or crt2.o for linking')] != []

First list contains 1 additional elements.
First extra element 0:
CompilerError('could not find crt0.o, crt1.o, or crt2.o for linking')

- [CompilerError('could not find crt0.o, crt1.o, or crt2.o for linking')]
+ []

======================================================================
FAIL: test_pi (tests.test_all.IntegrationTests)
Test the pi.c program.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 217, in test_pi
    self.io_test("general_tests/pi", "pi.c", None)
  File "/ShivyC/tests/test_all.py", line 188, in io_test
    self.assertEqual(error_collector.issues, [])
AssertionError: Lists differ: [CompilerError('could not find crt0.o, crt1.o, or crt2.o for linking')] != []

First list contains 1 additional elements.
First extra element 0:
CompilerError('could not find crt0.o, crt1.o, or crt2.o for linking')

- [CompilerError('could not find crt0.o, crt1.o, or crt2.o for linking')]
+ []

======================================================================
FAIL: test_trie (tests.test_all.IntegrationTests)
Test the trie.c program.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/ShivyC/tests/test_all.py", line 222, in test_trie
    self.io_test("general_tests/trie", "trie.c", None)
  File "/ShivyC/tests/test_all.py", line 188, in io_test
    self.assertEqual(error_collector.issues, [])
AssertionError: Lists differ: [CompilerError('could not find crt0.o, crt1.o, or crt2.o for linking')] != []

First list contains 1 additional elements.
First extra element 0:
CompilerError('could not find crt0.o, crt1.o, or crt2.o for linking')

- [CompilerError('could not find crt0.o, crt1.o, or crt2.o for linking')]
+ []

----------------------------------------------------------------------
Ran 94 tests in 7.858s

FAILED (failures=3, errors=44)
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
shivyc: error: linker returned non-zero status
The command '/bin/sh -c git clone --recurse-submodules https://github.com/ShivamSarodia/ShivyC.git      && cd ShivyC && python3 setup.py install && python3 -m unittest discover' returned a non-zero code: 1

bensuperpc avatar Jun 06 '21 20:06 bensuperpc

Update: I switch to ubuntu:latest and it seems to work, i don't know why alpine linux and debian don't work but hey it works with ubuntu Update 2: Rather, it is a package that is missing, because without "--no-install-recommends" it works, with it no longer works

bensuperpc avatar Jun 06 '21 21:06 bensuperpc