Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all 97355 articles
Browse latest View live

Why do I get the error when I get an image of the mobile device's gallery: Unable to load asset?

$
0
0

I am using the image_picker package to process the image and then show it when it has been chosen but sometimes it works correctly and at other times the application crashes and when I look at the debug window in the Call stack part I get this error: FlutterError (Unable to load asset: /storage/emulated/0/Android/data/com.example.produmax/files/Pictures/scaled_product.jpg

FlutterError (Unable to load asset: /storage/emulated/0/Android/data/com.example.produmax/files/Pictures/scaled_product.jpg)

This is the code I use to process the image

_seleccionarFoto () async {
  await _procesarImagen(ImageSource.gallery);
}

_tomarFoto () async {
  await _procesarImagen(ImageSource.camera);
}

_procesarImagen(ImageSource tipo) async {
  foto = await ImagePicker.pickImage(
    source: tipo
  );

  if (foto != null) {
    _producto.imagePath = null;
  }

  setState(() { });
}

And this is the code to display the image:

Widget _mostrarFoto() {
  if (_producto.imagePath != null) {
    final String url = utils.completeUrl(_producto.imagePath);
    return FadeInImage(
      image: NetworkImage(url),
      placeholder: AssetImage('assets/jar-loading.gif'),
      height: ScreenUtil.instance.setHeight(300.0),
      fit: BoxFit.contain
    );
  } else {
    return Image(
      image: AssetImage( foto?.path ?? 'assets/no-image.png'),
      height: ScreenUtil.instance.setHeight(300.0),
      fit: BoxFit.cover,
    );
  }
}

and this is where I use the functions _seleccionarFoto() and _tomarFoto()

return Scaffold(
  key: _scaffoldKey,
  appBar: AppBar(
  title: _producto == null ? Text('Agregar producto') : Text('Editar producto'),
  centerTitle: true,
    actions: <Widget>[
      IconButton(
        icon: Icon(Icons.photo_size_select_actual),
        onPressed: _seleccionarFoto,
      ),
      IconButton(
        icon: Icon(Icons.camera_alt),
        onPressed: _tomarFoto,
      ),
    ],
  ),


Using "esm" in VSCode's NodeJs Debugger

$
0
0

I am using Vscode.

I have a js file filled with a dozen+ class definitions which I wanted to be available in another jsfile. So I used es6 imports in my other file, main.js

//main.js
import * as Helper from './helperClasses.js';
var myDoggy = new Helper.Pet("Fido");

But that wouldn't run with node, so I installed 'esm' with npm, and made a file called server.js, in which I added

//server.js
require = require("esm")(module/*, options*/)
module.exports = require("./main.js")

Now that runs with the code runner extension, or from a cmd window with the '-r esm' args (i.e. node -r esm server.js). But in the vsCode debugger, I get the following error:

import * as helper from './helperClasses.js';
       ^

SyntaxError: Unexpected token *

I tried changing the configuration settings in launch.json as follows, but that did not work:

"configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch Program",
            "program": "${workspaceFolder}\\game.js",
            "args": ["-r","esm","server.js"]
        }
    ]

I went and changed the .js extensions to .mjs, but then intellisense stopped working...

Is there something I'm missing? This is my first time trying to use Node and I'm just trying to easily import some helper functions.

Building VS Code on Raspberry Pi 4: sqlite3 issue

$
0
0

I can successfully build VS Code from its github repository and instructions on a Raspberry Pi 4 running debian buster. But when I try to launch it via scripts/code.sh from within the vscode directory I run into the following error:

Cannot find module '../build/Release/sqlite'

yet sqlite3 was installed via npm and there is a directory vscode/node_modules/vscode-sqlite3

Digging into the source code under vscode/node_modules/vscode-sqlite3/build/Release (which is the path the error messages refers to) I noticed that it contains the following files:

drwxr-xr-x 3 mark mark    4096 Nov  3 08:52 obj
drwxr-xr-x 5 mark mark    4096 Nov  3 08:55 obj.target
-rw-r--r-- 1 mark mark 1380280 Nov  3 08:54 sqlite3.a
-rw-r--r-- 1 mark mark  273270 Nov  3 08:55 sqlite.a

For comparisons sake I checked out vscode/node_modules/nsfw/build/Release, which is another module that gets built in the default build process. It contains the following files:

-rwxr-xr-x 1 mark mark 102872 Nov  3 08:52 nsfw.node
drwxr-xr-x 3 mark mark   4096 Nov  3 08:52 obj.target

Offhand this suggests to me that some compilation step is being missed, so that a sqlite.node file is not being created (the .node files appear to be binary/library type files). But I'm not sure what step is being missed.

The basic process I'm using to build VS Code from source is documented here. In summary, it's basically:

cd vscode
yarn
yarn watch

The first call to yarn appears to be needed to resolve dependencies (which I was assuming meant things like sqlite.node were being created, but obviously not).

How do I disable: [js] File is a CommonJS module; it may be converted to an ES6 module

$
0
0

The following is what I want to disable:

[js] File is a CommonJS module; it may be converted to an ES6 module.

I can't find it in settings.
Help appreciated as this is really annoying.

Visual studio code can't detect emulator device or phone connected

$
0
0

I was running my app with vscode using Android emulator or my phone, however all of a sudden vscode could not identify any device or emulator that I connect (no devices). phone is in debug mode or even the android emulator. Also When I try starting the emulator I get this warning enter image description here

How to remove GitHub password from VSCode?

$
0
0

I have cloned one of my GitHub repositories with VSCode and I have made some commits. VSCode has asked me for my GitHub password when I have done the first commit.

I have rebooted the computer and now I can make commits as before, but VSCode does not ask for my password. It seems that the password has been stored. But this computer is not my computer and I do not want that somebody else could use my account.

How can I make VSCode forget my GitHub password?

I have tried the git command:

git config --global --unset-all user.email

But VSCode still lets me commit without asking.

FLASK : plotly : Error: module 'index' has no attribute 'app.server'

$
0
0

the context

I am debugging an application using Visual Studio Code (VSCode).

Breakpoints ARE NOT hit!

  • The breakpoints ARE NOT hit when I am using the launch.json (See [1])

  • I can debug with this launch.json (See [2]) but the debugger does not stops at the breakpoint !

I would like VSCode to stop on my breakpoints when necessary

**What is the correct configuration for launch.json to hit the breakpoints? **

Thank you for the time you are investing helping me!

the hierarchy of the project

  • launch.json
  • index.py See [4]
  • app.py See [3]
  • pages
    • index.py
    • transactions.py
  • launch.json is described here below [1]

the issue : Error: module 'index' has no attribute 'app.server'

The Error message is displayed after clicking on 'Start debugging > F5' = Error: module 'index' has no attribute 'app.server'

I tried dozens of ways to set the "FLASK_APP": "index:app.server" but they generate diverse error messages :

  • "FLASK_APP": "index:app.server" generates this error Error: A valid Flask application was not obtained from "index:app".

  • "FLASK_APP": "index.py" generates this error Error: Failed to find Flask application or factory in module "index". Use "FLASK_APP=index:name to specify one.

for information : gunicorn command (working)

here is a command available in azure-pipelines.yml running the plotly app :

  • gunicorn --bind=0.0.0.0 --timeout 600 index:app.server

attached files

[1] launch.json - non working

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Flask",
            "type": "python",
            "request": "launch",
            "module": "flask",
            "env": {
                "FLASK_APP": "index:app.server",
                "FLASK_ENV": "development",
                "FLASK_DEBUG": "1",
                "FLASK_RUN_PORT": "8052"
            },
            "args": [
                "run",
                "--no-debugger",
                "--no-reload"
            ],
            "jinja": true
        }
    ]
}

[2] launch.json - working but breakpoints are not hit

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${workspaceRoot}\\index.py",
            "console": "integratedTerminal"
        }
    ]
}

[3] webapp.py

# -*- coding: utf-8 -*-
import dash

app = dash.Dash(
    __name__, meta_tags=[{"name": "viewport",
                          "content": "width=device-width, initial-scale=1"}]
)
server = app.server
app.config.suppress_callback_exceptions = True

index.py - root of the application

# -*- coding: utf-8 -*-
import dash_html_components as html
import dash_core_components as dcc
from webapp import app
from dash.dependencies import Input, Output
from pages import (
    transactions, index)


# Describe the layout/ UI of the app
app.layout = html.Div([
    dcc.Location(id="url", refresh=False),
    html.Div(id="page-content")
])


# Update page
@app.callback(Output("page-content", "children"),
              [Input("url", "pathname")])
def display_page(pathname):
    if pathname == "/dash/index":
        return index.layout
    if pathname == "/dash/transactions":
        return transactions.layout
    else:
        return index.layout


if __name__ == "__main__":
    app.run_server(debug=True, port=8051)

In python, VSCode debugger won't step into external code. Can't figure out how to edit "justMyCode" in launch.json

$
0
0

I have been referring to https://code.visualstudio.com/docs/python/debugging#_justmycode and How to disable "just my code" setting in VSCode debugger?

Despite many attempts, still unable to figure out where to put "justMyCode": false in launch.json. Everywhere I try to put it the editor says "Property justMyCode is not allowed "

