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",
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.
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.
I have a launch.json like below:
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"env": {},
"args": ["server"]
}
]
}
When I launch it using the debug view on VScode it works fine but I need to change the program attribute to relative path of the respective file from my workspace location, strange behaviour is observed, other components in the same package start throwing undefined func error. Probably something goes wrong with current working dir or go module setup.
In order to investigate further, I need to know the command that is generated from this launch.json file. It should be something like go run ...
I have checked the output and debug console, both of them shows nothing about the launch command.
If you know how to see launch command, please help.
You can find the generated command in Visual Studio Code's debug output. When you have started a debug session, open the Debug Console by clicking on the Debug Console icon in the View Bar or by pressing Ctrl + Shift + Y. The debug output will include the generated command line.
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
I am new to web development in general, and I am trying to setup sass following the documentation here:
https://code.visualstudio.com/docs/languages/css
However I am receiving this error:
"An output directory must be specified when compiling a directory". On
the internet people are suggesting solutions, but they are related to
configuration of other editors.
My project looks like this, so you can have an idea how my project is set up:
SASS project config screenshot
I tried adding all design files in the same folder as the tasks.json file, but it didn't work and I got the same error.
I have one more question: do I need to create the .css file, or does the task create it if it's not found?
I appreciate any help possible.
I just figured this out, while looking for the same solution.
Your "args" have to be configured like this:
"args": ["./src/app/styles.scss", "./src/app/styles.css"]
or
"args": ["./(static or assets folder)/(sass folder)/styles.scss", "./(static or assets folder)/(css folder)/styles.css"]
The "./" points to the root of the project, then simply include the appropriate folder path.
Cheers!
The default setup for the Sass Task Runner on https://code.visualstudio.com/docs/languages/css now looks like this:
// Sass configuration
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Sass Compile",
"type": "shell",
"command": "node-sass styles.scss styles.css",
"group": "build"
}
]
}
If you get the error
"An output directory must be specified when compiling a directory"
then change the configuration like:
"command": "node-sass ./<your path>/styles.scss ./<your path>/styles.css",