Deploying Heroku Error

I am in the last steps of deploying Streamlit app in Heroku. I get this error:

setup.sh: 3: setup.sh: cannot create ~.streamlit/config.toml: Directory nonexistent.

How can I create config.toml. I using linux.

Here is my setup.sh file

mkdir -p ~/.streamlit/

echo "\ 
[server]\n\
headless = true\n\
port = $PORT\n\
enableCORS = false\n\
\n\
" > ~/.streamlit/config.toml

Github repository: https://github.com/shakasom/crime-eda-app

Hey!

You have a typo in one of your files in the repo (requirments.txt -> requirements.txt), which probably causes the build to fail. But it doesn’t explain why the ~/.streamlit directory is not created.
I have pretty much the same setup (following this guide: streamlit heroku guide), but I haven’t run into the same issue. Check the guide, maybe you missed a step in the heroku setup. Otherwise someone else might be able to help here :slight_smile:

1 Like

Thanks. As you said the error was unrelated to the typo in requirements.txt file. I still can not figure out.

Hey @shakasom,

Your setup.sh looks like it’s creating the ~/.streamlit/config.toml file successfully. It’s not formatting that file correctly, however - you don’t need the backslashes and newline character in there. This will work better:

mkdir -p ~/.streamlit

echo "[server]
headless = true
port = $PORT
enableCORS = false
" > ~/.streamlit/config.toml

This isn’t the issue preventing your app from launching, however - that looks like it’s likely due to conflicts in your Pipfile.lock. (A side note: there’s no reason to have both requirements.txt and Pipfile/Pipfile.lock in your project - they’re just two different ways to declare your Python dependencies.) I’d suggest removing both Pipfile and Pipfile.lock, and just using requirements.txt instead, for simplicity’s sake.

I’ve created a sample Streamlit-on-Heroku repo that you can check out if you’re still having trouble. It’s mostly equivalent to what you’ve done, but it specifies a Python 3 runtime, has a simplified requirements.txt, and doesn’t create a credentials file, which is actually unnecessary (though there’s no harm in adding one!).

4 Likes

Thanks, @tim With your example I could deploy the app successful in Heroku.

1 Like

“Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch”,
Why am I getting this error while deploying my Streamlit app on Heroku??

1 Like

add this in your proc file

web: sh setup.sh && streamlit run --server.port $PORT yourapp.py

1 Like

I had the same problem and struggled quite a lot. What worked for me was to change the main file name from main to app. Hope it may help someone !

Hi shakasom,

I think you have not added a line in the setup.sh file where we create the required directories.

Kindly add the line given below as the first line -

mkdir -p ~/.streamlit/

Thanks,
Please let me know if it worked :slight_smile: