Unable to push on heroku - django

Processing /D:/bld/astroid_1640971040574/work
remote: ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/D:/bld/astroid_1640971040574/work'
I am having above error while trying to upload to heroku using git push heroku main.
How can I push the changes?

Either what you are specifying includes a PATH (a local path which is only valid on your workstation, you local development environment).
Or what you are executing includes a path.
On the specification side, as explained here, check your requirements.txt file content (no path should be there)
On the execution side, make sure your server.js is not using PWD.

might be your project is in master branch of github.But you are trying to push main branch in heroku. Please check the branch in github where you uploaded the project carefully then push accordingly. Please upload with the screanshot of all command you given there.

Related

Build on Vercel with Prisma is not working recently (how to include schema.prisma file?)

I developed SvelteKit app with Prisma and am trying to deploy it on Vercel.
In package.json, configuration below should be set so that schema.prisma file located in root path is available when app is deployed.
"postbuild": "cp prisma/schema.prisma .vercel_build_output/functions/node/render/ && cp node_modules/#prisma/engines/*query* .vercel_build_output/functions/node/render/",
Problem is an error occurred during the build on Vercel, but that wasn't occurred before (~ May 2022).
I guess cause of the error is related to recent update of SvelteKit and found that directory of .vercel_build_output that is generated during the build is changed to the new .vercel recently. However, the new path structure for index.js (i.e. .vercel/output/functions/render.func/home/s/test/discord-bot-frontend/.svelte-kit/output/server/index.js) is so different from the previous (i.e. .vercel_build_output/functions/node/render/) that I cannot find right path for it.
Would you please let me know right setting for package.json?
Error message:
> discord-bot-frontend#0.0.1 postbuild
> cp prisma/schema.prisma .vercel_build_output/functions/node/render/ && cp node_modules/#prisma/engines/*query* .vercel_build_output/functions/node/render/
cp: cannot create regular file ‘.vercel_build_output/functions/node/render/’: No such file or directory
Error: Command "npm run vercel-build" exited with 1
I found that there is no need to modify .vercel_build_output now. In other words, the post build is not needed anymore.
It is probably because latest Vercel handles this point.

how to run a one-off task on cloudfoundry to upload data before starting Python app

