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

Is there a VSCode action to close the sidebar if open, otherwise do nothing?

$
0
0

There's an action called workbench.action.closePanel that does exactly what you'd think it does; it closes the panel in VSCode if it's open, and if it's not open it does nothing. As far as I can tell, there is no equivalent for the sidebar in VSCode (workbench.action.closeSidebar doesn't work).

I don't want to use the workbench.action.toggleSidebarVisibility command; I want to have an explicit "close" command for the sidebar. Is there such a command and I'm just not seeing it? If it doesn't exist, I guess I'll open a feature request.


Debug vue-cli project - no breakpoints, console links to wrong files

$
0
0

Trying to setup vscode to debug a vue project.

I use vue ui because it's actually super convenient.

I have 2 problems:

  1. Breakpoints end up Breakpoint set but not yet bound. And obviously not working.
  2. File links in the debug console open to src\node_modules\cache-loader\dist\webpack:.... That's not even a valid path - there's no node_modules in src.

I have read this page:
https://vuejs.org/v2/cookbook/debugging-in-vscode.html

I got most of my launch config from there.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "vuejs/chrome: Attach to devtools",
            "type": "chrome",
            "request": "attach",
            "port": 9222,
            "urlFilter": "http://localhost:8080/*",
            "webRoot": "${workspaceFolder}/src",
            "sourceMapPathOverrides": {
                "webpack:///src/*": "${webRoot}/*"
            }
        }
    ]
}

How do I Auto-bind Visual Studio Code Breakpoints for Mocha Unit Tests?

$
0
0

I've been unit testing with Visual Studio Code and Mocha. I've found that breakpoints only bind right away in the spec.js files. The ones in external files are only bound when you manually step into them.

Is there a way that I can make all breakpoints be bound as soon as the debugger starts up? I'd rather not have to step through things manually just so I can skip to one of said points.

VS Code with es6

$
0
0

I am getting the linting error in my code 'import' is only available in ES6 (use 'esversion: 6').

Everything es6 related is throwing an error. Not sure what I have to configure to get it to work.

VS Code move debug tab (left panel) to bottom

$
0
0

Is it possible to move left panel Debug from left to bottom? I believe is more comfortable to see all the callstacks, variables and watches in the bottom panel.

Many thanks!

VS Code Intellisense for unity not working

$
0
0

The Intellisense for VS Code for Unity specific methods is not working. I keep getting the following warnings repeated several times in the Output log of VS Code:

[warn]: OmniSharp.MSBuild.ProjectManager
        Expected project reference e:\GameDev\New Unity Project\Unity.VSCode.Editor.csproj to be already loaded for project Assembly-CSharp
[warn]: OmniSharp.MSBuild.ProjectManager
        Expected project reference e:\GameDev\New Unity Project\Unity.TextMeshPro.Editor.csproj to be already loaded for project Assembly-CSharp
[warn]: OmniSharp.MSBuild.ProjectManager
        Expected project reference e:\GameDev\New Unity Project\UnityEngine.UI.csproj to be already loaded for project Assembly-CSharp
[warn]: OmniSharp.MSBuild.ProjectManager
        Expected project reference e:\GameDev\New Unity Project\Unity.Timeline.csproj to be already loaded for project Assembly-CSharp
[warn]: OmniSharp.MSBuild.ProjectManager
        Expected project reference e:\GameDev\New Unity Project\Unity.CollabProxy.Editor.csproj to be already loaded for project Assembly-CSharp
[warn]: OmniSharp.MSBuild.ProjectManager
        Expected project reference e:\GameDev\New Unity Project\Unity.Rider.Editor.csproj to be already loaded for project Assembly-CSharp
[warn]: OmniSharp.MSBuild.ProjectManager
        Expected project reference e:\GameDev\New Unity Project\Unity.TextMeshPro.csproj to be already loaded for project Assembly-CSharp
[warn]: OmniSharp.MSBuild.ProjectManager
        Expected project reference e:\GameDev\New Unity Project\UnityEditor.UI.csproj to be already loaded for project Assembly-CSharp
[warn]: OmniSharp.MSBuild.ProjectManager
        Expected project reference e:\GameDev\New Unity Project\Unity.Timeline.Editor.csproj to be already loaded for project Assembly-CSharp

The problem starts by saying:

[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'e:\GameDev\New Unity Project\Assembly-CSharp.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Assembly-CSharp
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve project reference 'e:\GameDev\New Unity Project\Unity.Timeline.Editor.csproj' for 'Assembly-CSharp'.
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve project reference 'e:\GameDev\New Unity Project\Unity.VSCode.Editor.csproj' for 'Assembly-CSharp'.
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve project reference 'e:\GameDev\New Unity Project\Unity.TextMeshPro.Editor.csproj' for 'Assembly-CSharp'.
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve project reference 'e:\GameDev\New Unity Project\UnityEngine.UI.csproj' for 'Assembly-CSharp'.
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve project reference 'e:\GameDev\New Unity Project\Unity.Timeline.csproj' for 'Assembly-CSharp'.
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve project reference 'e:\GameDev\New Unity Project\Unity.CollabProxy.Editor.csproj' for 'Assembly-CSharp'.
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve project reference 'e:\GameDev\New Unity Project\Unity.Rider.Editor.csproj' for 'Assembly-CSharp'.
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve project reference 'e:\GameDev\New Unity Project\Unity.TextMeshPro.csproj' for 'Assembly-CSharp'.
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve project reference 'e:\GameDev\New Unity Project\UnityEditor.UI.csproj' for 'Assembly-CSharp'.

I have .NET v4.7.1 installed.

I have tried to generate the .csproj files by enabling this option in Unity: Edit > Preferences > External Tools > Generate all .csproj files.

I have also tried reinstalling all the VS Code extensions (using C# extension by microsoft, Debugger for Unity by Unity Technologies and Unity Code Snippets by Kleber Silva).

Any help would be highly appreciated.

Debugging Laravel with VSCode on Docker container using Xdebug as debugger

$
0
0

I am trying to debug Laravel code on Visual Studio Code using Xdebug. I am using Docker container that works as server.

But I am getting this error when try to debug:

Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 192.168.99.100:9000).

Here is my VSCode launch.json

"version": "0.2.0",
    "configurations": [

        {
            "type": "node",
            "request": "attach",
            "name": "Docker: Attach to Node",
            "port": 9000,
            "address": "192.168.99.100",
            "localRoot": "${workspaceFolder}",
            "remoteRoot": "/var/www",
            "protocol": "inspector",
            "restart": true
        }
]

Here is docker-compose.yml

  app:
    build:
      context: ./
      dockerfile: .docker/app.dockerfile
      args:
      - INSTALL_XDEBUG=true
    working_dir: /var/www
    volumes:
      - ./:/var/www
    environment:
      - "DB_PORT=33061"
      - "DB_HOST=192.168.99.100"
      - XDEBUG_CONFIG=remote_host=192.168.99.100 remote_port=9000 remote_connect_back=0

Here is my app.dockerfile

FROM php:7.1-fpm

RUN docker-php-ext-install pdo &&  docker-php-ext-install pdo_mysql

#####################################
# xDebug:
#####################################

ARG INSTALL_XDEBUG=true
RUN if [ ${INSTALL_XDEBUG} = true ]; then \
    # Install the xdebug extension
    pecl install xdebug && \
    docker-php-ext-enable xdebug \
;fi

# Copy xdebug configration for remote debugging
COPY .docker/xdebug.ini /usr/local/etc/php/conf.d/xdebug.ini


#####################################
# ZipArchive:
#####################################

ARG INSTALL_ZIP_ARCHIVE=false
RUN if [ ${INSTALL_ZIP_ARCHIVE} = true ]; then \
    # Install the zip extension
    docker-php-ext-install zip \
;fi

# RUN apt-get update && apt-get install -y \
#         freetds-bin \
#         freetds-dev \
#         freetds-common \
#         libct4 \
#     && docker-php-ext-install pdo_dblib

# pdo_dblib
RUN apt-get update && apt-get install -y freetds-dev
RUN docker-php-ext-configure pdo_dblib --with-libdir=/lib/x86_64-linux-gnu
RUN docker-php-ext-install pdo_dblib
RUN sed -i "s|\[sqlsrv\]|\[sqlsrv\]\nhost = 172.18.250.57\nport =1435\nclient charset=UTF-8\ntds version = 8.0|g" /etc/freetds/freetds.conf




RUN usermod -u 1000 www-data

WORKDIR /var/www

CMD ["php-fpm"]

EXPOSE 9000
EXPOSE 9001

I think VSCode can't connect to remote Xdebug with 9000 port. But when check to app docker image Xdebug is working properly. Maybe VSCode needs some more configuration. But I couldn't solve this issue.

VSCode add parentheses when automcompleting functions

$
0
0

Is is possible to tweak VSCode so that when function gets autocompleted it is written with () instead of just plain function name?

For example when I type str and autocomplete to strlen I would like to get strlen(), it saves quite some time.


Vscode "Unable to open [file]: Unable to read file" message when clicking on an error

$
0
0

I get this message when I click on a warning. This is a screenshot of the case. enter image description here

The error reads,

Unable to open 'warning.cpp': Unable to read file '/Users/dimen/code/C++/Users/dimen/code/C++/warning.cpp' (Error: Unable to resolve non-existing file '/Users/dimen/code/C++/Users/dimen/code/C++/warning.cpp').

My script is located in /Users/dimen/code/C++/warning.cpp so vscode reiterates the path for some reason.

I suspected that the linter setting must've been written erroneously but I'm not sure where I should edit. As some side notes,

  • Using Microsoft's C/C++ extension.
  • tasks.json have been customized so that all the builds go inside the build folder

Python elif works in IDLE but not Visual Studio Code

$
0
0

I'm a Python newbie, currently working on my first project.

My elif statements seem to work in IDLE but not VSC

To demonstrate, I have a very simple if statement:

dud = 'You'
if dud == 'You':
    print('You got the dud!')
elif dud == 'Me':
    print('ohhhh, I made myself sad')
else:
    pass

When I submit this code to IDLE, it works no problem. However, when I copy paste the exact same code into VSC and run in Python Terminal I get the following errors:

PS C:\Users\William> & C:/Users/William/AppData/Local/Programs/Python/Python38-32/python.exe
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 22:39:24) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> dud = 'You'>>> 
>>> if dud == 'you':
...     print('You got the dud!')
...
>>> elif dud == 'Me':
  File "<stdin>", line 1
    elif dud == 'Me':
    ^
SyntaxError: invalid syntax
>>>     print('ohhhh, I made myself sad')
  File "<stdin>", line 1
    print('ohhhh, I made myself sad')
    ^
IndentationError: unexpected indent
>>> else:
  File "<stdin>", line 1
    else:
    ^
SyntaxError: invalid syntax
>>>     pass
  File "<stdin>", line 1
    pass
    ^
IndentationError: unexpected indent
>>>

Naturally, I've tried various different types of formatting but I can't get it to work. If I remove the elif section it works fine, so I feel like I must be missing something basic.

Any help would be greatly apprecaited!

edit: Increasingly odd behaviour leads me to believe that this is somehow a Visual Studio issue:

Running code in 'Python interactive window" = Successful Fresh Launch of VSC and using 'Run python file in terminal' = Succesful 'Run selection/line in terminal' = Error encountered above Running 'Run python file in terminal' after terminal has already running = error encountered above

edit: People are rightly pointing out that that it looks like VSC is saying that there is an extra line being added. I don't think that is the case: here's a screenshot of the code in VSC

Description

Activate conda environment stopped working in vscode

$
0
0

I have noticed that conda activate environment stopped working in vscode integrated terminal with no obvious reason (I certainly did not install any new extensions, nor updated conda or vscode in the last few days).

Expected behaviour

After running conda activate environment I want the environment to be activated and be capable of using the environment python interpreter. Essentially it should look like this:

(base) lpravda-ml:~ lpravda$ conda activate rdkit-env
(rdkit-env) lpravda-ml:~ lpravda$ which python
/Users/lpravda/anaconda3/envs/rdkit-env/bin/python

This is what I can achieve using non-vscode terminal and work with conda as usual.

Actual behaviour This happens when I type in the same set of commands in vscode integrated terminal:

(base) lpravda-ml:~ lpravda$ conda activate rdkit-env
(rdkit-env) lpravda-ml:~ lpravda$ which python
/usr/local/bin/python

The environment seems to be switched on, however python still points to the system install python 2.7 and I have no idea why.

It used to be working like for years and now it broke down.

Note: When I run debugger in vscode the correct conda environment is selected and executed.

My setup:

OS: Mac OS X: 10.14.3
vscode: 1.31.1
conda: 4.6.7

Update ongoing issue with the following update:

OS: Mac OS X: 10.14.3
vscode: 1.33.3
conda: 4.6.8

Any idea what could possibly broke down?

VS Code gives me an ssh_askpass error when I try to push the changes to my Github repository using the integrated git

$
0
0

I have this problem, I've created a Github repository to back up a project. I have normal SSH access to my repo from my Linux command line and I can push, pull, commit, sync and all that stuff with no problem. But when I try to use the VS Code github integration tool to push my changes it gives me this error:

Git: ssh_askpass: exec(usr/lib/ssh/ssh_askpass): No such file or directory.

I've looked for this file on the mentioned directory but all I've seen was a file named gassh_askpass.

I'm currently using Manjaro and VS Code 1.28.2

VSCode "go to definition" not working

$
0
0

I installed Visual Studio Code 1.1 with the C/C++ extension, opened my C++ project and tried to use "Go to definition" in vain.

The "Go to definition" is not working at all. Example, go to definition of a class member:

int i = m_myVar;

(I opened a simpler project with one file and it was working for this one)

In the end, what I want is good indexation of my big project, is there a way to install Intellisense?

Snippet formating in VSCcode (c++)

$
0
0

I am using Visual studio code on mac. I didn't find solution nowhere.

When i use snippets for C/C++ from Microsoft. I get results like this:

for (size_t i = 0; i < count; i++) 
{

} 

but i want this snippets to look like this.

for (size_t i = 0; i < count; i++) {

} 

if i reformat code i get what i want. But its time consuming if i need to format or edit code on every snippet i use.

My settings.json:

{
    "workbench.colorTheme": "Material Theme High Contrast",
    "workbench.iconTheme": "material-icon-theme",
    "files.autoSave": "afterDelay",
    "liveServer.settings.donotShowInfoMsg": true,
    "C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 0}",
    "C_Cpp.clang_format_style": "{ BasedOnStyle: Google, IndentWidth: 4, ColumnLimit: 0}"
}

Can I hook up vscode language extensions and terminals to use a container instead of my local system?

$
0
0

Specifically looking at the powershell extension, Im running vscode on macos

Now I can install the .net core sdk and then install powershell on my system

But what I would prefer is to install this in a container and use that

Is it possible to have vscode automatically run this container when I open the integrated powershell console in the IDE and execute into it for me? This way I could have multiple sharable dev environments as container images.


python setup.py install error LNK2019: unresolved external symbol fmin referenced in function fatal error LNK1120:

$
0
0

I am new to python. I am trying to install a module in python by visual studio code in terminal and I have provided all the requirements but it gives me an error:

"error LNK2019: unresolved external symbol fmin referenced in function __pyx_pf_9traj_dist_6cydist_18basic_geographical_10c_point_to_path build\lib.win-amd64-2.7\traj_dist\cydist\basic_geographical.pyd : fatal error LNK1120: 1 unresolved externals error: command 'C:\Users\LENOVO\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe' failed with exit status 1120"

I download it from https://github.com/bguillouet/traj-dist

How can a extension obtain remote URL of file in currently connected remote server?

$
0
0

I'm writing an extension targeted for VSCode Remote environment. In this setup, one extension (UI extension) runs in client and another (workspace extension) runs in remote server.

Now, here's a question - is there any way to generate an URL that can be used by UI extension to access file on the server?

I know I can use vscode-remote://ssh-remote+<hostname>/file/on/server syntax to express this type of remote URL, but the issue here is that I cannot find any way for extension to discover one. Using vscode.Uri.file() API only generates file: URL, which is meaningless for UI extension running in client environment.

Since vscode-remote: scheme is fixed and ssh-remote part can be extracted from vscode.env.remoteName variable, the last piece I need is the hostname that was used to open current VSCode Remote session. Is there any API/variable to discover this?

Cant activate environment from Visual Studio Code

$
0
0

I use Python mostly in Spyder for data science. Both Visual Studio Code and virtual environments is fairly new to me.

Anyway, using the terminal in Visual Studio Code I try to switch between environments. I have tried both conda activate venv and activate venv. I get no error message but using conda env list to see which environment is active I seem stuck in Base.

enter image description here

Doing the same thing in the Anaconda Prompt I am allowed to switch between environments.

I use Windows and I start Visual Studio Code from the Anaconda Navigator.

What is going on?

Visual Studio Code tree view setting. Get back the old view (pre 2020) [duplicate]

$
0
0

This makes me crazy! It should be trivial but I cant find in settings how to get back the old look in the file explorer window. Well it's not that old, it was just a few weeks ago.

First image shows what I want and the second image shows what I have now. To be clear I don't want the folder structure to show up like this: routes \ admin or views \ admin

I want it to look like in the first image.

The question is how to get it back so it looks like in the first image. What setting is it?

In visual Studio Code.


Tree view I want.


tree view I have now.

How to resolve "unresolved import" in Rust when using VS Code?

$
0
0

I'm fairly new to rust and have been following the official book that they provide on their site. During chapter 2 they tell you to import a "Rand" cargo which I did. However, when I try to run my code directly through VS Code I get an error saying "unresolved import rand". When I run it through command prompt, everything works fine. I've already tried every solution suggested here: https://github.com/rust-lang/rls-vscode/issues/513 and nothing seemed to have worked. Extensions that I'm using:

  • Better TOML
  • Cargo
  • Code Runner
  • Rust (rls)
  • Rust Assist
  • vsc-rustfmt
  • vscode-rust-syntax

Has anyone else ran into a similar problem or a know a solution? Thank you!

Edit: My Cargo.TOML looks like this:

[package]
name = "guessing_game"
version = "0.1.0"
authors = ["Name <MyNameHere@gmail.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rand = "0.6.0"

Edit 2: my main.rs file looks like this:

use rand::Rng;
use std::io;
use std::cmp::Ordering;

fn main()
{
    println!("Guess the number!");
    let secret_number = rand::thread_rng().gen_range(1, 101);
    loop
    {
        println!("Please input your guess!");
        let mut guess = String::new();
        io::stdin().read_line(&mut guess).expect("Failed to read line!");
        let guess: u32 = match guess.trim().parse()
        {
            Ok(num) => num,
            Err(_) => continue,
        };
        println!("Your guess {}", guess);
        match guess.cmp(&secret_number)
        {
            Ordering::Less => println!("Too small!"),
            Ordering::Greater => println!("Too big!"),
            Ordering::Equal =>
            {
                println!("You win!");
                break;
            }
        }
    }
}
Viewing all 97530 articles
Browse latest View live


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