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

node plugin: dont crash when running on non-snap arm64 env #885

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

om26er
Copy link

@om26er om26er commented Oct 19, 2024

  • Have you signed the CLA?

When building nodejs based snap in a docker container using snapcraft 8.4.3 the build fails with these logs

2024-10-19 13:36:25.195 Architecture "aarch64 ('64bit', '')" is not supported.                                                                                                 
2024-10-19 13:36:25.199 Traceback (most recent call last):                                                                                                                     
2024-10-19 13:36:25.199   File "/snap/snapcraft/current/lib/python3.10/site-packages/craft_parts/plugins/npm_plugin.py", line 151, in _get_architecture                        
2024-10-19 13:36:25.199     node_arch = _NODE_ARCH_FROM_PLATFORM[machine_type][architecture_type[0]]                                                                           
2024-10-19 13:36:25.200 KeyError: 'aarch64'                                                                                                                                    
2024-10-19 13:36:25.200                                                                                                                                                        
2024-10-19 13:36:25.200 The above exception was the direct cause of the following exception:                                                                                   
2024-10-19 13:36:25.200 Traceback (most recent call last):                                                                                                                     
2024-10-19 13:36:25.200   File "/snap/snapcraft/current/lib/python3.10/site-packages/craft_application/services/lifecycle.py", line 270, in run                                
2024-10-19 13:36:25.201     aex.execute(action, stdout=stream, stderr=stream)                                                                                                  
2024-10-19 13:36:25.201   File "/snap/snapcraft/current/lib/python3.10/site-packages/craft_parts/executor/executor.py", line 324, in execute                                   
2024-10-19 13:36:25.201     self._executor.execute(actions, stdout=stdout, stderr=stderr)                                                                                      
2024-10-19 13:36:25.201   File "/snap/snapcraft/current/lib/python3.10/site-packages/craft_parts/executor/executor.py", line 136, in execute                                   
2024-10-19 13:36:25.201     self._run_action(act, stdout=stdout, stderr=stderr)                                                                                                
2024-10-19 13:36:25.201   File "/snap/snapcraft/current/lib/python3.10/site-packages/craft_parts/executor/executor.py", line 211, in _run_action                               
2024-10-19 13:36:25.202     handler.run_action(action, stdout=stdout, stderr=stderr)                                                                                           
2024-10-19 13:36:25.202   File "/snap/snapcraft/current/lib/python3.10/site-packages/craft_parts/executor/part_handler.py", line 171, in run_action                            
2024-10-19 13:36:25.202     state = handler(step_info, stdout=stdout, stderr=stderr)                                                                                           
2024-10-19 13:36:25.202   File "/snap/snapcraft/current/lib/python3.10/site-packages/craft_parts/executor/part_handler.py", line 310, in _run_build                            
2024-10-19 13:36:25.202     self._run_step(                                                                                                                                    
2024-10-19 13:36:25.202   File "/snap/snapcraft/current/lib/python3.10/site-packages/craft_parts/executor/part_handler.py", line 493, in _run_step                             
2024-10-19 13:36:25.203     return step_handler.run_builtin()                                                                                                                  
2024-10-19 13:36:25.203   File "/snap/snapcraft/current/lib/python3.10/site-packages/craft_parts/executor/step_handler.py", line 108, in run_builtin                           
2024-10-19 13:36:25.203     return handler()                                                                                                                                   
2024-10-19 13:36:25.203   File "/snap/snapcraft/current/lib/python3.10/site-packages/craft_parts/executor/step_handler.py", line 138, in _builtin_build                        
2024-10-19 13:36:25.203     build_commands = self._plugin.get_build_commands()                                                                                                 
2024-10-19 13:36:25.204   File "/snap/snapcraft/current/lib/python3.10/site-packages/craft_parts/plugins/npm_plugin.py", line 277, in get_build_commands                       
2024-10-19 13:36:25.204     arch = self._get_architecture()                                                                                                                    
2024-10-19 13:36:25.204   File "/snap/snapcraft/current/lib/python3.10/site-packages/craft_parts/plugins/npm_plugin.py", line 153, in _get_architecture                        
2024-10-19 13:36:25.204     raise InvalidArchitecture(                                                                                                                         
2024-10-19 13:36:25.204 craft_parts.errors.InvalidArchitecture: Architecture "aarch64 ('64bit', '')" is not supported.                                                         
2024-10-19 13:36:25.204 Make sure the architecture name is correct.                                                                                                            
2024-10-19 13:36:25.205 Recommended resolution: Make sure the architecture name is correct.

@om26er
Copy link
Author

om26er commented Oct 19, 2024

For now I do this in my docker container build to patch craft_parts. Obviously another "hack" would be to export SNAP_ARCH parameter in docker container as well and then a different codepath would execute.

RUN sed -i 's|_NODE_ARCH_FROM_PLATFORM = {"x86_64": {"32bit": "x86", "64bit": "x64"}}|_NODE_ARCH_FROM_PLATFORM = {"x86_64": {"32bit": "x86", "64bit": "x64"}, "aarch64": {"64bit": "arm64"}}|g' /snap/snapcraft/current/lib/python3.10/site-packages/craft_parts/plugins/npm_plugin.py

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

Successfully merging this pull request may close these issues.

1 participant