Visual Studio Code (한국어)
Visual Studio Code는 크로스 플랫폼, MIT 라이센스의 오픈소스 텍스트 에디터이다. Microsoft에 의해, JavaScript, TypeScript로 작성되었다. Electron 프레임워크를 기반으로 동작하며, Marketplace에서 제공되는 확장을 이용하여 확장기능을 사용할 수도 있다. 프로젝트 자체는 오픈소스이지만, EULA 라이센스의 비-자유 빌드 버전 역시 Microsoft에 의하여 제공되고 있다. 이러한 라이센스 방침에 관해서는 GitHub 코멘트를 통한 설명을 참고.
설치
다음 패키지는 VSCode를 제공한다.
- code (오픈소스 릴리즈, MIT 라이센스)
- visual-studio-code-binAUR (Microsoft 브랜드 릴리즈)
- visual-studio-code-insiders-binAUR (Microsoft 브랜드 릴리즈, 인사이더. 일 단위로 업데이트.)
- code-gitAUR (개발 버전의 오픈소스 패키지)
- vscodium-binAUR (커뮤니티 주도 하에 관리되는 오픈소스 버전)
Microsoft ptvsd (Python Tools for Visual Studio Debug) 서버/모듈은 python-ptvsdAUR에서 제공된다.
사용
code
로 어플리케이션을 실행할 수 있다. (혹은 다른 버전의 릴리즈를 사용한다면, code-git
로 code-gitAUR, codium
로 vscodium-binAUR를 실행.)
-n
플래그를 이용하여 복수의 인스턴스를 실행할 수도 있다.
설정
code는 설정을 ~/.config/Code - OSS/User/settings.json
에 저장한다.
visual-studio-code-binAUR의 경우, ~/.config/Code/User/settings.json
에 해당한다.
내장 터미널
View > Integrated Terminal 혹은 Ctrl + `
단축키로 내장 터미널을 열 수 있다.
내장 터미널은 어떠한 값도 설정되지 않은 상태에서는 기본적으로 Bash를 사용한다.
이는 설정을 통하여 변경할 수 있다.
terminal.integrated.shell.linux
을 통해 기본값으로 사용될 쉘,
terminal.integrated.shellArgs.linux
을 통해 쉘에 전달할 argument를 지정할 수 있다.
예:
~/.config/Code/User/settings.json
"terminal.integrated.shell.linux": "/usr/bin/fish", "terminal.integrated.shellArgs.linux": ["-l","-d 3"]
External terminal
If you are using Terminator as default terminal for Arch and you have an error on Visual Studio Code: Unable to launch debugger worker process (vsdbg) through the terminal. spawn truecolor ENOENT
, you can change the terminal that will be used by Visual Studio to another terminal (e.g. gnome-terminal).
"terminal.external.linuxExec": "Your alternative terminal"
sets the default terminal to be used for exec debug.
Example:
~/.config/Code/User/settings.json
"terminal.external.linuxExec": "gnome-terminal"
트러블슈팅
KDE/Plasma에서 글로벌 메뉴가 작동하지 않음
Visual Studio Code는 DBus를 이용하여 Plasma에서 메뉴를 전달하므로, libdbusmenu-glib을 설치.
휴지통으로 파일을 옮길 수 없음
기본적으로 Electron는 gio
를 이용하여 파일을 삭제한다.
휴지통의 다른 구현체를 사용하길 원한다면, ELECTRON_TRASH
환경변수를 이용하여
설정할 수 있다.
예를 들어, Plasma에서 파일을 삭제하기를 원한다면:
$ ELECTRON_TRASH=kioclient5 code
Electron은 kioclient5
, kioclient
, trash-cli
, gio
(기본)
gvfs-trash
(중단)을 지원한다.
더 자세한 사항에 관해서는 공식 문서를 참고.
Unable to debug C#
If you want to debug C#.NET (using the OmniSharp extension) then you need to install the Microsoft branded release (from the AUR). This is apparently because the .NET Core debugger is only licensed to be used with official Microsoft products - see this github discussion.
When using the open-source package, debugging fails fairly quietly. The debug console will just show the initial message:
You may only use the Microsoft .NET Core Debugger (vsdbg) with Visual Studio Code, Visual Studio or Visual Studio for Mac software to help you develop and test your applications.
For debugging with the open-source package netcoredbgAUR can be used. To run it in VS Code, add this configuration to .NET Core launch configuration of the project:
./.vscode/launch.json
"configurations": [ { ... "pipeTransport": { "pipeCwd": "${workspaceFolder}", "pipeProgram": "/usr/bin/bash", "pipeArgs": ["-c"], "debuggerPath": "/usr/bin/netcoredbg" } ...
Unable to open .csproj with OmniSharp server, invalid Microsoft.Common.props location
You have to switch from mono to proper SDK version props.
/opt/dotnet/sdk/{VERSION}/Sdks/Microsoft.NET.Sdk/Sdk/Sdk.props
$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props
Modify import to look like this:
/opt/dotnet/sdk/{VERSION}/Sdks/Microsoft.NET.Sdk/Sdk/Sdk.props
/opt/dotnet/sdk/{VERSION}/Current/Microsoft.Common.props
Error from OmniSharp that MSBuild cannot be located
It is noted in the OmniSharp introduction that Arch Linux users should install the mono-msbuild package. Without it, you might get an error like:
OmniSharp Log
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator Registered MSBuild instance: StandAlone 15.0 - "~/.vscode/extensions/ms-vscode.csharp-1.18.0/.omnisharp/1.32.11/omnisharp/msbuild/15.0/Bin" MSBuildExtensionsPath = /usr/lib/mono/xbuild BypassFrameworkInstallChecks = true CscToolPath = ~/.vscode/extensions/ms-vscode.csharp-1.18.0/.omnisharp/1.32.11/omnisharp/msbuild/15.0/Bin/Roslyn CscToolExe = csc.exe MSBuildToolsPath = ~/.vscode/extensions/ms-vscode.csharp-1.18.0/.omnisharp/1.32.11/omnisharp/msbuild/15.0/Bin TargetFrameworkRootPath = /usr/lib/mono/xbuild-frameworks System.TypeLoadException: Could not load type of field 'OmniSharp.MSBuild.ProjectManager:_queue' (13) due to: Could not load file or assembly 'System.Threading.Tasks.Dataflow, Version=4.5.24.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. ...
You might be able to build anyway (possibly depending whether you have mono installed too).
Omnisharp ships with its own mono version, so, if it's unable to locate the installed one, if you want to tell omnisharp to look for a "global" mono installed in your machine, put this in your settings.json:
settings.json
"omnisharp.useGlobalMono:"always"
Saving with "Retry as Sudo" does not work
This feature does not work in the code package, because Microsoft does not support the way the Arch package is packaged (native instead of bundled Electron). See FS#61516 and the upstream bug report for more information.
The binary release visual-studio-code-binAUR does not have this issue, and the feature works there.
Keyboard variants or keymappings do not map
As per the wiki on GitHub:
- Switching keyboard layouts under some Linux window managers does not result in a change in the low level X window APIs VS Code uses to read the current keyboard layout. This means that VS Code ends up sometimes reading one of the other configured keyboard layouts and not the current active one. PR welcome...
Per the wiki, there are two possible solutions:
- make sure
setxkbmap -query
returns as the first keyboard layout the one you want to work with in VS Code. - use
"keyboard.dispatch": "keyCode"
in your settings and restart VS Code. This will prevent VS Code from trying to determine your keyboard layout whatsoever.
Command "..." not found
In the official build of VS Code, a product.json
file lists the extensions that are allowed to use certain proposed APIs accessed by extensions. However, the product.json
is absent in the OSS build code. [1]
In the related issues below, some flags may be required to enable certain APIs. [2] You may either run code with these flags, or you can add the relevant entries to the extensionAllowedProposedApi
section in the product.json
file (code installs this to /usr/lib/code/product.json
).
"extensionAllowedProposedApi": [ "ms-vsliveshare.vsliveshare", "ms-vscode.node-debug", "ms-vscode.node-debug2" ]
Alternatively, you may also consider installing the Microsoft branded packages: visual-studio-code-binAUR, visual-studio-code-insiders-binAUR.
Use either the solution above by editing the product.json
, or open VS Code with:
$ code --enable-proposed-api ms-vsliveshare.vsliveshare
Command 'remote-containers.openFolder' not found
Open VS Code enabling remote-containers API as commented in FS#63374:
$ code-oss --enable-proposed-api ms-vscode-remote.remote-containers
Command 'GitHub Pull Requests: Configure Remotes...' resulted in an error (command 'pr.configureRemotes' not found)
Open VS Code with:
$ code --enable-proposed-api GitHub.vscode-pull-request-github
Git: ssh_askpass: exec(/usr/lib/ssh/ssh-askpass): No such file or directory
This error is a result of an encrypted ssh-key, and can be solved by installing a dialogue provider like SSH keys#x11-ssh-askpass or the alternatives listed there like ksshaskpass for KDE.
One thing to note is that for e.g. ksshaskpass you would need to link it from /usr/lib/ssh/ssh-askpass
to get VSCode to find it:
# ln /usr/bin/ksshaskpass /usr/lib/ssh/ssh-askpass
No extensions found
There exist several differences between "vscode" (open-source) and "Visual Studio Code" (Microsoft product based on vscode), see: Differences between the repository and Visual Studio Code. The usage of Microsoft marketplace for extensions is restricted to products of the Visual Studio Code's family. Consequently, it cannot be used by vscode (see FS#67780). The code and vscodium-binAUR packages are configured to use the Open VSX registry instead of the Microsoft one. This explains why some extensions are missing from the vscode explorer while they appear to be listed online.
The workaround is to either install the visual-studio-code-binAUR package instead, manually download and install the .vsix
file from the web marketplace page, or ask the maintainer to upload its extension to OpenVSX.
Technically, one could also edit the product.json
as shown in this Github comment, but that would not comply with the Microsoft Marketplace Terms of Use. Additionally, the changes would be overwritten during package update.
Cutoff characters in integrated Terminal
Characters that are too wide can end up clipping. For example the italic bold text of Deno stack-traces.
This can be avoided by setting "terminal.integrated.rendererType" to "experimentalWebgl".