lemverse icon indicating copy to clipboard operation
lemverse copied to clipboard

ValueError: invalid mode: 'rU' while trying to load binding.gyp

Open PuKoren opened this issue 1 year ago • 0 comments

This should be fixed in the next dependencies update (maybe to solve #235 when the upgrade to Meteor3 is ready?), so I am leaving this as a documentation ticket in case someone encounter the same problem. Please let me know if there is a better place for it or if it is already documented elsewhere.

Description

The following error is shown when starting the Meteor app using meteor --settings settings-dev.json on a system with Python 3.11 and above. It is due to an incompatibility between node-gyp and this specific version of Python.

line 234, in LoadOneBuildFile
   build_file_contents = open(build_file_path, 'rU').read()
   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
   ValueError: invalid mode: 'rU' while trying to load binding.gyp
   gyp ERR! configure error 
   gyp ERR! stack Error: `gyp` failed with exit code: 1

How to solve it

Installing Python version 3.10 on the system (using pyenv for example) and forcing node-gyp to use it will solve it. If using pyenv, the path to Python can be provided to node-gyp by using the following command:

NODE_GYP_FORCE_PYTHON=~/.pyenv/versions/3.10.13/bin/python3 meteor --settings settings-dev.json

Sources

https://stackoverflow.com/questions/74715990/node-gyp-err-invalid-mode-ru-while-trying-to-load-binding-gyp

https://github.com/pact-foundation/pact-js/issues/1087

PuKoren avatar Feb 09 '24 09:02 PuKoren