Visual Studio Code: Unable to watch for file changes. Why? - visual-studio-code

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 :)

Related

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

How can I fix [Ycm] Invalid ycm path in vs code?

In Vs code whenever i open VS code application this message is pop up.
[Ycm] Invalid ycm path
What is the meaning of this message and how do i can fix this?
Hiļ¼ŒI have fixed this noteļ¼Œbut looks like ycm does not work.
--
I use this link to fix.
My command have some differences.
git clone https://github.com/Valloric/YouCompleteMe.git
cd YouCompleteMe
git submodule update --init --recursive
cd third_party
mkdir ycmd_build
cmake -G "Unix Makefiles" . /Users/xx/software_cfg/ycm/YouCompleteMe/third_party/ycmd/cpp
Then copy 'ycm_core.cpython-310-darwin.so' to VS Code ycmd path.
--
After these settingļ¼ŒI found ycm still not work.
Just add one dir path in [Ycmd: Path], the note will disappear.

VSCode build task command not found

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

What changes needed in .spec file to rename installing software?

I am trying to rebuild nano rpm package on CentOS 8 so after installing it I will be able to run nano using command newnano.
After some googling I came to the conclusion that I need to change .spec file and build package using command rpmbuild -ba nano.spec.
Here is what I've already tried:
Changing name in the beginning of .spec file, so it looked like that:
Summary: A small text editor Name: newnano ...
But when I tried to build package there was error: Bad exit status from '/var/tmp/rpm-tmp.DSP7dc (%prep) As I understand after unzip tar archive its tried to cd newnano-2.9.8 but there is no such directory.
Adding alias in %install section:
%install cd build %make install rm -f %{buildroot}%{_infodir}/dir
alias newnano="nano" ...
Building and installation was successful but alias was not created.
Using %package. I insert after %description and before %prep in original .spec this:
%package -n newnano Summary: test %description -n newnano test
Also I add -n newnano to %files section. Building and installation was successful but new command was not added.
So how I have to change .spec file to achieve my goal?
There is a very simpe way to do it via rpmrebuild and .rpm nano package.
rpmrebuild -enp nano.rpm
In .spec file (it will open after previous comand) you should do these:
replace Name: nano with Name: newnano (optional, but recommended)
add mv /usr/bin/nano /usr/bin/newnano before the first exit 0 line. This section you can find before %changelog
Look carefully and remember the path of rebuilded .rpm that you will see after you close vim
Install rebuilded .rpm via rpm -i command
(Optional: maybe you will need to reboot)
You'll have to do a few things:
Get the current specfile (looks like you did that)
Change the name of the RPM (looks good)
Change the name of the GNU package (hint: look in configure.ac)
Add another patch to the RPM that modifies the final executables (hint: look in src/Makefile.am - you want to rename nano and remove the rnano symlink)
Rebuild
Instead of messing with src/Makefile.am, you can probably rename things in the %install stanza of the specfile, but I don't know enough about nano to tell you if it will be still identifying itself properly, etc.
Have fun!

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 .