sync-engine
sync-engine copied to clipboard
sys.path may be in wrong order when bin/create-db is run during setup.sh
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.
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.
Can this not be added in setup.sh to permanently add it to the system path? Specially if we are using a virtual machine.
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?