l3mpire / lemverse

The first-ever coworking metaverse
https://app.lemverse.com
GNU Affero General Public License v3.0
149 stars 43 forks source link

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

Open PuKoren opened 7 months ago

PuKoren commented 7 months ago

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