Skip to content
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

nodist looks good, one tweak for powershell users #23

Closed
wants to merge 20 commits into from

Conversation

fschwiet
Copy link
Collaborator

I am learning node.js, but as I try to deploy node.js to windows nodist has been really helpful.

I had two questions:

  • Is anyone working on a chocolatey installer? (http://chocolatey.org/)
  • Is anyone working on supporting .node-version files to determine the version? (its used by nodenv https://github.com/OiNutter/nodenv#readme to determine the version, this would let me use nodenv on mac and nodist against the same sourcecode) Likewise, detecting version from packages.json might be useful to others, particularly those deploying to heroku or azure.

I could help with these, but before I dug in I wanted to check if someone else was working on them. Also since I am new node.js, I'd appreciate your feedback on whether they make sense to do.

add note for powershell users
@@ -9,6 +9,7 @@ Don't install node beforehand!
2. When you've got the code, add `...path...\nodist\bin` to your path ([how?](http://www.computerhope.com/issues/ch000549.htm)).

3. Now, run `nodist update`, which will install the dependencies.
* From powershell, use cmd /c "nodist update"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this really necessary? I think it works fine for me...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Marcel, I looked into the "cmd /c" thing a bit more. It turns out the
reason it was needed for me was because my nodist path was "C:\Program
Files (x86)\nodist". If I put the files somewhere else (like
C:\src\nodist) it works. Maybe the .CMD can be updated to handle this
better? I replaced the note in the readme, though it would be better to
update the .CMD file I do not know how to do that.

I could make an attempt at adding support for reading .nodeversion file,
but I haven't been able to figure out how to run the existing tests. Node
is new to me, so if there is some convention I'm missing it.

My console output from the cmd issue wais:

C:\Program Files (x86)> nodist update
\nodist\bin\nodist.cmd"" was unexpected at this time.
C:\Program Files (x86)> get-command nodist | select path

Path
----
C:\Program Files (x86)\nodist\bin\nodist.cmd

On Wed, May 15, 2013 at 5:17 AM, Marcel Klehr notifications@github.comwrote:

In README.md:

@@ -9,6 +9,7 @@ Don't install node beforehand!

  1. When you've got the code, add ...path...\nodist\bin to your path (how?).
  2. Now, run nodist update, which will install the dependencies.
    • * From powershell, use cmd /c "nodist update"

is this really necessary? I think it works fine for me...


Reply to this email directly or view it on GitHubhttps://github.com//pull/23/files#r4233332
.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah. the space in path bug again...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the bright side, if someone installs via chocolatey then the path will
not have a space. I tried to put together a package (learning chocolatey
too...), it worked on my last attempt:
https://github.com/fschwiet/nodist/blob/chocolatey/chocolatey/tools/chocolateyInstall.ps1

Still experimental, to use it, install chocolatey (http://chocolatey.org/)
then build/install the package:
c:\nodist\chocolately> cpack
c:\nodist\chocolately> cinst nodist -source c:\nodist\chocolately

On Wed, May 15, 2013 at 12:15 PM, Marcel Klehr notifications@github.comwrote:

In README.md:

@@ -9,6 +9,7 @@ Don't install node beforehand!

  1. When you've got the code, add ...path...\nodist\bin to your path (how?).
  2. Now, run nodist update, which will install the dependencies.
    • * From powershell, use cmd /c "nodist update"

ah. the space in path bug again...


Reply to this email directly or view it on GitHubhttps://github.com//pull/23/files#r4241931
.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up uploading the chocolatey package to the official gallery:
http://chocolatey.org/packages/nodist. Its marked as prerelease now
though, so people will recognize its perhaps not done. It seems to work
well though, I've ran it on a few VMs now successfully.

On Wed, May 15, 2013 at 2:16 PM, Frank Schwieterman fschwiet@gmail.comwrote:

On the bright side, if someone installs via chocolatey then the path
will not have a space. I tried to put together a package (learning
chocolatey too...), it worked on my last attempt:
https://github.com/fschwiet/nodist/blob/chocolatey/chocolatey/tools/chocolateyInstall.ps1

Still experimental, to use it, install chocolatey (
http://chocolatey.org/) then build/install the package:
c:\nodist\chocolately> cpack
c:\nodist\chocolately> cinst nodist -source c:\nodist\chocolately

On Wed, May 15, 2013 at 12:15 PM, Marcel Klehr notifications@github.comwrote:

In README.md:

@@ -9,6 +9,7 @@ Don't install node beforehand!

  1. When you've got the code, add ...path...\nodist\bin to your path (how?).
  2. Now, run nodist update, which will install the dependencies.
    • * From powershell, use cmd /c "nodist update"

ah. the space in path bug again...


Reply to this email directly or view it on GitHubhttps://github.com//pull/23/files#r4241931
.

@marcelklehr
Copy link
Member

Nobody's working on anything right now, afaik.

.node-version files and package.json version detection sounds interesting. So does a chocolatey installer, although I'm not aware of how much work that'd be.

Help is always appreciated :)

@marcelklehr
Copy link
Member

Mh. It doesn't seem to add any commands to chocolatey/bin, though.

chocInstall.ps1 should probably add nodist/bin to the path, no? And how can I stop chocolatey from detecting the node.exe in nodist's root?

@fschwiet
Copy link
Collaborator Author

fschwiet commented Dec 3, 2013

I tried to repro this on a clean machine. I wish I took better notes as I thought I had a repro, as after rebooting the problem went away.

What I recall observing was that there was a node command accessible, but not a nodist command. After rebooting this (I assume the reboot changed things) I have both a node and nodist command available from cmd or powershell prompt.

After rebooting, the node and nodist commands are being found where the files were unpacked:

PS C:\Users\user> Get-Command node | select path
Path
----
C:\Chocolatey\lib\nodist.0.3.12-beta\tools\nodist-master\bin\node.exe

PS C:\Users\user> Get-Command nodist | select path
Path
----
C:\Chocolatey\lib\nodist.0.3.12-beta\tools\nodist-master\bin\nodist.ps1

The chocolatey package is adding that to the path at the machine level from https://github.com/marcelklehr/nodist/blob/master/chocolatey/tools/chocolateyInstall.ps1 with "Install-ChocolateyPath $binPath 'Machine'".

My hypothesis is that the machine-level path update isn't kicking until after the reboot for some reason. I'm not sure what the appropriate fix would be. We could try to fix the path inclusion of C:\Chocolatey\lib\nodist.0.3.12-beta\tools\nodist-master\bin perhaps by making the change to the user environment variable (instead of system level, as it does now). Or we could try to get a nodist.bat file created at c:\chocolatey\bin. I think using c:\chocolatey\bin is the Right Way to do it, and I was probably doing the wrong thing when trying to modify path variables before. That said, I have no idea what part of the chocolatey script is creating the node.bat file. I suspect chocolatey is scanning for .exe files automatically and creating a .bat for it automatically.

Still thinking about this. Saving my notes for now.

Here is the console results of the original chocolatey install:

Windows PowerShell
Copyright (C) 2012 Microsoft Corporation. All rights reserved.

PS C:\Users\user> cinst nodist -pre
Chocolatey (v0.9.8.23) is installing 'nodist' and dependencies. By installing you accept the license for 'nodist' and ea
ch dependency you are installing.
______ nodist v0.3.12-beta ______

Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----        12/02/2013     16:03            nodist
Downloading nodist 64 bit (https://github.com/marcelklehr/nodist/archive/master.zip) to C:\Users\user\AppData\Local\Temp
\chocolatey\nodist\nodistInstall.zip
Extracting C:\Users\user\AppData\Local\Temp\chocolatey\nodist\nodistInstall.zip to C:\Chocolatey\lib\nodist.0.3.12-beta\
tools...
C:\Chocolatey\lib\nodist.0.3.12-beta\tools
nodist has finished successfully! The chocolatey gods have answered your request!
Installing nodist at C:\Chocolatey\lib\nodist.0.3.12-beta\tools\nodist-master\bin
PATH environment variable does not have C:\Chocolatey\lib\nodist.0.3.12-beta\tools\nodist-master\bin in it. Adding...
Elevating Permissions and running C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy
unrestricted -Command "& import-module -name  'C:\Chocolatey\chocolateyinstall\helpers\chocolateyInstaller.psm1'; try{[E
nvironment]::SetEnvironmentVariable('Path','C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\
WindowsPowerShell\v1.0\;C:\Chocolatey\lib\nodist.0.3.12-beta\tools\nodist-master\bin;', 'Machine'); start-sleep 6;}catch
{write-error 'That was not sucessful';start-sleep 8;throw;}". This may take awhile, depending on the statements.
Running nodist update
Elevating Permissions and running C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy
unrestricted -Command "& import-module -name  'C:\Chocolatey\chocolateyinstall\helpers\chocolateyInstaller.psm1'; try{C:
\Chocolatey\lib\nodist.0.3.12-beta\tools\nodist-master\bin\nodist.cmd update; start-sleep 6;}catch{write-error 'That was
 not sucessful';start-sleep 8;throw;}". This may take awhile, depending on the statements.
nodist has finished successfully! The chocolatey gods have answered your request!
Adding C:\Chocolatey\bin\node.bat and pointing to '%DIR%..\lib\nodist.0.3.12-beta\tools\nodist-master\bin\node.exe'.
Adding C:\Chocolatey\bin\node and pointing to '%DIR%..\lib\nodist.0.3.12-beta\tools\nodist-master\bin\node.exe'.
Adding C:\Chocolatey\bin\node.bat and pointing to '%DIR%..\lib\nodist.0.3.12-beta\tools\nodist-master\node.exe'.
Adding C:\Chocolatey\bin\node and pointing to '%DIR%..\lib\nodist.0.3.12-beta\tools\nodist-master\node.exe'.
Finished installing 'nodist' and dependencies - if errors not shown in console, none detected. Check log for errors if u
nsure.


Reading environment variables from registry. Please wait... Done.
PS C:\Users\user>

@fschwiet
Copy link
Collaborator Author

fschwiet commented Dec 3, 2013

There is a note about .batch file redirects here: https://github.com/chocolatey/chocolatey/wiki/CreatePackages
It does look like it scans for .exe files. I noticed c:\chocolatey\bin points to C:\Chocolatey\lib\nodist.0.3.12-beta\tools\nodist-master\node.exe and not C:\Chocolatey\lib\nodist.0.3.12-beta\tools\nodist-master\bin\node.exe. Should it be pointing to the later node.exe in the bin folder?

I suspect we may need to add a "node.exe.ignore" file for the node.exe in tools\nodist-master, and manually create batch redirects for node and nodist in tools\nodist-master\bin. I'm going to ask the chocolatey forum if there is a correct way to create batch redirects.

@fschwiet
Copy link
Collaborator Author

fschwiet commented Dec 3, 2013

I asked my question on the chocolatey discussion alias, here: https://groups.google.com/forum/#!topic/chocolatey/U80l-Oy3nXw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants