nylas / sync-engine

:incoming_envelope: IMAP/SMTP sync system with modern APIs
https://nylas.com/docs/platform
GNU Affero General Public License v3.0
3.5k stars 354 forks source link

sys.path may be in wrong order when bin/create-db is run during setup.sh #427

Open armarti opened 7 years ago

armarti commented 7 years ago

Hello, my git show --oneline -s shows 0d607a3 Release 17.1.6 (#424).

After running vagrant ssh after first setting up this repo, running ./setup.sh kept failing on NYLAS_ENV=dev bin/create-db with this error message:

File "bin/create-db", line 12, in <module> from inbox.config import config

And my path:

$ python -c 'import sys; print "\n".join(sys.path);' ` /usr/lib/python2.7 /usr/lib/python2.7/plat-linux2 /usr/lib/python2.7/lib-tk /usr/lib/python2.7/lib-old /usr/lib/python2.7/lib-dynload /usr/local/lib/python2.7/dist-packages /vagrant /usr/lib/python2.7/dist-packages /usr/lib/pymodules/python2.7`

Notice /usr/local/lib/python2.7/dist-packages is in front of /vagrant.

I have:

$ ls -1 /usr/local/lib/python2.7/dist-packages/inbox __init__.py __init__.pyc $ ls -1 /vagrant/inbox ... config.py config.pyc ...

Thus, when from inbox.config import config is run in bin/create-db it is looking for a config module in /usr/local/lib/python2.7/dist-packages (it's not there).

There is probably a more elegant way of correcting this, adding this to /vagrant/bin/create-db worked:

import sys sys.path = ["/vagrant"] + [p for p in sys.path if p != "/vagrant"]

Then I run NYLAS_ENV=dev bin/create-db and everything works correctly.

itsjef commented 7 years ago

Perfect! It works for me.

Plus, you have to put the very same line into both bin/inbox-start, bin/inbox-auth, and bin/inbox-api if you want to start the service.

ajcollett commented 7 years ago

Can this not be added in setup.sh to permanently add it to the system path? Specially if we are using a virtual machine.

spang commented 7 years ago

Saw this while QAing the latest release today.

I think the root of this issue is actually that /usr/local/lib/python2.7/dist-packages/inbox is created at all during setup.sh—if you remove that empty directory, everything works fine.

Has anyone figured out what creates that directory?