I am trying to write an auto task to help me build go plugin. The task looks like this
{
"label": "compile wc.go",
"type": "shell",
"command": "go",
"args": [
"build",
"-buildmode=plugin",
"-gcflags='all=-N -l'",
"../mrapps/wc.go"
],
"options": {
"cwd": "${workspaceFolder}/src/main",
}
}
When I ran it, terminal shows the following error:
> Executing task: go build -buildmode=plugin -gcflags='all=-N -l' ../mrapps/wc.go <
/bin/bash: go: command not found
The terminal process "/bin/bash '-c', 'go build -buildmode=plugin -gcflags='all=-N -l' ../mrapps/wc.go'" failed to launch (exit code: 127).
The command go env works perfectly on integrated terminals when I ran it
(base) XIEs-MacBook-Pro:6.824 j$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
...enter code here
I've been searching for answers, but none.
I tried another task
{
"label": "test",
"type": "shell",
"command": "echo $PATH",
"options": {
"cwd": "${workspaceFolder}/src/main"
}
}
which prints my PATH, which is clearly different from the one I got in bash or integrated terminals.
And I also tried open a python interpreter by task, which yields a python 2.7, definately not the default one (by which python).
You probably should set Run as login shell so all variables in the bash_profile(rc) will be exported. AFAIK here is the setting "terminal.integrated.shellArgs.osx": ["-l"] .
Try to set terminal.integrated.shellArgs.osx as #Зелёный suggest, or you also can set up terminal.integrated.automationShell.osx to point to /bin/bash.
Related
I would like to add /home/sanya/work/ORB_SLAM3/Examples/ROS to the ROS_PACKAGE_PATH variable before the ROS debug session starts. If it isn't added, the debugger won't start, because it cannot find the package.
I would like to export the variable before the ROS debug starts.
What I already tried:
I tried to add it as an environment variable in the launch.json in two different ways:
first way:
{
"name": "ROS: Launch + build (release)",
"type": "ros",
"request": "launch",
"target": "/home/sanya/work/ORB_SLAM3/Examples/ROS/ORB_SLAM3/launch/ORB_SLAM3_bag.launch",
"env": {"ROS_PACKAGE_PATH": "/opt/ros/melodic/share:/home/sanya/work/ORB_SLAM3/Examples/ROS"}
}
second way:
{
"name": "ROS: Launch + build (release)",
"type": "ros",
"request": "launch",
"target": "/home/sanya/work/ORB_SLAM3/Examples/ROS/ORB_SLAM3/launch/ORB_SLAM3_bag.launch",
"environment": [{"name": "ROS_PACKAGE_PATH", "value": "/opt/ros/melodic/share:/home/sanya/work/ORB_SLAM3/Examples/ROS"}]
}
I tried to add it to an .env file, and set the envFile property in launch.json:
.env file:
ROS_PACKAGE_PATH=/opt/ros/melodic/share:/home/sanya/work/ORB_SLAM3/Examples/ROS
launch.json file:
{
"name": "ROS: Launch + build (release)",
"type": "ros",
"request": "launch",
"target": "/home/sanya/work/ORB_SLAM3/Examples/ROS/ORB_SLAM3/launch/ORB_SLAM3_bag.launch",
"envFile": "${workspaceFolder}/.env"
}
I tried adding a prelaunchTask:
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/sanya/work/ORB_SLAM3_multi/Examples/ROS
This option works— the export happens (I ran echo $ROS_PACKAGE_PATH after to check)— but the debug session starts in a different terminal (if I understand correctly) and the variable won't be set to the correct value in the debug session.
The only thing that has worked is adding it to the .bashrc file. This isn't really ok for me, because I have a modified version of the same library, and I would like to use them both (I will benchmark the modified version against the original), and I wouldn't like to modify the .bashrc file everytime when switching between the 2 versions.
Is there another option to export variables to the VSCode debug environment?
(I maintain the Microsoft VSCode ROS extension.)
The extension inherits most of the environment from the ROS environment it is launched from, so if you need to set environment variables (or relocate ROS), you can set them in a terminal and launch code from the terminal.
I create a feature request - https://github.com/ms-iot/vscode-ros/issues/646, and assigned it to our 0.8.0 which I'm working on now.
The '+' button to open terminal in my visual studio code does not work.
Also, the default profile selection button does not work.
The only thing I changed was from "launch.json" to "externalConsole: false->true".
Even if I try to restore it to its original state, it remains the same. I tried reinstalling the VSCode, deleted the "setting.json" file, and recreated it. But... :(
Originally, I was using git bash as a standard, but you can see it. There is only "JavaScript Debug Terminal" left.
Please help me, friends.
My "launch.json" file
"version": "0.2.0",
"configurations": [
{
"name": "gcc.exe - 활성 파일 빌드 및 디버그",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "C:/MinGW/bin",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "gdb에 자동 서식 지정 사용",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc.exe 활성 파일 빌드"
}
]
I am on macOS with an issue like this as well. My terminal instantly closes when I try to open it and I have not found a good solution. The best I can do it just reinstall VScode.
I use Windows, hence commands are for Windows, but you can definitely find the alternative commands for your OS in case you happen to use an OS other than Windows.
Open your settings.json file(File -> preferences -> Settings or Ctrl+,) and look for the configuration terminal.integrated.profiles.windows (newer recommended setting). If you seeterminal.integrated.shell.windows then it is the older deprecated setting.
If you are on linux or Mac, then look for the terminal.integrated.profiles.linux or terminal.integrated.profiles.osx. If you don't find these, then perhaps you don't have any terminal profiles setup and you need to set it up.
Setting up a terminal profile is quite easy.
In your settings.json file you need to create a new setting with key terminal.integrated.profiles.windows (or terminal.integrated.profiles.linux or terminal.integrated.profiles.osx based on your system). Start typing the above key and once VSCode shows the suggestion hit Enter(Return). If you don't see any suggestion for auto-complete try hitting Ctrl+Space. Your settings will auto-populate against the above key and will look something like following:
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": [],
"icon": "terminal-cmd"
},
"Git Bash": {
"source": "Git Bash"
}
}
In addition to above you can also setup a default terminal profile. Include the below setting(here Git Bash has been configured as the default terminal profile) :
"terminal.integrated.defaultProfile.windows": "Git Bash"
You can always use the Ctrl+Space to force VScode to provide you with the possible values.
Few handy links :
To create a new profile.
To go to the command pallette(Ctrl+Shift+P on windows)
I have a simple LinkedList implementation in Node. I want to test it using Mocha -- simply exercise different append/delete operations. And most importantly, I want to be able to stepthrough/debug my linkedlist as called from the mocha tests.
This is my launch.json:
{
"version": "0.1.0",
"configurations": [
{
"type": "node",
"request": "launch",
"protocol": "inspector",
"name": "Mocha All",
"windows":{
"runtimeExecutable": "c:\\Users\\alern\\AppData\\Roaming\\npm\\_mocha.cmd"
},
"args": [
"--colors",
"${workspaceFolder}\\test\\test.js"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
]
}
when I press Run on my "Mocha All" configuration in VSCode,
global installation of mocha.cmd starts running, I see the following in the terminal:
cd 'd:\Projects\Algorithms\LinkedList'; & 'c:\Users\alern\AppData\Roaming\npm\_mocha.cmd' '--inspect-brk=30840' '--colors' 'D:\Projects\Algorithms\LinkedList\test\test.js'
(node:21524) ExperimentalWarning: The ESM module loader is experimental.
The above makes sense.
And then I see:
all of my tests simply rip through --- although I have setup some breakpoints in the Mocha scripts, they get ignored. So thats useless.
once all the tests are done (some successful, some not), at the end I get a popup that says:
"Cannot connect to runtime process, timeout after 10000ms - reason: Cannot connect to target: connect ECONNREFUSED 127.0.0.1:30840" This error feels like my process is done running and gone away, and VSCode or debugger are trying to connect to it?
In any case, what do I tweak to have my breakpoints stop execution? Thank you
The first thing I might try is to change the type to "pwa-node". I think mocha or VSCode recently made some changes that make that mandatory. You might also not want to set the runtime executable, but rather the "program". Generally the runtimeExecutable will be node, and if it's on your path VSCode should be able to find it automatically.
If all else fails I'd also try looking at the default configuration that ships with VSCode and see if that gives you any clues. That can be accessed by adding a new configuration through the "Add Configuration..." button. https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_launch-configurations-for-common-scenarios
This is my first day using vscode with beego.
I used IntelliJ otherwise, which has a setting to specify custom paths for GOPATH.
Vscode does not seem to have this option of allowing multiple GOPATHs, and I thought I could try to append GOPATH variable for all integrated terminal sessions.
I've added following to settings.json
"terminal.integrated.env.osx": {
"GOPATH": "/Users/hk/go:/Users/hk/Documents/code/go/go-beego"
}
However, it has no effect on tasks.json
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "go: run beego",
"type": "shell",
"command": "echo \"gopath is $GOPATH\" | bee run portal"
}
]
}
Output of tasks
gopath is /Users/hk/go
FATAL ▶ 0001 No application 'portal'
found in your GOPATH.
The terminal process terminated with exit code: 255
EDIT: The integrated terminal does not honour the following:
"go.gopath": "/Users/hk/go:/Users/hk/Documents/code/go/go-beego",
I've installed VSCode with Bash debug extension.
Before that, I've installed bashdb and I've verified its version using (bashdb --version) and it's 4.4.
Now, the extension creates an empty file called launch.json.
I wrote the following to start debugging, but still, nothing happened
{
"version": "0.2.0",
"scriptPath": "${command:SelectScriptName}",
"configurations": [
],
"compounds": [
{
"type": "bashdb",
"name": "Compound",
"configurations": []
}
]
}
What should I do to enable debugging?
Regards,
With the bashdb extension installed, add the following block to the launch.json file. This configuration allows you to debug the script you have currently open on VS Code. So, in order to start debugging a script you must have it open on VS Code, and type F5 to start debugging it. Alternatively, and also with the same script open on VS Code, you can open the Run and Debug menu, on the VS Code left bar, and click Play.
{
"type": "bashdb",
"request": "launch",
"name": "Bash-Debug (simplest configuration)",
"cwd": "${workspaceFolder}",
"program": "${file}",
"showDebugOutput": true,
"terminalKind": "integrated"
}
Adding the args parameter to the above block, allows you to pass an array with arguments to the script while debugging.
I tested this code with the Bash Debug extension:
{
"version": "0.2.0",
"configurations":
[
{
"type": "bashdb",
"request": "launch",
"name": "Bash-Debug (select script from list of sh files)",
"cwd": "${workspaceFolder}",
"program": "${command:SelectScriptName}",
"args": []
}
]
}
Visual Studio Code displays a list of script from your project, and you can pick the one you want to run. You can alternatively choose a "Bash-Debug (hardcoded script name)" configuration, which allow to hardcode the script path.
If you want to debug a Bash script I recommend you execute your script with -x flag. For example:
bash -x script.sh
or into the script add:
set -x
<DEBUG_CODE_LINES>
set +x