VSCode build task command not found - visual-studio-code

I'm working in vscode, and I want to build the chromium in tasks.json, but the build shell report error command not found. I use echo $PATH to see the environments variables in tasks.json. It seems like the build shell in vscode doesn't execute source ~/.bashrc, so it can't find environment variable, but the terminal in vscode is in working order. Could someone help me?

I had the same issue and fixed it with the solution below
Solution For OSX with ZSH
Add a new file under /usr/local/bin/zsh-with-rc
#!/usr/bin/env zsh
source ~/.zshrc
/bin/zsh $#
Then run
chmod +x /usr/local/bin/zsh-with-rc
In settings.json add:
"terminal.integrated.automationProfile.osx": {
"path": "/usr/local/bin/zsh-with-rc",
}
Solution For Linux With Bash
Add a new file under /usr/local/bin/bash-with-profile
#!/usr/bin/env bash
source ~/.bash_profile
source ~/.bashrc
/bin/bash $#
Then run
chmod +x /usr/local/bin/bash-with-profile
In settings.json add:
"terminal.integrated.automationProfile.linux": {
"path": "/usr/local/bin/bash-with-profile",
}

Add "terminal.integrated.shell.linux": "/bin/bash" in settings.json

Related

correct PATH for zshrc in windows 10

I'm on Windows 10, installed WSL2 with Ubuntu v20 and then I installed Oh My Zsh. I thought I had everything working but when I went to type code ., in my Ubuntu terminal I got the error zsh: command not found: code.
When I do echo $PATH I get:
/home/robbie/.nvm/versions/node/v18.1.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/robbie/.yarn/bin
My .zshrc file looks like (I removed a bunch of the comments for this snippet):
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="agnoster"
plugins=(git node npm nvm z yarn)
source $ZSH/oh-my-zsh.sh
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
source /home/robbie/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
On VSCode I have the Remote WSL extension installed and set default/enabled on Ubuntu under Remote Explore.
In Windows 10 under Environment Variables, under Path I have a variable C:\Users\RobbieC\AppData\Local\Programs\Microsoft VS Code\bin
I have tried uncommenting export PATH=$HOME/bin:/usr/local/bin:$PATH - shutting down WSL, rebooting, no luck. I tried uninstalling/reinstalling the Remote WSL extension, rebooting computer, etc. No luck.
Open your regular Debian terminal App(Ensure you are in the debian home directory). Type ls -la there you will find the .zshrc file. Then remove the VScode Path you added.

VSCode asdf-vm command no such file or directory

Specs
VSCode 1.63.2
Homebrew 3.3.10
asdf 0.9.0
MacOS Monterey
Problem
I installed asdf via Homebrew as per doc http://asdf-vm.com/guide/getting-started.html#_3-install-asdf
The asdf command works well in my iTerm. However, it didn't work when committing or pushing via VScode terminal and VSCode source control.
The error from VSCode terminal
Unknown command: `asdf exec npm run pre-commit`
/usr/local/Cellar/asdf/0.9.0/libexec/bin/asdf: line 82: /usr/local/opt/asdf/lib/commands/command-help.bash: No such file or directory
And this below from VSCode source control
The error I got in output.
> git push origin feature/my-branch
Unknown command: `asdf exec npm run pre-commit`
/usr/local/Cellar/asdf/0.9.0/libexec/bin/asdf: line 82: /usr/local/opt/asdf/lib/commands/command-help.bash: No such file or directory
Running asdf exec npm run pre-commit in my iTerm works well. There must be different configuration between zsh in iTerm vs in VSCode. 🤔
My attempt so far is to add this configuration in VSCode settings.json
"terminal.external.osxExec": "iTerm.app",
"terminal.integrated.defaultProfile.osx": "zsh"
but still not working
My ~/.zshrc setup for asdf
. /usr/local/opt/asdf/libexec/asdf.sh
What is the possible cause here?
Found dubious decision
I also dont have commands folder in asdf/lib
So I copied the same from asdf/libexec/lib
And it worked

SwiftLint setup with Xcode

