Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error message while fresh install without secret.py #1876

Closed
zoepage opened this issue Nov 15, 2017 · 14 comments
Closed

Error message while fresh install without secret.py #1876

zoepage opened this issue Nov 15, 2017 · 14 comments

Comments

@zoepage
Copy link
Member

zoepage commented Nov 15, 2017

We get an error message that is hard to figure out, when you are new to the project.
Fresh install of project.

  1. npm run setup
  2. npm run pip
  3. npm run start

without creating a config yet (so there is npm run config missing as 3rd step).

Probably there is just a catch missing @karlcow @miketaylr ?

Statuses Initialization…
Fetching milestones from Github…
It failed with 404 Client Error: Not Found for url: https://api.github.com/repos/milestones!
We will read from data/milestones.json.

Traceback (most recent call last):
  File "run.py", line 35, in <module>
    from webcompat import app
  File "/Users/madeleine/projects/webcompat.com/webcompat/__init__.py", line 20, in <module>
    app.config.from_object('config')
  File "/Users/madeleine/projects/webcompat.com/env/lib/python2.7/site-packages/flask/config.py", line 168, in from_object
    obj = import_string(obj)
  File "/Users/madeleine/projects/webcompat.com/env/lib/python2.7/site-packages/werkzeug/utils.py", line 418, in import_string
    __import__(import_name)
  File "/Users/madeleine/projects/webcompat.com/config/__init__.py", line 132, in <module>
    if not initialize_status():
  File "/Users/madeleine/projects/webcompat.com/config/__init__.py", line 57, in initialize_status
    app.config['STATUSES'] = convert_milestones(milestones_content)
  File "/Users/madeleine/projects/webcompat.com/config/__init__.py", line 69, in convert_milestones
    STATUSES[milestone['title']]['id'] = milestone['number']
TypeError: string indices must be integers
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! webcompat@ start: `source env/bin/activate || . env/bin/activate && python run.py`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the webcompat@ start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/madeleine/.npm/_logs/2017-11-15T14_25_28_052Z-debug.log
@karlcow
Copy link
Member

karlcow commented Nov 15, 2017

We could catch that error and exit gracefully with a message saying. You need to configure the repo URI and oauth.

@zoepage Would that work for you? I'll do that tomorrow (thursday morning JST/Wednesday night CET).

@zoepage
Copy link
Member Author

zoepage commented Nov 15, 2017

@karlcow yessssss. thank you! :)

@karlcow
Copy link
Member

karlcow commented Nov 16, 2017

git checkout master
git fetch webcompat
git merge webcompat/master
git checkout -b 1876/1

ok we are ready to code. :)

@karlcow
Copy link
Member

karlcow commented Nov 16, 2017

Let's try to test with config done.

npm run start

This has never worked for me.

→ npm run start

> webcompat@ prestart /Users/karl/code/webcompat.com
> npm run build


> webcompat@ build /Users/karl/code/webcompat.com
> grunt

Running "checkDependencies:default" (checkDependencies) task

Running "jst:compile" (jst) task
File webcompat/static/js/templates.js created.

Running "concat:dist" (concat) task

Running "concat:diagnose" (concat) task

Running "concat:issues" (concat) task

Running "concat:issueList" (concat) task

Running "concat:userActivity" (concat) task

Running "uglify:dist" (uglify) task
>> 1 file created 548.27 kB → 389.51 kB

Running "uglify:issues" (uglify) task
>> 1 file created 45.23 kB → 25.33 kB

Running "uglify:issueList" (uglify) task
>> 1 file created 37.17 kB → 20.03 kB

Running "uglify:userActivity" (uglify) task
>> 1 file created 21.94 kB → 11.36 kB

Running "uglify:diagnose" (uglify) task
>> 1 file created 12.99 kB → 6.48 kB

Running "uglify:contributors" (uglify) task
>> 1 file created 1.05 kB → 737 B

Running "postcss:dist" (postcss) task
>> 1 processed stylesheet created.

Running "cssmin:combine" (cssmin) task
>> 1 file created. 269 kB → 59.45 kB

Done.

> webcompat@ start /Users/karl/code/webcompat.com
> source env/bin/activate || . env/bin/activate && python run.py

Traceback (most recent call last):
  File "run.py", line 41, in <module>
    raise ImportError('{0}\n\n{1}'.format(e, IMPORT_ERROR))
ImportError: cannot import name get_remote_address


==============================================
It seems like you don't have all dependencies.
Please re-run:
    pip install -r config/requirements.txt
==============================================


