Skip to content

Instantly share code, notes, and snippets.

@geovra
Last active October 26, 2021 16:28
Show Gist options
  • Save geovra/fa4aae649747604316d59ee901559b18 to your computer and use it in GitHub Desktop.
Save geovra/fa4aae649747604316d59ee901559b18 to your computer and use it in GitHub Desktop.
Error on deploying Laravel project to Heroku using Git

Error on deploying Laravel project to Heroku using Git

#laravel, #storage, #heroku, #git

Please provide a valid cache path

rm -rf public/storage # // Optional: Undo the effect of: $ php artisan storage:link; This links to storage/app/public and can be deleted. 

mkdir -p bootstrap/cache storage/framework/{sessions,views,cache}

sudo touch storage/framework/cache/data/NULL # // Force git to include this folder by adding an empty file. I can't figure out why git would not register properly the storage directory.
sudo touch storage/framework/views/NULL
sudo touch storage/framework/sessions/NULL

sudo chown -R 48:48 bootstrap storage # Optional
sudo chmod -R 777 bootstrap storage # Optional

git add -A
git status # // Check output to verify the storage folder is present
git commit -m "Lorem ipsum dolor sit amet"

git push heroku master

Why sudo touch?

After many failed attempts, I noticed that Laravel's storage folder would not be included in the heroku commits.

  • The folder was not marked in any .gitignore files
  • The folder was not marked in the .slugignore file By adding the empty files in every indicated directory I make sure that Git will include the storage folder in the next commit. The output from the command: git push heroku master; should now include the storage directory and its dummy files. Done!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment