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

VSCode Ftp-Simple Download Ftp-Tree On Click

$
0
0

I'm almost despaired to not find any solution on FTP in Visiual Studio Code.

It's a very powerfull editor and has very talented extensions. But about simple ftp editing, I couldn't find any solution. I'm looking for an extension like Notepad++ FTP. It's simple and doesn't require any setup and works with a few configuration setting.

I used ftp-simple. That's the closest one to NppFtp. But on every connect it attemps to download all ftp tree and waits too much. On simple projects it works fine, but on large projects i.e. has 60K files, I'm waiting for 10-15 minutes it to download the ftp-tree. NppFtp download ftp tree on click.

I've also used deploy, sftp, ftp-sync and other ftp extensions. But couldn't find any solution like NppFtp.


ASP.NET Core 3 MVC : IHost not starting browser unlike IWebHost

$
0
0

ASP.NET Core 3 MVC suggests using IHost instead of IWebHost (HostBuilder replaces WebHostBuilder and .NET Generic Host Settings for web apps).

Here is a section of launch.json

"launchBrowser": {
            "enabled": true,
            "args": "${auto-detect-url}",
            "windows": {
                "command": "cmd.exe",
                "args": "/C start ${auto-detect-url}"
            },
            "osx": {
                "command": "open"
            },
            "linux": {
                "command": "xdg-open"
            }
        },

This doesn't however launch the browser for debugging locally.

  • OS: Linux
  • Editor: VSCode

All of my .json files have problems loading reference/schema from schemastore.azurewebsites.net

$
0
0

I'm working in VS Code and started getting this error yesterday. All of my json files have this error, not just a few. If I remember right there was an update to the program yesterday or the day before. Did the update break something or reset a setting that I forgot I had set?

When looking this up, people are talking about downloading the schema and using it locally, but I would prefer not to have to do that and would instead like to find out why this broke?

I am using a proxy, but as far as I know that hasn't changed. Here's the exact error I'm getting.

Problems loading reference 'https://schemastore.azurewebsites.net/schemas/json/package.json': Unable to load schema from 'https://schemastore.azurewebsites.net/schemas/json/package.json': Unable to connect to https://schemastore.azurewebsites.net/schemas/json/package.json. Error: connect ECONNREFUSED 168.62.224.13:443

VSCode 1.39.x & Python 3.7.x: "ImportError: attempted relative import with no known parent package" - when started without debugging (CTRL+F5))

$
0
0
  • when running Python test from withing VS Code using CTRL+F5 I'm getting error message

    ImportError: attempted relative import with no known parent package

Error message text: "ImportError: attempted relative import with no known parent package"

  • when running Python test from VS Code terminal by using command line

    python test_HelloWorld.py

    I'm getting error message

    ValueError: attempted relative import beyong top-level package

Error Message: "ValueError: attempted relative import beyond top-level package"

Here is the project structure

Project structure

How to solve the subject issue(s) with minimal (code/project structure) change efforts?

TIA!

[Update]

I have got the following solution using sys.path correction:

The subject issue solution using sys.path correction

import sys
from pathlib import Path
sys.path[0] = str(Path(sys.path[0]).parent)

but I guess there still could be a more effective solution without source code corrections by using some (VS Code) settings or Python running context/environment settings (files)?

Can't run 'ruby' using VScode

$
0
0

Actually I found same case already.

Can't execute Ruby file using Powershell

But I couldn't solve it with this answer. I couldn't find where's ruby.exe. I wanted to make a comment but I don't have any reputation, so I'm asking the same question again.


The Problem is simple. When I tried to run ruby on VScode, something problem happened.

The term "ruby" is not recognized as the name of the cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. 

At line:1 char:1"

Keep VS Code cursor on screen

$
0
0

How can I keep the text cursor (caret) on the screen when scrolling in VS Code with Ctrl + up/down?

I've searched for scroll options, text options, extensions, etc. To no avail.

Azure Function in Visual Studio Code - adal-node package error

$
0
0

From my local testing NodeJS code without using Azure Function in Visual Studio Code, I could use adal-node code without error:

let AuthenticationContext = require('adal-node').AuthenticationContext;

However, after I copied this above module.exports in index.js, below error occurred:

[error] Worker was unable to load function ServiceBusQueueTrigger: 'ReferenceError: authenticator is not defined'

Below is package.json settings:

{
  "name": "function",
  "version": "1.0.0",
  "private": true,
  "description": "facing adal-node error",
  "main": "index.js",
  "scripts": {
    "test": "echo \"No tests yet...\""
  },
  "dependencies": {
    "adal-node": "^0.2.1",
    ......
  },
  "devDependencies": {}
}

Below is launch.json settings:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Attach to Node Functions",
      "type": "node",
      "request": "attach",
      "port": 9229, 
      "preLaunchTask": "func: host start"
    }
  ]
}

Below is function.json settings:

{
  "bindings": [
    {
      "name": "mySbMsg",
      "type": "serviceBusTrigger",
      "direction": "in",
      "queueName": "myqueue",
      "connection": "ServiceBus"
    }
  ]
}

How to setup XDebug with VSCode on Ubuntu on a Laravel project?

$
0
0

I'm doing a simple laravel project and I have some code to debug but I can't make the debugging on VSCode work.

I'm on Ubuntu 19.10. I'm using VSCode insiders and Firefox with the XDebug extension. I followed the guide on xdebug.org/wizard but it didn't work.

Here is my xdebug configuration in my php.ini

[xdebug]
zend_extension=/usr/lib/php/20180731/xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_connect_back=1
xdebug.idekey = VSCODE
xdebug.remote_port=9000

Here is my launch.json

"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000

And my php -v

$ php -v
PHP 7.3.11-0ubuntu0.19.10.1 (cli) (built: Oct 24 2019 11:38:49) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.11-0ubuntu0.19.10.1, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v2.8.0, Copyright (c) 2002-2019, by Derick Rethans

I expect to be able to debug my laravel code but when I put a breakpoint in my code, it doesn't work. I am able to catch breakpoints that are in regular php files though.


How do I get intellisense/code-completion working in vscode

$
0
0

I've been working with vscode for quite sometime now but I can never get the intellisense to work the way it does in fully featured IDE's or even how it is portrayed in videos. I created a simple repo. https://github.com/dwayne-roberts/vscode-code-completion-test/tree/master/src

And if you check the screenshots I just cannot get it to work.

enter image description here

It doesn't offer the methods or properties on the class. Only way I can seem to get it to work is to import the class directly.

Can anyone shine some light on this conundrum. I'm convinced it should be able to work this way.

Set PYTHONPATH for local Jupyter Notebook in VS Code

$
0
0

I'm using Visual Studio 1.39.2 on Windows 10. I'm very happy that you can run Jupyter Notebook natively through VS Code as of October this year (2019), but one thing I don't get right is how to set my PYTHONPATH prior to booting up a local Jupyter server.

What I want is to be able to import a certain module which is located in another folder (because the module is compiled from C++ code). When I run a normal Python debugging session, I found out that I can set environment variables of the integrated terminal, via the setting terminal.integrated.env.linux. Thus, I set my PYTHNPATH through this option when debugging as normal. But when running a Jupyter Notebook, the local Jupyter server doesn't seem to run in the integrated terminal (at least not from what I can see), so it doesn't have the PYTHONPATH set.

My question is then, how can I automatically have the PYTHONPATH set for my local Jupyter Notebook servers in VS Code?

Unable to load annotation processor factory in vs code

$
0
0

I am trying to use the immutables library with vscode (and Gradle)

Steps I've taken:

  1. confirmed that the jar does exist
  2. Ensured that the GRADLE_USER_HOME variable exists (it didn't initially)
  3. Set the "java.import.gradle.home" vscode setting (GRADLE_HOME)
  4. project does build using gradle build

I keep getting hung up on the environment variable. GRADLE_USER_HOME vs GRADLE_HOME. I'm on MacOS and didn't install vscode using brew but actually downloaded the app from the vscode website.

Unable to load annotation processor factory 'GRADLE_USER_HOME/caches/modules-2/files-2.1/org.immutables/value/2.7.3/91d271437be1e14438a2da6c5c3e9f8db061a7b9/value-2.7.3.jar' for project

Unable to start VSCode; suggestions for debugging?

$
0
0

I'm working on a disconnected network, so some options are a bit limited. Also, we have SAs who handle stuff like system updates (so, for instance, it is possible that there was a system update in there that I know nothing about).

However, I had 1.33.1, then 1.34.0, then 1.38 versions of VSCode working on my (Windows 10) machine. One day, for no apparent reason (I hadn't just installed something, for instance), 1.38 stopped working. It wouldn't even start up. Running 'Code --verbose' from the command line produced no output (the mouse cursor turned briefly to a spinner, but nothing even showed up in Task Manager, let alone something like a splash screen).

I did get an error message in the Application log, which included the lines (more or less; remember, no cut-n-paste possible): Faulting Application Code.exe, version: 1.38.0 Faulting module ntdll.dll, version 10.0.16299.936 Exception code: 0xc0000374 Faulting Application path: c:\Program Files\Microsoft VS Code\Code.exe Faulting module path: c:\Windows\System32\ntdll.dll

Re-installing VS Code (with or without system restart after uninstall) did nothing. Removing all extensions (we have a bunch) did nothing Installing 1.39.2 did nothing

The only good thing is that I can still run 1.34.0, if I reinstall that (did not try 1.33.1, and I don't have any in-between versions from 1.34 to 1.38 to try). So at least I'm not completely shut out.

I also tried deleting basically all of workspaceStorage, to no effect. Nor did renaming my storage.json.

The biggest weirdness, to me, is that the path to ntdll.dll is in System32, rather than in SysWOW64 (is there some way to force usage of the latter?). Second, why did 1.38.0 work just fine for a while, and then stop.

So, I'm curious if anyone else has seen this problem, and/or if anyone has any idea what else could be done to get more insight into what's causing this.

(edit: I plan to file bug for VSCode, but been waiting on confirmation email to finish creating my github acct for some time now. sigh)

Specflow - TearDown failed for test fixture - System.ArgumentNullException : Value cannot be null. (Parameter 'key')

$
0
0

I'm working with test automation using Specflow and Selenium but by the time I try to execute my test, I face these error messages:

  • My question is not what is a NullReferenceException, but what (and where) is this Parameter 'key' pointed as the cause of the exception.

TearDown failed for test fixture MyProject.Features.MyFeature System.ArgumentNullException : Value cannot be null. (Parameter 'key') TearDown : System.NullReferenceException : Object reference not set to an instance of an object.

And:

Error Message: OneTimeSetUp: System.ArgumentNullException : Value cannot be null. (Parameter 'key')

This is my scenario:

Scenario: Accessing the screen for the first time
    Given I accessed the screen for the first time
    Then the result grid should only show the phrase "Lorem ipsum"

This is my StepDefinition.cs file:

    [Binding]
    public class StepDefinition
    {
        PageObject pageObject = new PageObject();

        [Given(@"I accessed the screen for the first time")]
        public void GivenIAccessedTheScreenForTheFirstTime()
        {
            pageObject.NavigateToScreen();
        }

        [Then(@"the result grid should only show the phrase (.*)")]
        public void ThenTheResultGridShouldOnlyShowThePhrase(string phrase)
        {
            Assert.True(pageObject.isPhraseDisplayed(phrase));
        }        
    }

This is my PageObject.cs file:

        public PageObject() : base(){ } //I use a BasePageObject.cs file also

        public void NavigateToScreen()
        {
            driver.Navigate().GoToUrl(_urlHere_);
        }
        public bool isPhraseDisplayed(string phrase)
        {
            wait.Until(u => u.FindElement(_byIdOfWebElementHere_).Displayed);

            IWebElement element = driver.FindElement(_byIdOfWebElementHere_);
            return element.Displayed;
        }

And this is the BasePageObject.cs file, which implements IDisposable interface:

        protected IWebDriver driver { get; set; }
        protected WebDriverWait wait { get; set; }

        public BasePageObject()
        {
            driver = new ChromeDriver();
        }

        [AfterScenario]
        public void Dispose()
        {
            driver.Close();
            driver.Quit();
            driver.Dispose();
        }
    }

Things I think are important to point:

  • I am using VSCode, not Visual Studio.
  • The test runner I have installed on my project is NUnit.

Basic C++ Program on Visual Studio Code Error: The terminal process terminated with exit code: 1 [closed]

$
0
0

I'm trying to compile a basic "Hello World" program and I'm using Visual Studio Code. Program is written in C++ and when I press CONTROL-SHİFT-B I get an error like this:

The terminal process terminated with exit code: 1

This is my task.json:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "echo",
            "type": "shell",
            "command": "C:/MinGW/bin/g++",
            "args": [
                "-g", "main.cpp"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

This one is c_cpp_properties.json file:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceRoot}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "compilerPath": "C:\\MinGW\\bin\\gcc.exe",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "clang-x64",
            "browse": {
                "path": [
                    "${workspaceRoot}/",
                     "C:\\MinGW\\lib\\gcc\\mingw32\\6.3.0\\include\\c++"

                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }

        }
    ],
    "version": 4
}

And this is the program I'm trying to execute:

#include <iostream>
using namespace std;
int main() 
{
    cout << "Hello, World!";
    return 0;
}

How can I fix this problem?

How to select all occurences and replace one by one in VSCode

$
0
0

On VSCode, it is possible to select occurences of a word one by one with CTRL/CMD + D or all at once with CTRL+SHIFT+L. With both those methods, however, you replace them all by the same value. I would like to know if there is a way to select all occurences and yet replace them one by one switching to the next one with TAB for example. For instance, in the pug code below, I would like to select one "About Us" text, click on some keyboard shortcut to automatically select them all and then press TAB to replace the first one by "Homepage", the second one by "About Us", etc. Thanks in advance!

li: a(href="#") About Us
li: a(href="#") About Us
li: a(href="#") About Us
li: a(href="#") About Us
li: a(href="#") Homepage
li: a(href="#") Careers
li: a(href="#") About Us
li: a(href="#") Contact

Remote debugging - Unverified breakpoint

$
0
0

Hope I can explain this right.

Update: I can confirm that dlv debug -l 127.0.0.1:2345 does work. Therefore I must be in VsCode launch.json

Update: removed the panic. There was a different in go versions. Now the debugger in VsCode is just not working, it says "Unverified breakpoint". But it works fine if I use dlv from terminal, if I am in the folder with the code.

I am trying to remote debug with this sample code.

It works with this change.

Do you know what to do? I have tried to change the launch.json to "program": "${workspaceRoot}", to include the path like "program": "${workspaceRoot}/src/app",.

Launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "program": "${workspaceRoot}",
            "env": {},
            "args": []
        },
        {
            // To remote debug in Docker, run the following before debugging:
            // # docker build -t webapp-go .
            // # docker run -d --name webapp-go --privileged -p 8080:8080 -p 2345:2345 webapp-go
            // # docker run -d --name webapp-go --privileged -p 8080:8080 -p 2345:2345 -v "${PWD%/*}/src/app/":/go/src/app webapp-go
            // And then each time you want to restart debugging:
            // # docker restart
            "name": "Remote debug in Docker",
            "type": "go",
            "request": "launch",
            "mode": "remote",
            "program": "${workspaceRoot}",
            "env": {},
            "args": [],
            "remotePath": "/go/src/app",
            "port": 2345, // Port 
            "host": "127.0.0.1" // Docker IP
/*            "preLaunchTask": "docker" */ 
        }
    ]
}

Dockerfile:

FROM golang:1.6
RUN go get -u -v github.com/derekparker/delve/cmd/dlv
EXPOSE 2345

# RUN mkdir -p /go/src/app
# WORKDIR /go/src/app
# VOLUME ["src/app2"]

VOLUME ["/go/src/app"]
RUN mkdir -p /go/src/app
WORKDIR /go/src/app
COPY src/app /go/src/app

RUN go-wrapper download
RUN go-wrapper install

EXPOSE 8080
CMD ["dlv", "debug", "--headless", "--listen=:2345", "--log"]

How to install Python extenion on VS Code 1.36.1

$
0
0

I installed VS Code 1.36 on a Windows 7 PC and trying to install the Python extension by downloading the .vsix file from the Market Place as I do not have Admin rights on the PC. I have already installed Python 3.8.0 and configures the PATH environment correctly. I then attempted to install the extension from the VS Code UI and also on the command line as code --install-extension , but I get the error "Unable to install extension 'my-python.python' as it is not compatible with VS Code 1.36.1 (the latest Windows version as of today) On the Market Place site the extension does not specify which VS Code version is compatible. Can anyone help me understand which python extension I should be installing for this VS Code version. Also could this be due to not having Admin Rights ? Or is there something I am not doing right ? Many Thanks R

Visual Studio Code - flatten packages in explorer view

$
0
0

I would like to know if anyone knows how to flatten the package structures in Visual Studio Code.

I used to have this in my IntelliJ IDE, but with VS Code I can't find a similar option. I am looking for any solution which could resolve this. Either changing settings or extensions if available.

Angular 8+ tsconfig Path Aliases not Recognized in .spec files

$
0
0

I am working on some Angular testing and my spec files will not recognize my paths and they give me a red squiggle import warning in VS Code (and show up in Problems) despite the fact that they work in every other way (testing works, etc.). I am assuming this is a tsconfig issue and not a linting issue as the error it gives me is: Cannot find module '@feature/<reference path>.<file type>'.ts(2307)

It functionally doesn't affect me much, but it is annoying (and kills automatic imports).

tsconfig.json paths:

...
    "paths": {
        "core-js/es6/*": [
            "node_modules/core-js/es/*"
        ],
        "core-js/es7/reflect": [
            "node_modules/core-js/proposals/reflect-metadata"
        ],
        "@core/*": [
            "src/app/core/*"
        ],
        "@shared/*": [
            "src/app/shared/*"
        ],
        "@feature/*": [
            "src/app/feature/*"
        ],
        "@test/*": [
            "src/test/*"
        ],
        "@/*": [
            "src/*"
        ]
    }
...

tsconfig.spec.json and tsconfig.app.json paths (note standard folder structure from angular-cli):

{
    "extends": "../tsconfig.json",
    "compilerOptions": {
        "outDir": "../out-tsc/spec"
    }
}

angular.json

...
            "test": {
                "builder": "@angular-builders/jest:run",
                "options": {
                    "tsConfig": "src/tsconfig.spec.json",
                    "no-cache": true,
                    "polyfills": "src/polyfills.ts",
                    "configPath": "./jest.config.js",
                    "styles": [
                        "node_modules/font-awesome/css/font-awesome.css",
                        "src/styles.scss"
                    ],
                    "scripts": [],
                    "assets": [
                        "src/favicon.ico",
                        "src/assets",
                        "src/manifest.json",
                    ],
                    "stylePreprocessorOptions": {
                        "includePaths": [
                            "src"
                        ]
                    }
                }
            },
            "lint": {
                "builder": "@angular-devkit/build-angular:tslint",
                "options": {
                    "tsConfig": [
                        "src/tsconfig.app.json",
                        "src/tsconfig.spec.json"
                    ],
                    "exclude": [
                        "**/node_modules/**"
                    ]
                }
            }
...

Versions:

Angular CLI: 8.3.6
Node: 12.3.1
OS: win32 x64
Angular: 8.2.8
... animations, common, compiler, compiler-cli, core, forms     
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.803.6
@angular-devkit/build-angular     0.803.6
@angular-devkit/build-optimizer   0.803.6
@angular-devkit/build-webpack     0.803.6
@angular-devkit/core              8.3.6
@angular-devkit/schematics        8.3.6
@angular/cli                      8.3.6
@angular/pwa                      0.803.6
@ngtools/webpack                  8.3.6
@schematics/angular               8.3.6
@schematics/update                0.803.6
rxjs                              6.5.3
typescript                        3.5.3
webpack                           4.39.2

How to remove a specific linting highlight in VS Code?

$
0
0

sometimes the python linter i use (either pylint or mypy) highlight things that aren't an issue.

id like to know if it is possible to ignore this specific highlight. i just want to remove the highlight on specific places is it possible ?

(im not asking to completely remove the linter, just remove the highlight at some places that's all)

Viewing all 97245 articles
Browse latest View live