apm ignores python versioning in npm config

Created on 21 Aug 2014  路  13Comments  路  Source: atom/apm

apm install atom-lint
and
apm install --python=python2.7 atom-lint

result in:
gyp ERR! stack Error: Python executable "python" is v3.4.1, which is not supported by gyp.
gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.

npm config list outputs:
; globalconfig /usr/etc/npmrc
python = "/usr/bin/python2"

which python2.7 outputs:
/usr/bin/python2.7

I was eventually able to get the linter installed by:
export PYTHON=python2.7

but it appears that the switch and config are ignored.

Most helpful comment

I found that you need to do the following:

In your apm script

vim `which apm`

Comment out the line

export npm_config_python="${binDir}/python-interceptor.sh"

Ensure you did apm config set python /path/to/python2.7 and then it should work.

All 13 comments

apm uses a .apmrc file, if you add the python override to ~/.atom/.apmrc, does it work then?

Closing this out due to inactivity, please let me know if putting the python path in your ~/.atom/.apmrc file does not solve this issue.

I can confirm that the following resolves Python3-related issues with apm:

echo "python=/usr/bin/python2" >> ~/.atom/.apmrc

you can also do

apm config set python /path/to/python2

This no longer seems to work :(

I found that you need to do the following:

In your apm script

vim `which apm`

Comment out the line

export npm_config_python="${binDir}/python-interceptor.sh"

Ensure you did apm config set python /path/to/python2.7 and then it should work.

@ioquatix The hack works. But I'm guessing it'll be reset each time you update Atom.

@jokeyrhyme Your suggestion doesn't work. I'll make a PR.

@ioquatix well, considering python2 is end-of-life 2020-01-01, Node.js and its entire ecosystem, including native modules, needs to be upgraded to python3 pretty soon

I looked into it briefly, and it seems like there is a pretty big cludge in the form of python-interceptor.sh and https://github.com/atom/apm/blob/1ac3c80a9e148127e08d7a7965bf8a38ccd27cd8/bin/apm#L34-L44 which ignores the user specified python env and instead basically breaks everything. I feel like the first step, and what I was thinking to make as a PR, would be to remove that cludge.

@ioquatix I would suggest discovering why that file was made in the first place, before attempting a PR. It may or may not be required now, I don鈥檛 know, but Chesterton鈥檚 fence would be a good principle to keep in mind.

Apparently it was made to fix the python version detection but it now seems completely broken.

This is still a problem, and my proposed fix above still works :p

Was this page helpful?
0 / 5 - 0 ratings