Below is a copy of my launch.json. Can someone tell me what should I do ?

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",

    "configurations": [
        {
            "name": "Python: Current File (Integrated Terminal)",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": false
        },
        {
            "name": "Python: Remote Attach",
            "type": "python",
            "request": "attach",
            "port": 5678,
            "host": "localhost",
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "."
                }
            ]
        },
        {
            "name": "Python: Module",
            "type": "python",
            "request": "launch",
            "module": "enter-your-module-name-here",
            "console": "integratedTerminal"
        },
        {
            "name": "Python: Django",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/manage.py",
            "console": "integratedTerminal",
            "args": [
                "runserver",
                "--noreload",
                "--nothreading"
            ],
            "django": true
        },
        {
            "name": "Python: Flask",
            "type": "python",
            "request": "launch",
            "module": "flask",
            "env": {
                "FLASK_APP": "app.py"
            },
            "args": [
                "run",
                "--no-debugger",
                "--no-reload"
            ],
            "jinja": true
        },
        {
            "name": "Python: Current File (External Terminal)",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "externalTerminal"
        },
        {
            "name": "Debug Unit Test",
            "type": "python",
            "request": "attach",
            "justMyCode": false
        }
    ]
}


How to install PIP for Python 3.6?

$
0
0

I want to code on Visual Studio Code. When I run code, it says:

There is no Pip installer available in the selected environment

and when I install it on Ubuntu it says

E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem.

VSCode: How to import a module from my code path to another file in the same path?

$
0
0

I'm trying to debug my python app using VSCode. But I cannot configure my environment right. Attempting to import a class from one folder in my source path to another, gives me this message:

Traceback (most recent call last):
  File "/Users/mb/Library/source/sandbox/lib/lib.py", line 1, in <module>
    from app.main import MyClass
ModuleNotFoundError: No module named 'app'

I created a simple app to exhibit the problem. My source path looks like this:

sandbox
+-- .vscode
    --- launch.json
+-- app
    --- __init__.py
    --- main.py
+-- lib
    -- lib.py
# main.py

class MyClass:
    def __init__(self):
        print('Creating object...')
    def print_message(self, message):
        print(message)
# lib.py

from app.main import MyClass


myclass = MyClass()
myclass.print_message('hello, world!')

Trying to run lib.py using the default configuration to run current file I get the error message above.

Additionally, I created a .vscode/launch.json to set the working directory, but to no avail. Here is my launch.json:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "cwd": "${workspaceFolder}"
        },
        {
            "name": "Python: Module",
            "type": "python",
            "request": "launch",
            "module": "main"
        }
    ]
}

I'm sure, I'm missing a simple setup, but I can't put my finger on it.


Note

  • The interpreter used is: Python 3.7.5 64-bit
  • The above code works fine in PyCharm.

How to get promp-box for unsave files on closing in visual studio code on closing editor

$
0
0

How to configure setting so that i get prompt for unsave file in vs-code like visual studio when closing vscode editor like visual studio as given in below image

enter image description here

I can't install any extensions on vscode

$
0
0

enter image description here

I tried a lot of methods to install, but the following log does not install. I'm having a problem with other extensions not being installed. Is there a solution for this?

How to switch word wrap on and off in VSCode?

$
0
0

When using code files, you typically don't need longer lines to wrap around. However, with .md files this is in fact rather useful. However, I can't seem to find the option to enable word wrap so longer lines will be wrapped.

To reproduce, open VSCode resized to a small-enough window, and enter the following text in a new document:

This is my test lorem ipsum. This is my test lorem ipsum. This is my test lorem ipsum. This is my test lorem ipsum. This is my test lorem ipsum. This is my test lorem ipsum. This is my test lorem ipsum. This is my test lorem ipsum. This is my test lorem ipsum.
A linebreak before this. 

The effect is this:

Example of missing word wrap

I'm trying to get the horizontal scrollbar to stay away, having line 1 wrap around at the right side of the window.

I've done a few things to answer my own question:

  • Search Stack Overflow: zero results at the time of writing this;
  • Meticulously going through the menu of VSCode: didn't find it;
  • Using the Command Palette with "wrap": gives no matching commands.

Perhaps it's not possible, and I'd need to file a feature request? Or am I missing something?

Note that I'd like to be able to turn it on and off quickly. For one, @PanagiotisKanavos mentioned in comments this solution to change wrapping behavior in the settings, but I'm looking for a quick command or menu option to do this (much like Notepad++ and Sublime Text 2 have).

VsCode - Bind keyboard-key to scroll horizontaly

$
0
0

Is there a way to bind a keyboard-key to scroll horizontally?

I tried many different things and I cannot seem to put it together.

Warning: unrecognized cop Rails/

$
0
0

I have problems with Rubocop in Vs-code. I get the error

Warning: unrecognized cop Rails/ActionFilter found in /path/to/yml/with/cops
...
Warning: unrecognized cop Rails/Output found in
...
Warning: unrecognized cop Rails/UnknownEnv found in
...
# The list goes on...

I run:

Rubocop version rubocop-0.76.0

VS-code Version: 1.39.2

ruby-rubocop extention in vs code: 0.8.1

macOS Catalina: 10.15 (Problem existed in earlier versions like mojave)


I find very little about this problem. Basically only thing I found was this. And I already have require rubocop-rspec in my rspec yml file so no success with the proposals from that thread.

What can I do to solve this? My co-workers will soon start to call me Mr. Lint-failure


Omnisharp server does not start on VS Code (WSL)

$
0
0

I'm using:

  • Windows 10 Professional
  • VS Code WSL:Ubuntu v1.39.2
  • Omnisharp C# Extension v1.21.5

Problem

When I look at the Omnisharp logs after installing I get the following error:

Starting OmniSharp server at 11/4/2019, 8:14:40 PM
Target: /c/Users/path/to/my/solution.sln
[ERROR] Error: spawn /home/wsl-user/.vscode-server/extensions/ms-vscode.csharp-1.21.5/.omnisharp/1.34.5/run ENOENT

I've googled around and can see that this error is usually caused by not having C:\Windows\System32\ on your system path. However, I've made sure that is present and have restarted VS Code along with uninstalling and installing the extension numerous times, to no avail.

Some of the issues I've seen and tried:
https://github.com/OmniSharp/omnisharp-vscode/issues/2525
https://github.com/OmniSharp/omnisharp-vscode/issues/32

Any suggestions would be welcome

Make Visual Studio Code open in clean state

$
0
0

I work in multiple projects spread in multiple folders on macOS. I usually start working on them by running:

cd ~/workspace/project-a
code .

That always causes a new window to be open with the last files I worked on that project. My next move is to close all tabs, if the editor was split I have to do that as many times as split editors I had.

Is there a setting that would allow me to always start on a clean state?

My settings that I believe are related to this issue are the following:

"window.restoreWindows": "none",
"files.hotExit": "onExitAndWindowClose",

I tried off for files.hotExit but the behaviour remained the same.

Also if possible, where is this information stored (open files for given folders)? Is that a dot file inside the folder or elsewhere inside Visual Studio Code installation?

How to debug NHibernate in netcore app on linux and visual studio

$
0
0

I managed to get my .net development project and environment over to linux. So far, I managed to resolve all issues but for some reason, I cannot adjust the debug mode to show the details for exceptions in nuget packages.

I'm sure this has to do with missing PDB/symbols in the bin. For example, I'm using NHibernate and see that NHibernate.dll throws an exception which is obviously some mapping issue or similar. But I cannot get details what caused the exception.

Anybody out there who solved that? "Enable just my code" is of course set to false, I used MicrosoftSymbolServer to fetch some of the missing PDBs, but NHibernate not among them. Was reading they use sourcelink now? But enabling it in launch.json didn't help. For the sake of completeness, here's my launch.json:

{
            "name": ".NET Core Launch (web, local DB)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            // If you have changed target frameworks, make sure to update the program path.
            "program": "${workspaceFolder}/myproject/bin/Debug/netcoreapp3.0/myproject.dll",
            "args": ["web.settings.local.json"],
            "cwd": "${workspaceFolder}/myproject",
            "stopAtEntry": false,
            // Enable launching a web browser when ASP.NET Core starts. For more information: https://aka.ms/VSCode-CS-LaunchJson-WebBrowser
            "serverReadyAction": {
                "action": "openExternally",
                "pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"                
            },
            "env": {
                "ASPNETCORE_ENVIRONMENT": "Development"
            },
            "sourceFileMap": {
                "/Views": "${workspaceFolder}/Views"
            },
            "justMyCode": false,
            "symbolOptions": {
                "searchPaths": [],
                "searchMicrosoftSymbolServer": false
            },
            "sourceLinkOptions": {
                "*": {
                    "enabled": true
                }
            }
        },

How to paste clipboard text in VS Code Terminal

$
0
0

I have updated the VS Code today in my windows 7 machine. VS Code introduced Terminal inside the VS Code.

Right-Click is disable in Terminal. Is there any Keyboard shortcuts to paste the text in VS Code.

Visual Studio Code Tab Key does not insert a tab

$
0
0

I'm using Visual Studio Code as my editor for Unity. I did a search on google but wasn't able to find anything about my issue.

The issue is simple, pressing ⇥ Tab in the editor does nothing. I'm expecting it to insert 4 spaces.

Anyone know what I can do to get ⇥ Tab working like expected?

Viewing all 97355 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>