Hi this is my first experience trying to deploy a Python app on cloud using CF. I am having issues deploying my app; I sincerely appreciate if anyone can help me or point me to the right direction to solve the issue.
The main problem is the app that I am trying to deploy is large size due to a lot of python dependencies. The size of my app directory is 200 Kb. The first error I observed was: Staging fails due to "Failed to upload payload for droplet" . I think the reason is when all Python dependencies are downloaded from requirements.txt file and finally the droplet is created its size is too large for upload. The droplet size=982. 3 Mb.
The first solution I tried was vendoring app where I created a vendor directory containing all python dependencies but the size of vendor directory was greater that 1Gb, which causes the upload size exceed 1Gb limit and leads to failure in uploading app files.
The second solution I am working on is to upload all installed Python libraries on an object store (in my case S3 bucket which is bounded to my app) and then download the dependencies folder called Pypackages to the app's root directory: /home/vcap/app, so I want to have /home/vcap/app/Pypackages exist before my app starts on the cloud. But I couldn't do it successfully yet. I have included a python script in my app directory which downloads files from S3 bucket successfully. (I have put the correct absolute path for download in downloadS3.py script ie, /home/vcap/app/Pypackages) I want to run this script using "python downloadS3.py" as a one-off task. First I tried the solution here : Can I have multiple commands run in a manifest.yml file?
and although I can see the status of the task is SUCCEED via '$cf tasks my-app-name' , /home/vcap/app/Pypackages does not exist.
I also tried to run one-off task as the steps below:
1-
$ cf push -c 'python downloadS3.py && sleep infinity' -i 1 --no-route
2-
$ cf push -c 'null'
I have printed the contents of /home/vcap/app on my app, ie when app is started and I enter the url in my browser (I don't know what is the right way to see the contents of root directory). Anyway, the problem is Pypackages are not downloaded to the correct root directory. I am not sure if I am running the one-off task in a wrong way or if there is a better solution to make my app work.
I appreciate any helps! (edited)
Diego Cells stage apps and upload droplet to blobstore via cloud controller, the max file can be uploaded is configurable at Ops Manager > TAS for VMs > Application Developer Control > Maximum File Upload Size (MB), default is 1024MB. Seems this is causing restriction, if you can get it increased with your admin help...
Tasks run in their own containers so possibly not an option. I think Python buildpack collects and install the packages before creating the droplet, so don't think copying packages directly to /app directory will be of much help.
If you have data files then you can use .profile file and do some scripting to copy them from S3 or server/NFS location into the /app directory. Something like
wget http://s3.location.com/data_files
cp data_files /home/vcap/app/
But if all these are packages and increasing the size is not feasible then you may need to look to break the app..

post_receive hook in git: how does it checkouts my non-git folder?

I am using webfaction for my web deployment.
I have a Django app at: webapps/django_app/project_name/
I have a Git repo at: webapps/git_app/repos/my_repo.git
my_repo.git is a bare repository. It is not a working directory.
whenever I push from my local development computer to the remote (webfaction --> my_repo.git), I want my django_app to get the pushed code.
I followed this post which works fine. But no explanation of how this works is given.
I have added these two lines in post_recieve hook in my_repo.git.
#!/bin/sh
GIT_WORK_TREE=/home/username/webapps/django/myproject git checkout -f
GIT_WORK_TREE=/home/username/webapps/django/myproject git reset --hard
what does this two lines actually do?
Moreover, my Djangoapp folder is not a git repo. still whenever push is made to my_repo.git, Djangoapp gets updated. so how does it work?
When you are managing files locally with .git, you typically have two things:
Your git repository, which is contained in the .git directory, and
Your work tree, which is the set of files you are actually editing.
By default, the repository is a subdirectory of the work tree, but this is not a requirement. Setting the GIT_WORK_TREE environment variable directs git to use a different location for your checkout out files.
So the first line...
GIT_WORK_TREE=/home/username/webapps/django/myproject git checkout -f
...is asking git to check out the HEAD of the repository into /home/username/webapps/django/myproject.
The second line...
GIT_WORK_TREE=/home/username/webapps/django/myproject git reset --hard
...makes sure that /home/username/webapps/django/myproject does not have any local changes. reset --hard discards any changes to files that are tracked by git. By "local changes" I mean any changes that you or someone else has made to files in this directory; ideally, there won't be any, but if there were some there, reset -f makes sure that the modified files are overwritten with the version of the file stored in the repository.
For more details on any of the commands listed here, try running git <command> --help for the man page, or see The Git Book.

Boto.conf not found

I am running a flask app on an AWS EC2 server, and have been using boto to access data stored in dynamoDB. After accidentally adding boto.conf to a git commit (and push and pull on the server), I have found that my python code can no longer locate the boto.conf file. I rolled back the changes with git, but the problem remains.
The python module and boto.conf file exist in the same directory, but when the module calls
boto.config.load_credential_file('boto.conf')
I get the flask error IOError: [Errno 2] No such file or directory: 'boto.conf'.
As per Documentation:
I'm not really sure why you are using boto.config_load_credential_file. In general you can pick up the config in a file called either ~/.boto or /etc/boto.cfg.
You can also look at this questions from SO that also answers how to get the configuration for boto: Getting Credentials File in the boto.cfg for Python

Why is git not pushing contents of a folder?

After copying a folder 'myapp' into to my working folder, I do the following to add it to my staging area:
git add .
and then commit the changes:
git commit
Then I push my changes to Heroku:
git push heroku master
So my folder, called 'myapp' is present on heroku, but the problem is that it's completely empty.
When I do the following,
git clone myapp myapp2
the folder clones properly on my local machine with all expected subcontents.
Does anyone know why the subfolders' contents are not being pushed to Heroku properly? What am I doing wrong?
To answer the questions below:
I am doing the git add . in my top level folder (the folder that contains folder myapp). Doing git status shows `no changes added to commit (use "git add" and/or "git commit -a")
Yes, myapp contains files/folders (my django project)
I deleted my .gitignore file because I placed my virtual environment in another place altogeher so it's no longer in my project folder so I don't think that's affecting it.
Ok, I seemed to have solved the problem. Somehow git got in a weird state. I don't really understand how, but for some reason it wasn't adding any of the files in the folder.
I simply copied that folder and gave it a new name, and then followed the exact same process I had been doing all along, and it finally uploaded properly.
By default, you cannot push changes to a checked-out branch of a repository. It usually causes major problems! Here is what usually happens:
$ git push heroku master
...error messages...
To heroku
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'heroku'
Since you haven't mentioned any error messages, I'm assuming that you've added the following to your heroku repository configuration, or you're running a fairly old version of Git:
[receive]
denyCurrentBranch = false
It sounds like you want to check out a fresh copy of the master branch whenever you push a new version to your heroku repository. That can be achieved with a post-receive hook. Create a file in your heroku repository .git/hooks/post-receive, and give it +x permissions.
#!/bin/sh
while read oldrev newrev refname
do
if test "$refname" = refs/heads/master
then
( cd ..; GIT_DIR=.git; git reset --hard )
fi
done
Now, whenever you push a new master branch to heroku, the hook will run and check out the new branch. There are better ways to do this kind of thing, but this is simple.
Summary: By default, when you push changes, it only changes the history but not the working tree. The assumption is that someone might be working on that tree, so doing anything to it could be destructive.