outreachy / website

Code for the Outreachy website, based on Python, Django, and Bootstrap.
https://www.outreachy.org
GNU General Public License v3.0
246 stars 235 forks source link

Error while doing the project setup #492

Closed mridubhatnagar closed 3 years ago

mridubhatnagar commented 3 years ago

I am trying to set up the project on my local system based on the steps mentioned in the repository's README.md file but I am facing the following issue when I am trying to access the web applications URL. I am able to access the admin panel though.

Can you guide me on how to do the project setup?

Screenshot from 2021-08-21 21-29-03

sagesharp commented 3 years ago

I think that error occurs when either you didn't install the npm packages, or you didn't run the manage.py runserver command with the npm package prefix. Please tell me exactly what commands you ran before you got this error.

mridubhatnagar commented 3 years ago

@sagesharp I followed the steps as mentioned in the README.md file.

Did npm install, created virtual environment using pipenv, activated pipenv shell. After activating the pipenv shell ran python manage.py migrate followed by python manage.py runserver

sagesharp commented 3 years ago

@mridubhatnagar You did almost all the right steps! For the last command, the README.md says that you need to run this command:

PATH="$PWD/node_modules/.bin:$PATH" ./manage.py runserver

That first part of the command does something very important. Leaving it off caused the error you encountered. I'll explain why below. If you already know these things, no worries! I just want to make sure other people who run into this error understand what's happening.

You installed some node.js packages with the command npm install. The packages got installed in a local directory in your git repository (node_modules/.bin). A package includes a set of executable files. Setting the "execute" property on a file means it's a program that your computer can execute (run).

You've executed (run) commands in a window called a shell (or terminal). Those commands included things like the npm install command you ran.

Running a command in your shell is actually a short cut -- the shell finds an executable file with that command name, runs it with the arguments you passed, and displays the output from the program on your shell window.

So, running a command actually runs an executable file. Where are these executable files normally stored? You can find out where the executable file for a command is stored by running which. For example, you can find out where the executable file for the ls command is stored:

$ which ls
/bin/ls

So the ls command is an executable file in the directory /bin/.

Executable files can be in many different directories on your computer. By default, the shell looks in a specific set of directories for executable files.

The shell doesn't know that it needs to search the local directory node_modules/.bin/ for executable files. So when it tries to execute a node.js package command, like postcss, it doesn't find the postcss executable file in the default set of directories. And you get the error "/bin/sh postcss not found".

So we need to tell the shell about this new "directory path" to the node.js executable files. That's what the first part of this command does:

PATH="$PWD/node_modules/.bin:$PATH" ./manage.py runserver

It's basically giving the shell a hint, saying, "look here for the executable files for any command you want to run."

This blog post has a good write up for what a shell "path" is.

I hope this helps! Let me know if you run into any more issues.

sagesharp commented 3 years ago

Ah, I thought of one more thing that might be an issue. You will also need to make sure you run the command while in your git repository. That may mean you need to change directories, as sometimes invoking a virtual environment can cause you to change directories. But if the migrate command succeeded, you're probably in the correct directory.

If you still have trouble after trying the command in my first comment, please copy and paste your full output from your shell window, including the commands and where you are running them.