I am using a setup on Xcode that runs the following script for SwiftLint
if which $PATH/swiftlint >/dev/null; then
$PATH/swiftlint
elif which $HOME/.brew/bin/swiftlint >/dev/null; then
$HOME/.brew/bin/swiftlint
elif which ~/Softwares/homebrew/bin/swiftlint >/dev/null; then
~/Softwares/homebrew/bin/swiftlint
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
I am unable to use pods or brew.
To make SwiftLint available I added the following to my path by using
vim ~/.bash_profile
export PATH
export PATH=$PATH:/Users/me/Documents/SwiftLint
and I can now access SwiftLint everywhere through the command line.
However, Xcode still displays the message that SwiftLint is not installed.
I can't use another method to install Swiftlint or change the script. I guess there is a problem with my export path - what is it?
When running scripts, .bash_profile will not be considered. I would just prepend your script like this:
if test -d "${HOME}/Documents/SwiftLint"; then
PATH="${HOME}/Documents/SwiftLint:${PATH}"
fi
export PATH
if ! which swiftlint >/dev/null 2>&1; then
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint" >&2
fi
You could just export the path to system-wide variables.
Steps to do
open Terminal
run command open .zshrc
add export PATH="${HOME}/Documents/SwiftLint:${PATH}"
Save and close

Visual Studio Code: Unable to watch for file changes. Why?

I often get the "Visual Studio Code is unable to watch for file changes in this large workspace" -error and I can't figure out why.
Visual Studio Code (Linux): 1.24.1
My exclude setting is:
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/*/**": true,
"**/.svn/**": true,
"**/dist/**": true,
"**/dist-prod/**":true
}
The structure of the project is:
angular.json
/dist
/dist-prod
/e2e
ngsw-config.json
/node_modules
package.json
package-lock.json
proxy.conf.json
README.md
/src
tsconfig.json
tslint.json
xliffmerge.json
.editorconfig
.gitignore
/.svn
/src contains only 167 files and folders. I suspect that node_modules is not really excluded. But I can't know for sure. Is my settings correct?
The problem goes away after VSC is restarted, but it always comes back after a while...
you've to increase the limit. Follow the below procedure:
Check the current limit cat /proc/sys/fs/inotify/max_user_watches
edit sysctl.conf file in vim editor sudo vim /etc/sysctl.conf
Add this line at bottom fs.inotify.max_user_watches=524288
save it (esc) :wq!
To load the change sudo sysctl -p
now check again cat /proc/sys/fs/inotify/max_user_watches
if the count is same, execute the following command
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
For more details
Happy coding :)

how to use ejs lint in cli

I am using EJS as my view engine on a node and express setup. I want to use ejs-lint to help get the line for errors. I haven't use a linter before, but from reading through the documentation here: https://github.com/RyanZim/EJS-Lint
I'm assuming you can just check errors on a specified file in command line like this: ejslint
Are my assumptions right and what am I doing wrong? I've already installed using npm install ejs-lint --save-dev
Also, if I plan to add ESlint to my project I'm guessing I can have it work alongside EJSlint?
Short answer
Run it directly from the terminal:
./node_modules/.bin/ejslint src/templates/some-template.ejs
Or with npm script:
// package.json
{
...
"scripts": {
"lint:ejs": "ejslint src/templates/some-template.ejs"
}
}
// terminal
npm run lint:ejs
ESLint and EJSlint are different, exclusive processes. What is analysed by ESLint should not be analysed by EJSLint and vice versa. Having both installed will not cause any issues.
Extended answer
For what I have tested, you have to use the ejs linter CLI per file. Which is not as useful as eslint which can process multiple files, exclusions etc.
If you had some src/templates directory, you could lint all the EJS files by doing something like this:
find src/templates -type f -iname '*.ejs' -exec bash -c "./node_modules/.bin/ejslint '{}'" \;
Which would work for Unix but not for Windows. You could prepare some node script to do it cross system with the ejslint API.
There is also a grunt plugin for it.
If you want to have both ESLint and EJSLint, you should have different npm scripts for them, e.g:
// package.json
{
...
"scripts": {
"lint": "npm run lint:js && npm run lint:ejs",
"lint:js": "eslint src --ignore-path src/templates",
"lint:ejs": "find src/templates -type f -iname '*.ejs' -exec bash -c \"./node_modules/.bin/ejslint '{}'\" \\;"
}
}
If you are using grunt, you can create different tasks for eslint and ejslint and then create a group task:
grunt.registerTask('lint', ['eslint', 'ejslint']);
Actually, the following way is the easiest and by far the fastest execution time. It also has better error logging because it doesn't pass through the find command.
ejslint $(find ./ -type f -iname '*.ejs')
You can run npx ejslint **/*.ejs from the command-line in your project root to check all the ejs files in your project.
the npx is needed because you used --save-dev (or -D) if you used --global (or -g) then you can call ejs lint directly using ejslint **/*.ejs
**/*.ejs will select any file ending in .ejs in any folder.
they is no definitve instructions on usage ejslint on cmd. try and debug your lines of code yourself with a debug in your editor ,as it says its something to do with syntax error within your code. worked for me.!
Ohh ya and good news is that you can still run ESlint aswell to debug your Js files .