-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows: infer CouchDB installation dynamically #26
Comments
First of all the command is
You should specify the current path to the value. Following command will query Microsoft's Uninstall service which keeps track of the installed sotfware:
If the key is not found it exits with the status code 1. |
If there's no hurry, I'm willing to give it a shot. Also, for additional reference, the reg key for 32-bit Windows installs should be:
|
@aztech-dev Thanks, that helps a lot! Retrieving the value should be as easy as |
Cool, sounds like we have all the prerequisites. If anyone feels hacky over the holidays, this would make a neat little project :) |
"use strict";
var child_process = require("child_process"),
os = require("os"),
key = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ApacheCouchDB_is1";
// Use different key on 64-bit Windows
if(os.arch() == "x64") {
key = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ApacheCouchDB_is1";
}
var command = 'reg query ' + key + ' /v "Inno Setup: App Path"';
child_process.exec(command, function(err, stdout, stderr) {
if(err) {
throw err;
}
var lines = stdout.trim().split(os.EOL);
console.log(/^Inno Setup: App Path\s+REG_SZ\s+(.+)$/.exec(lines[1].trim())[1]);
}); That's what a the first working version after 5min looks. As far as I can tell it works for me. The next question is where and how to integrate this into multicouch.js. |
@Acconut excellent! I’d say: put this in a new file |
And which path should be returned if we can't get the entry in the registry? The default as seen in https://github.com/hoodiehq/node-multicouch/blob/master/lib/multicouch.js#L17? |
Yeah, wouldn't hurt trying that! If this causes trouble for users later, we can then throw an error.
|
any update on this? :) |
I stopped working on this since I switched my primary development machine to Ubuntu. :) |
@Acconut are you interested in finishing this? |
I may give it a second try but won't promise anything regarding timing. :) |
Hi, It seems this issue is still open, so I tried to find a solution. I've used the originals from @Acconut and added a few functions to convert raw child_process.exec into a Promise so the returned data could be passed over to multicouch.js. The solution contains a file called find-executable-win.js that executes the 1st half of the job. The other file is a modified version of multicouch.js that finishes the job by executing the 2nd half. I know it sounds like an abomination and just believe me: This solution is a nice example on how you can irreparably damage your own coding career (or at least become a joke on Twitter) 😅 Here's a screenshot from my machine. Here are the two files: sources.zip I think it's a bit too early to send a pull request. Maybe someone could test the stuff. Thanks. Kind regards, |
@brakmic thanks for looking into this, could you still open a PR (preface with WIP — work in progress — so we don’t merge it), that’d make it easier to follow your changes. Don’t worry about it being unfinished ;) |
Ok. Will do it. |
Sorry for the multi posts, but they seem to be related. I have a hard time understanding which is the problem, because it finds Node, so why won't npm clean its cache? And I reinstalled CouchDB in its default location, yet it still won't find Erlang. I suppose that having a local copy of Erlang is better than using the one installed by default on my machine? |
Hi @GRUBMEISTER, If you have some time you could test my proposed patch. Maybe it'll help you avoid the issue (and also help others as we need more tests to prove the patch). Here's the link: #31 |
OK. |
So, If you could help me with some directions. I'm still learning JS. |
And I'm kinda new to GitHub as well. |
Well, I wouldn't misuse this tread for such things. There are a plenty of good resources. But, as a starting point you should check-out my multicouch-repo as it contains the aforementioned patch: https://github.com/brakmic/node-multicouch |
I don't expect you to tutor me on JS or Git right here now. My question is, to merge these into my installation, can I just replace the two files on my system? |
Actually, one of the files replaces the original file, and the other file is a new one, containing the patch (find-executable-win.js). Both of the files are full with comments so it should be very easy to replace/insert them. But beware: I don't know anything about your installation so I'd rather avoid giving you any "good advices" regarding your system. If you're merely testing CouchDB on your machine and not using it for any productive stuff then you should, of course, replace the original node-multicouch with the one from my repo. |
Thank you, I simply heard about Hoodie on a podcast, and have been reading about it a bit. I am not anywhere ready for a full on production site yet, still learning Javascript. But it sounded interesting. I work a full time job outside of IT so my time to learn and write code is limited. I'll attempt to test it. |
So does the find-executable file go in the same directory as the muticouch.js? I am replacing them in the actual created application file structure. |
Just replace the original multicouch with the patched one. |
The one Node installed I thought it would be easier to keep it localized to the application. Not a good idea? Where do I put find-executable-win ? |
I'm sorry but I don't understand your question. The only thing that should be done is replacing the node-multicouch in your node_modules directory. Please replace the original node-multicouch with the patched one. Or, you can simply copy the original one to some safe place during testing and then bring it back when done. |
I was planning on just replacing the two files. Therein lies the problem. Sorry. |
Just put the files where they belong to. Or you can simply download the zip-file from my repo and unpack them directly into your node_modules. No need for you to manually replace anything. If you want to save the original files then just make a copy of the whole node-multicouch. Manually replacing certain files is just an invitation to additional problems. |
It worked like a charm |
I had also set various environmental variables, but nothing seemed to work. |
You're welcome. Thanks for testing it! |
Luck of the draw that I happened to be messing with it now and you happened to be looking for testers. Strange but good. Regards |
Did you update this into the repository, or is it still non functional? Just purged node cache and tried reinstalling multicouch, couch, hoodie-cli it still errors out in Windows. Any idea when this something like this is going to make it into the main code? I would be nice to be able to work just do a quick install and have this working.... |
@GRUBMEISTER is the comment above still relevant for you? For the new Hoodie, you should do a simple install and have everything working, without even needing CouchDB |
Currently, multicouch expects the default installation location for the CouchDB installer on Windows. There are good reasons why people do not use the default install location, and those people can’t use multicouch. In particular, this comes up in Hoodie, which uses multicouch under the hood (har har).
The most convenient way that a cursory search brought up is using a (gasp) Registry Search. In particular:
req query HKLM\SOFTWARE /s /f CouchDB
gives us a bunch of information about the install location of the CouchDB package. Exactly what we want.Next steps:
Any takers? :)
The text was updated successfully, but these errors were encountered: