Until recently my Django projects would debug fine using launch.json file. But it stopped working today and I have no idea about it.
Changes made by me in system were:
Clean-Installing Windows
Installing python in default path just for current user and not all users
Problem Description:
As soon as I click F5 key the debugger starts for some milliseconds and stops automatically without any prompt. As it does not shows any error I tried to log errors by nothing in it. It does not even load terminal to run commands.
The added configuration in launch.json file is as below:
{
"configurations": [
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}\\manage.py",
"args": [
"runserver"
],
"django": true,
"justMyCode": true,
"logToFile": true,
"console": "integratedTerminal",
"cwd": "${workspaceFolder}",
"host": "localhost"
}
]
}
Can someone help to troubleshoot this, I have already tried:
Creating new projects
Reinstalling Python
Creating new environment
Resetting VS Code Sync Settings
Run other dubug configurations {they are working fine)
Changing django debug configuration
My current options are:
Research more (Already spent a hours would take more)
Wait for solution by someone
Clean Install Windows and all software's (Would be like BhramaAstra)
Posting answer within few minutes of posting question seems weird but I got a solution that could help to get perfect answer to my problem.
The problem was the python environment path: I created environment in documents folder of C drive of current non-admin user hoping of no issues since python is installed for just the current user in default path. But as soon as created new environment in current user directory the debugger started working normally.
The issue is related to permissions and file paths, hope this helps to get solution to new questions generated:
Why can't I use Documents folder for creating a python environment?
Is there some other solution to my actual problem?
Adding images for further details:
Debugger not working from this environment -
Debugger working as usual if environment created here -
Related
Is it possible to both Dockerize a Django app and still be able to debug it using Visual Studio Code's debugging tool? If yes, how? E.g, using docker-compose to run Django app, postgres, and a redis instance and be able to debug the Django app via Visual Studio Code.
Yes, this is possible.
I've done it with a NestJs app and should be a similar setup.
Expose a specific port on the Django app service in the compose file first.
Create the launch.json file the following configuration, then replace <port-exposed-on-container> and <directory-on-container> with real values.
{
"version": "0.2.0",
"configurations":
[
{
"name": "Docker: Attach to Node",
"type": "node",
"request": "attach",
"port": <port-exposed-on-container>,
"address": "localhost",
"localRoot": "${workspaceFolder}",
"remoteRoot": "/<directory-on-container>",
"protocol": "inspector",
"restart": true
},
]
}
I'm trying to use a use cloud build for my cloud run project. I have this cloudbuild.json:
{
"steps": [
{
"name": "gcr.io/cloud-builders/docker",
"args": ["build", "-t", "eu.gcr.io/$PROJECT_ID/keysafe", "."]
},
{
"name": "gcr.io/cloud-builders/docker",
"args": [
"push",
"us-central1-docker.pkg.dev/${PROJECT_ID}/my-docker-repo/myimage"
]
}
],
"options": {
"logging": "CLOUD_LOGGING_ONLY"
}
}
And I keep getting a permission denied error. I've tried running it without a service account and using my permissions (I'm the owner), and with a service account even with the owner role.
It was originally working but since my project transitioned from Container registry to Artifact repository, I was getting an error
generic::invalid_argument: generic::invalid_argument: if 'build.service_account' is specified, the build must either (a) specify 'build.logs_bucket' (b) use the CLOUD_LOGGING_ONLY logging option, or (c) use the NONE logging option
That error persisted through both my account and the service account, which is why I switched to building from a cloudbuild.json file, not just my Dockerfile alone.
All the other Stack Overflow articles I've found suggest permissions to assign, but the service account and I have owner permissions and even adding the suggested permissions on top of Owner did not help.
Here are the permissions of the service account:
Here is the trigger configuration:
If anyone ends up in my position this is how I fixed it.
I ended up deleting the Cloud Run and Build and then recreated them. This gave me a pre-made cloudbuild.yaml which I added the option logging: CLOUD_LOGGING_ONLY, still using the same service account. I'm not sure why this fixed it but it does seem to be working.
I'm trying to follow the instructions I found here for debugging a Python SAM application in VS Code
https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-using-debugging-python.html
I'm not sure why they don't use sam build in the expamle, and point to .aws-sam/build but that's what I'm attempting.
My launch.json looks like this:
{
"version": "0.2.0",
"configurations": [
{
"name": "SAM CLI Python debug test",
"type": "python",
"request": "attach",
"port": 5890,
"host": "localhost",
"pathMappings": [
{
"localRoot": "${workspaceFolder}/.aws-sam/build",
"remoteRoot": "/var/task"
}
]
}
]
}
I'm triggering the Lambda's directly for now and so I'm invoking them like this:
sam local invoke -d 5890
I'm then putting a breakpoint at the beginning of the Lambda I find in the build folder, but when I start the debugger in VS Code it executes the Lambda without stopping at the breakpoint.
I created a GitHub repo with the test project I'm using and description of how I'm using it.
https://github.com/rupe120/aws-sam-python-debugging-test
Could someone help point me at what I'm missing in my setup?
So, the recommended way to do this is with the AWS Toolkit extension.
https://github.com/awslabs/aws-sam-cli/issues/1926#issuecomment-616600799
So the docs suggest using a localRoot of "${workspaceFolder}/hello_world/build" (assuming one is using the Hello World template). However, it only works when removing the build at the end of the path:
"localRoot": "${workspaceFolder}/hello_world"
This way, I got it to work without the AWS Toolkit.
I'm developing a PWA using Ionic 3.
Normally the JavaScript files generated by the build to browser process of Ionic 3 are in www/build folder.
I wish to change this folder to www/build/v1 and, of course, keep the application working.
How could I change the build process of Ionic 3 to achieve this result?
The simplest way is add "config" section to your package.json
{
"name": "projectname",
"version": "0.0.1",
"author": "Ionic Framework",
...,
"config": {
"ionic_www_dir": "www/v1",
"ionic_build_dir": "www/v1/build"
},
"dependencies": {
...
}
You can read "Custom Project Structure" here ionic docs.
You may want to try the config option in the package.json file to provide custom build configuration.
To get started, add a config entry to the package.json file. From there, you can provide your own configuration file.
Here's an example of specifying a custom configuration:
"config": {
...
"ionic_rollup": "./config/rollup.config.js",
"ionic_cleancss": "./config/cleancss.config.js",
...
},
You may want to see this Ionic documentation for more information.
I'm using jest to write tests in my ReactJS application.
So far, to run my test suite, I need to type 'npm test'.
Here's the snippet from package.npm:
"scripts": {
"test": "./node_modules/.bin/jest",
(other stuff)
},
"jest": {
"unmockedModulePathPatterns": ["<rootDir>/node_modules/react"],
"scriptPreprocessor": "<rootDir>/node_modules/babel-jest",
"testFileExtensions": [
"es6",
"js"
],
"moduleFileExtensions": [
"js",
"json",
"es6"
]
},
Is it possible to run those tests within my IDE (IDEA/WebStorm) directly, preserving the configuration? I'm not a js guy, but for example WebStrom works perfectly fine with Karma. Shouldn't this be possible with jest-cli either?
To make Jest test results shown in a tree view (like karma, etc.), a special integration is needed. WebStorm doesn't yet support Jest. Please vote for WEB-14979 to be notified on any progress.
EDIT: as of March 2017 the first version of Jest integration at WebStorm has been released.
In WebStorm 9+ You can set this up as follows:
Install Jest CLI: npm install --save-dev jest-cli
Create node run configuration with javascript file set to node_modules/.bin/jest, and application parameter to --runInBand. runInBand tells jest to run in single process, otherwise there's a port conflict when running multiple node processes in debug mode
Create some tests and run configuration in Debug mode (Ctrl-D/CMD-D). If you set breakpoints in your test or app code they should hit
It would be great though if you could click on file:line numbers in the output to go directly to the code.
app_sciences's answer is awesome, but does not work for Windows.
For windows, you can use next configuration:
Provided configuration is taken from here
For IDEA I'm using https://confluence.jetbrains.com/display/IDEADEV/Run+Configurations for that purposes. For WebStorm it seems you can add your config by yourself https://www.jetbrains.com/webstorm/help/creating-and-editing-run-debug-configurations.html . The configuration you are talking about is on the software level. If you will configure to run it via your IDE it will definitely will run within the ENV variables and paths given, you just need to add the needed global paths and the commands to run.