Execute git cmd via node.js on windows fails with err - windows

git is installed on windows and works from any directory (it is in System path)
var child_process = require('child_process');
child_process.exec('git --version', function(err, stdout, stderr) {
// stdout is correct - git version 1.7.11.msysgit.1
// but err is not null
// err is [Error: Command failed: ] killed: false, code: 1, signal: null }
}
What can cause this?

I had this issue using Windows 7 with msysgit. Two things seem to solve the issue.
First, verify that your Path system variable includes a path to the Git bin directory, and not the cmd directory:
C:\Program Files (x86)\Git\bin
Next, verify you have a recent version of msysgit. I've verified the issue as solved with version 1.8.4-preview:
https://code.google.com/p/msysgit/downloads/list
Restart your shell and try again.

As a workaround you can pass {env:{PATH:"C:\path to\node"}} as the options argument to process.exec(cmd, opts, callback) as described in docs. I am surprised that the Windows path doesn't carry over but have no explanation why.

Related

Having trouble with rsync version on mac when using it with lsyncd

I am trying to synchronize a folder on my mac with one on an ubuntu server 16.06 system that I built. The problem is with the rsync version. Here is what I did. I created a file in /var/log/lsyncd/ and called it lsyncd.conf.lua. The following are its contents:
settings {
logfile = "/var/log/lysncd/lsyncd.log", -- Sets the log file
statusFile = "/var/log/lsyncd/lsyncd-status.log" -- Sets the status log file
}
sync {
default.rsyncssh, -- uses the rsyncssh defaults Take a look here: https://github.com/axkibe/lsyncd/blob/master/default-rsyncssh.lua
delete = false, -- Doesn't delete files on the remote host eventho they're deleted at the source. This might be beneficial for some not for others
source="/Users/alixchristakaze/Desktop", -- Your source directory to watch
host="", -- The remote host (use hostname or IP)
targetdir="", -- the target dir on remote host, keep in mind this is absolute path
rsync = {
binary = "/usr/local/bin/rsync",
archive = true, -- use the archive flag in rsync
perms = true, -- Keep the permissions
owner = true, -- Keep the owner
_extra = {"-a"}, -- Sometimes permissions and owners isn't copied correctly so the _extra can be used for any flag in rsync
},
maxProcesses = 1 -- We only want to use a maximum of 1 rsync processes at same time
}
I get this error when I run this command: lsyncd /var/log/lsyncd/lsyncd.conf.lua
Warn: Using /dev/fsevents which is considered an OSX internal interface.
Warn: Functionality might break across OSX versions (This is for 10.5.X)
Warn: A hanging Lsyncd might cause Spotlight/Timemachine doing extra work.
Error: Cannot access /dev/fsevents monitor! (1:Operation not permitted)
As you can see I added this line binary = "/usr/local/bin/rsync", hoping it would tell system to use the rsync I installed through homebrew. However, I am getting the error above.
I have the latest mac version 10.12.3 and my rsync version is 3.1.2 . What am I doing wrong?

knife bootstrap silent fail on windows 2008 x86

I use knife bootstrap on windows 2008 x86 server is silent fail.
It created windows batch file, but the batch file not executed and return code is 0.
the version info is
knife-windows version:1.4.1
winrm version:1.8.1
and after digging, I think found that. on knife-windows source code lib/chef/knife/winrm_session.rb "relay_command" method
remote_id = #winrm_session.open_shell
command_id = #winrm_session.run_command(remote_id, command)
=> it's not run batch file. just exit code is 0, and run other command is OK
#winrm_session.create_executor do |executor|
executor.run_cmd(cmd) do |stdout, stderr|
Chef::Log.info(cmdstdout)
Chef::Log.error(cmdstderr)
end
end
=> it's ok to run batch file. but lt's bad idea because can't get real time log
sound like the it is winrm_session run_command bug. but I'm not sure.
how to fix this?
thanks.
It was fixed via https://github.com/chef/knife-windows/pull/389
so when update knife-windows to newest version, It will be OK.

How to Install Vim Plugins in a Windows Environment

I am just getting started with Vim and setting up the environment with some of the plugins recommended by http://vimawesome.com/. I downloaded and placed plug.vim in C:\Program Files\Vim\vim74\autoload
and in C:\Program Files\Vim\vimfiles\plugin I put the git master branch nerdtree-master and renamed it to nerdtree. In the _vimrc file, which is otherwise working, I put
Plug 'scroloose/nerdtree
and
Plug 'nerdtree
Neither of these commands worked. And I receive this error:
Error detected while processing C:\Program Files\Vim\_vimrc:
line 7:
E492: Not an editor command: Plug 'nerdtree'
Error detected while processing
C:\Program Files\Vim\vim74\plugin\nerdtree\lib\nerdtree\path.vim:
I finally figured out that I had forgot to wrap the line Plug 'nerdtree' with
call plug#begin('~/.vim/plugged')
Plug 'nerdtree'
call plug#end()
Although .vim is a Linux path, Vim or Vim-Plug was able to recognize the path. I then received an error that Git must be installed. I already had Git installed, so I simply added C:\Program Files\Git\bin to the system environment variable %PATH%. After restarting Vim I typed
:PlugInstall
in the Vim editor.
The vim-plug plugin manager got to work and printed:
- Finishing ... Done!
x nerdtree:
Cloning into 'C:\Users\labbedz7\.vim\plugged\nerdtree'...
remote: Invalid username or password.
fatal: Authentication failed for 'https://git::#github.com/vim-scripts/nerdtree.git/'
Now, Git did not "authenticate" because the string in Plug 'String' refers to the GitHub URL path: http://github.com/String. By changing to the actual path: scrooloose/nerdtree I was able to run :PlugInstall again.
call plug#begin('~/.vim/plugged')
Plug 'scrooloose/nerdtree'
call plug#end()
This resulted in:
Updated. Elapsed time: 5.706874 sec.
[=]
- Finishing ... Done!
- nerdtree: Checking connectivity... done
I then added these lines to _vimrc:
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
Nerdtree is now running! It starts in Windows\System32 and is a bit slow to load, but it is running.

Nodejs - Windows Key/Certificate store

Does anybody have any pointers as to how I could go about interacting with the Key/Certificate store using nodeJs? I specifically want to add/remove certificates and possibly keys.
Update.
So the way to go here is to use "edge". Very nice work!
https://github.com/tjanczuk/edge
Without knowing too much about your setup here is a stab at a 'pointer' as to how to interact.
You could try using Nodes Child Process and then spawning out a process to the commandline and interact with the key/certificate store the way you would via command line. Microsofts certificate manager tool perhaps?
Rough example:
var exec = require('child_process').exec,
child;
child = exec('certmgr /add /all /c myFile.ext newFile.ext',
function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) {
console.log('exec error: ' + error);
}
});
I've just published node-windows-root-certs which uses ffi to read the windows root certificate store, and then apply these in nodejs... may provide some inspiration.
Example use to use Windows certificates rather than internal NodeJS certificates:
var windowsRootCerts = require('node-windows-root-certs');
// to read the windows root certs and patch in a single command:
windowsRootCerts.useWindowsCerts();
There is an npm package 'windows-certs' which uses edge and a .csx script to read certificates in .pem format
https://github.com/jfromaniello/node-windows-certs
https://www.npmjs.com/package/windows-certs
This should have the required functionality, but is marked as deprecated. The successor package is indicated as.win-ca. However, this seems to be lacking some of the functionality of the older package:
https://www.npmjs.com/package/win-ca
https://github.com/ukoloff/win-ca

Why am i getting a ENOTEMPTY error?

So i create a default meteor app.
Its runs great.
Now I add a simple insert in the startup function.
its is now giving me exceptions.
Here is my app.js code:
Book = new Meteor.Collection("book");
if (Meteor.isClient) {
Template.hello.greeting = function () {
return "Welcome to app_01.";
};
Template.hello.events({
'click input' : function () {
// template data, if any, is available in 'this'
if (typeof console !== 'undefined')
console.log("You pressed the button");
}
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
if (Book.find().count() === 0) {
var names = ["Ada Lovelace",
"Grace Hopper",
"Marie Curie",
"Carl Friedrich Gauss",
"Nikola Tesla",
"Claude Shannon"];
for (var i = 0; i < names.length; i++)
Book.insert({name: names[i], score: Math.floor(Math.random()*10)*5});
}
});
}
And here is the exception I am getting:
No dependency info in bundle. Filesystem monitoring disabled.
Errors prevented startup:
Exception while bundling application:
Error: ENOTEMPTY, directory not empty 'C:\Users\Office\Workspace\Code\Meteor\app_01\.meteor\local\build\server'
at Object.fs.rmdirSync (fs.js:456:18)
at Object.module.exports.rm_recursive (C:\Program Files (x86)\Meteor\app\lib\files.js:256:10)
at C:\Program Files (x86)\Meteor\app\lib\files.js:254:15
at Array.forEach (native)
at Function._.each._.forEach (C:\Program Files (x86)\Meteor\lib\node_modules\underscore\underscore.js:79:11)
at Object.module.exports.rm_recursive (C:\Program Files (x86)\Meteor\app\lib\files.js:252:9)
at _.extend.write_to_directory (C:\Program Files (x86)\Meteor\app\lib\bundler.js:493:11)
at Object.exports.bundle (C:\Program Files (x86)\Meteor\app\lib\bundler.js:685:12)
at exports.run.restart_server (C:\Program Files (x86)\Meteor\app\meteor\run.js:615:26)
at C:\Program Files (x86)\Meteor\app\meteor\run.js:726:9
Please fix the problem and restart.
The console gives me no useful information at all.
Some more info:
I am using the windows version of meteor 0.5.4
My code has both tabs and spaces as indentation (should that be a problem?)
to add to my perplexity:
If i run the leaderboard example, it runs perfectly.
When I run the default project with my modified startup code, i get the exception. >.<
More info:
when the server crashed, the mongod service was still running in windows. In my infinite wisdom, i thought I'll kill it and maybe try a fresh restart of it.
now i get a new error:
PS C:\Users\Office\Workspace\Code\Meteor\app_01> meteor
[[[[[ C:\Users\Office\Workspace\Code\Meteor\app_01 ]]]]]
Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Unexpected mongo exit code 100. Restarting.
Can't start mongod
MongoDB had an unspecified uncaught exception.
Check to make sure that MongoDB is able to write to its database directory.
Edit: now deleted the .meteor/local/db contents. we are now back to the ENOTEMPTY error.
It is because the directory is not getting deleted during the bundling operation.
So when this happens, Stop your server with ctrl + c.
Then delete the contents of .meteor\local\db directory as well as .meteor\local\builds directory and run the server again using meteor command.
Not an ideal way, but it works.
Just tested this on my mac and on my Windows machine, it works fine for me. (Copied and pasted your code into app.js, did not change anything anywhere else, as I understood this is what you did).
There are two ways to go on:
You try meteor reset. Warning: This will empty any databases you had within this app, but I think there isn't anything all to important in there at the moment?
You delete the app and make a new one using meteor create appname, and copy the source code from above into app.js.
I think investing too much time and effort is not worth it, since it is not an app close to production stage. If, however, creating a new app causes the same problem, it will get interesting =)
EDIT: Just searched around and found this: https://github.com/TomWij/meteor/issues/18
Scroll down to the answer; apparently it might be your antivirus scanner preventing Meteor from rebuilding it. Is that possible?
Also, are you starting Meteor from anything else than cmd.exe? I just read through the issue on GitHub, and things seem to be pretty gnarly when using anything else than cmd.exe (eg the GitHub Bash Shell)
Once my pull request goes in, this issue should be resolved:
https://github.com/TomWij/meteor/pull/56

Resources