npm ERR! Darwin 17.2.0
npm ERR! argv "/Users/karl/.nvm/versions/node/v6.10.2/bin/node" "/Users/karl/.nvm/versions/node/v6.10.2/bin/npm" "run" "start"
npm ERR! node v6.10.2
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! webcompat@ start: `source env/bin/activate || . env/bin/activate && python run.py`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the webcompat@ start script 'source env/bin/activate || . env/bin/activate && python run.py'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the webcompat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     source env/bin/activate || . env/bin/activate && python run.py
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs webcompat
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls webcompat
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/karl/code/webcompat.com/npm-debug.log

@miketaylr
Copy link
Member

miketaylr commented Nov 16, 2017

@karlcow you just have to manually activate the virtualenv at that point, then it will work. That's why I reported #1875.

(then you need to set up secrets.py, or you run into the issue @zoepage reported... which yeah, you're working on ❤️ )

@karlcow
Copy link
Member

karlcow commented Nov 16, 2017

On the other hand if I just type.

→ python run.py
Statuses Initialization…
Fetching milestones from Github…
Milestones saved in data/
Milestones in memory
 * Running on http://localhost:5000/ (Press CTRL+C to quit)
 * Restarting with stat
Statuses Initialization…
Fetching milestones from Github…
Milestones saved in data/
Milestones in memory
 * Debugger is active!
 * Debugger PIN: 195-432-804

This is working. My virtual environment is already started too. Because you can't really develop without it.

Let me deactivate and retry

→ deactivate
10:39:20 ~/code/webcompat.com
→ npm run start

This doesn't work either.


→ source env/bin/activate
(env)10:41:20 ~/code/webcompat.com
→ python run.py
Traceback (most recent call last):
  File "run.py", line 41, in <module>
    raise ImportError('{0}\n\n{1}'.format(e, IMPORT_ERROR))
ImportError: cannot import name get_remote_address


==============================================
It seems like you don't have all dependencies.
Please re-run:
    pip install -r config/requirements.txt
==============================================

FAIL again.

→ . env/bin/activate && python run.py
Traceback (most recent call last):
  File "run.py", line 41, in <module>
    raise ImportError('{0}\n\n{1}'.format(e, IMPORT_ERROR))
ImportError: cannot import name get_remote_address


==============================================
It seems like you don't have all dependencies.
Please re-run:
    pip install -r config/requirements.txt
==============================================

and FAIL again.

ok going back to my traditional way of doing things with mkvirtualenvwrapper.

→ workon webcompatcom
(webcompatcom) 10:44:58 ~/code/webcompat.com

@miketaylr
Copy link
Member

you just have to manually activate the virtualenv at that point, then it will work.

To be more clear,

source env/bin/activate

@karlcow
Copy link
Member

karlcow commented Nov 16, 2017

→ cp config/secrets.py config/secrets.py.bkp
(webcompatcom) 10:47:28 ~/code/webcompat.com
→ cp config/secrets.py.example config/secrets.py
(webcompatcom) 10:47:47 ~/code/webcompat.com
→ python run.py
Statuses Initialization…
Fetching milestones from Github…
It failed with 404 Client Error: Not Found for url: https://api.github.com/repos/milestones!
We will read from data/milestones.json.

Milestones in memory

The OAUTH_TOKEN is not configured in your config file.
You will need to set up one on github for testing your
local developments.
Read Instructions at
https://github.com/webcompat/webcompat.com/blob/master/CONTRIBUTING.md#configuring-the-server

@karlcow
Copy link
Member

karlcow commented Nov 16, 2017

Let's try by erasing config/secrets.py

(webcompatcom) 10:51:29 ~/code/webcompat.com
→ rm -rf config/secrets.py
(webcompatcom) 10:51:57 ~/code/webcompat.com
→ python run.py
Statuses Initialization…
Fetching milestones from Github…
It failed with 404 Client Error: Not Found for url: https://api.github.com/repos/milestones!
We will read from data/milestones.json.

Milestones in memory

The OAUTH_TOKEN is not configured in your config file.
You will need to set up one on github for testing your
local developments.
Read Instructions at
https://github.com/webcompat/webcompat.com/blob/master/CONTRIBUTING.md#configuring-the-server

This is working too.
Hmmm?!…

Aaaaah… secrets.pyc

→ rm -rf config/secrets.pyc 
(webcompatcom) 10:54:01 ~/code/webcompat.com
→ python run.py
Traceback (most recent call last):
  File "run.py", line 41, in <module>
    raise ImportError('{0}\n\n{1}'.format(e, IMPORT_ERROR))
ImportError: import_string() failed for 'config'. Possible reasons are:

- missing __init__.py in a package;
- package or module path not included in sys.path;
- duplicated package or module name taking precedence in sys.path;
- missing module, class, function or variable;

Debugged import:

- 'config' not found.

Original exception:

ImportError: No module named secrets


==============================================
It seems like you don't have all dependencies.
Please re-run:
    pip install -r config/requirements.txt
==============================================

@karlcow
Copy link
Member

karlcow commented Nov 16, 2017

Oh wait shoot… The initial message in @zoepage issue is

It failed with 404 Client Error: Not Found for url: https://api.github.com/repos/milestones!

Recreating secrets.py

(webcompatcom) 10:56:11 ~/code/webcompat.com
→ cp config/secrets.py.example config/secrets.py
(webcompatcom) 10:59:15 ~/code/webcompat.com
→ rm -rf config/*.pyc
(webcompatcom) 10:59:29 ~/code/webcompat.com
→ ls -al config
total 64
drwxr-xr-x  10 karl  staff   320 16 nov 10:59 .
drwxr-xr-x  35 karl  staff  1120 16 nov 10:40 ..
-rw-r--r--   1 karl  staff  4494 10 nov 08:10 __init__.py
drwxr-xr-x   5 karl  staff   160 29 sep  2016 __pycache__
-rw-r--r--   1 karl  staff   228  1 nov 08:45 deploy.ignore
-rw-r--r--   1 karl  staff  2123 10 nov 08:09 environment.py
-rw-r--r--   1 karl  staff   216 30 aoû 06:41 requirements.txt
-rw-r--r--   1 karl  staff  2510 16 nov 10:58 secrets.py
-rw-r--r--   1 karl  staff  2654 16 nov 10:47 secrets.py.bkp
-rw-r--r--   1 karl  staff  2510 30 aoû 06:41 secrets.py.example

Let's run.

→ python run.py
Statuses Initialization…
Fetching milestones from Github…
It failed with 404 Client Error: Not Found for url: https://api.github.com/repos/milestones!
We will read from data/milestones.json.

Milestones in memory

The OAUTH_TOKEN is not configured in your config file.
You will need to set up one on github for testing your
local developments.
Read Instructions at
https://github.com/webcompat/webcompat.com/blob/master/CONTRIBUTING.md#configuring-the-server

@karlcow
Copy link
Member

karlcow commented Nov 16, 2017

hehe… let's remove data/milestones.json… we will get there eventually. ;)

Gotcha… pfew

(webcompatcom) 11:02:14 ~/code/webcompat.com
→ rm -rf config/*.pyc
(webcompatcom) 11:02:18 ~/code/webcompat.com
→ rm -rf data/milestones.json 
(webcompatcom) 11:02:26 ~/code/webcompat.com
→ python run.py
Statuses Initialization…
Fetching milestones from Github…
It failed with 404 Client Error: Not Found for url: https://api.github.com/repos/milestones!
We will read from data/milestones.json.

Traceback (most recent call last):
  File "run.py", line 35, in <module>
    from webcompat import app
  File "/Users/karl/code/webcompat.com/webcompat/__init__.py", line 20, in <module>
    app.config.from_object('config')
  File "/Users/karl/.virtualenvs/webcompatcom/lib/python2.7/site-packages/flask/config.py", line 168, in from_object
    obj = import_string(obj)
  File "/Users/karl/.virtualenvs/webcompatcom/lib/python2.7/site-packages/werkzeug/utils.py", line 418, in import_string
    __import__(import_name)
  File "/Users/karl/code/webcompat.com/config/__init__.py", line 132, in <module>
    if not initialize_status():
  File "/Users/karl/code/webcompat.com/config/__init__.py", line 57, in initialize_status
    app.config['STATUSES'] = convert_milestones(milestones_content)
  File "/Users/karl/code/webcompat.com/config/__init__.py", line 69, in convert_milestones
    STATUSES[milestone['title']]['id'] = milestone['number']
TypeError: string indices must be integers

@karlcow
Copy link
Member

karlcow commented Nov 16, 2017

So the error is that data/milestones.json doesn't exist. :)
Now that I know exactly the source, we can fix it.

@karlcow
Copy link
Member

karlcow commented Nov 16, 2017

@zoepage This seems to be a better message :)

→ python run.py
Statuses Initialization…
Fetching milestones from Github…
It failed with 404 Client Error: Not Found for url: https://api.github.com/repos/milestones!
We will read from data/milestones.json.

Oooops.
We can't find /Users/karl/code/webcompat.com/data/milestones.json
Double check that everything is configured properly
in config/secrets.py and try again. Good luck!

Milestones are not initialized.

@karlcow
Copy link
Member

karlcow commented Nov 16, 2017

And pull request done in #1878

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants