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

Updated for npm 1.0: the -g option installs to the global npm bin directory #1305

Merged
merged 1 commit into from
Apr 30, 2011

Conversation

benatkin
Copy link
Contributor

Updated for npm 1.0: the -g option installs to the global npm bin directory.

Without -g, the bin is created in node-modules/.bin/coffee, which isn't expected to be in the path. This is not equivalent to cake install /usr/local/bin where it installs by default in /usr/local/bin, which is expected to be in the path.

…ectory.


Without -g, the bin is in node-modules/.bin/coffee.
@michaelficarra
Copy link
Collaborator

Or you could put your personal npm bin directory in your path and not install it globally. It's irresponsible to use npm in that way and shouldn't be promoted as the default. I am in support of mentioning that one would either need to add that directory to their path or install globally with the -g flag. -1

@TrevorBurnham
Copy link
Collaborator

Michael, I think that realistically, people would prefer for binaries installed via npm to be in a single location, rather than having to add whatever/node_modules/coffee-script/bin to their PATH.

(Edit: As Michael points out below, the rest of what I said didn't make a lick of sense and is hereby retracted.)

@michaelficarra
Copy link
Collaborator

Trevor, this is a suggestion for a documentation change for npm installing coffeescript. Users should have a bin directory (somewhere in their home directory) that is in their path. That is where binaries from npm packages should (generally) be installed, not in some global bin directory.

edit:
example: I have binroot = ~/.node/bin in my ~/.npmrc file and ~/.node/bin in my PATH. All binaries from npm packages I install go there instead of being globally installed. I don't need to append some path to my PATH for every package I install, just that one-time setup.

@TrevorBurnham
Copy link
Collaborator

Sorry, I've corrected my earlier remarks.

I still think you're expecting a lot of extra work—either adding an obscure directory to PATH or creating a symbolic link, right? -g seems like a sensible default to me. If people know what it does, they can choose to not type it. If they don't know what it does, they'll be confused when coffee isn't on their PATH, and I think I can confidently say that we'll see a lot of issues reporting that npm install coffee-script is broken.

(Edit in response to Michael's edit: Hmm, why isn't binroot defined in .npmrc by default? Also, what's the advantage of omitting -g if you do have it?)

jashkenas added a commit that referenced this pull request Apr 30, 2011
Updated for npm 1.0: the -g option installs to the global npm bin directory
@jashkenas jashkenas merged commit f76ad89 into jashkenas:master Apr 30, 2011
@michaelficarra
Copy link
Collaborator

I don't know either 1) the default binroot value or 2) why it isn't defined in .npmrc by default, but it's useful to omit -g (and I'm sure this is why they made it the default) so that you don't have to install and manage everything as root. @jashkenas: merged without comment? How'd you make your decision?

@jashkenas
Copy link
Owner

Ugh, this kind of silly backwards-incompatible path-mucking stuff is starting to approach the levels of Java CLASSPATH insanity. Let's review the history:

  • At first, npm installed globally, to /usr/local
  • Then, npm installed locally, unless you used sudo, in which case it would yell at you loudly with a page full of warnings every time you ran a command (even npm list). You were supposed to chown /usr/local to your personal user id.
  • Then, npm claimed to have solved its sudo problems, and you were only ever supposed to install with sudo -- I'm not sure where the commands were being installed, but they were being linked to /usr/local.
  • Now, you're supposed to install without -g, unless you don't want to futz with your path and don't mind installing globally (which is the case 99% of the time on developers' laptops, no?), in which case -g just does the right thing.

So, we need to come up with a policy -- how does this sound: Our installation instructions will always include -g, with a note saying that if you don't want to install globally, you should leave the -g out.

@TrevorBurnham
Copy link
Collaborator

Sounds like a plan.

On Apr 30, 2011, at 11:08 AM, jashkenasreply@reply.github.com wrote:

Ugh, this kind of silly backwards-incompatible path-mucking stuff is starting to approach the levels of Java CLASSPATH insanity. Let's review the history:

  • At first, npm installed globally, to /usr/local
  • Then, npm installed locally, unless you used sudo, in which case it would yell at you loudly with a page full of warnings every time you ran a command (even npm list). You were supposed to chown /usr/local to your personal user id.
  • Then, npm claimed to have solved its sudo problems, and you were only ever supposed to install with sudo -- I'm not sure where the commands were being installed, but they were being linked to /usr/local.
  • Now, you're supposed to install without -g, unless you don't want to futz with your path and don't mind installing globally (which is the case 99% of the time on developers' laptops, no?), in which case -g just does the right thing.

So, we need to come up with a policy -- how does this sound: Our installation instructions will always include -g, with a note saying that if you don't want to install globally, you should leave the -g out.

Reply to this email directly or view it on GitHub:
#1305 (comment)

@michaelficarra
Copy link
Collaborator

@jashkenas: Why suggest -g with a note saying that you can install without root instead of suggesting omitting -g with a note that root can install globally with -g?

@TrevorBurnham
Copy link
Collaborator

Well, the former approach is certainly less likely to lead to dupes of #1287. For people with the default npm installation, running npm without -g won't add coffee to their PATH. That's why -g should be the default in a short README that can't explain npm (much less PATH) in excruciating detail.

Btw, I spend a couple of paragraphs trying to explain npm paths and -g in the book.

On Apr 30, 2011, at 11:28 AM, michaelficarrareply@reply.github.com wrote:

@jashkenas: Why suggest -g with a note saying that you can install without root instead of suggesting omitting -g with a note that root can install globally with -g?

Reply to this email directly or view it on GitHub:
#1305 (comment)

@benatkin
Copy link
Contributor Author

benatkin commented May 1, 2011

I just noticed while reading npm help json that there's a preferGlobal option for command-line utilities like npm itself, that warns if the package isn't installed globally. It might not be right for the project in its current state, but it might make sense if the use of CoffeeScript within projects diverges from the use of CoffeeScript outside of projects that they get split into separate library and command-line interface packages.

@TrevorBurnham
Copy link
Collaborator

That sounds like an excellent idea going forward, Ben. There could easily be three independent projects:

  1. coffee-script: The compiler and Node library
  2. coffee-command: The coffee binary and command.coffee
  3. coffee-browser: The stuff that lets CoffeeScript run in the browser

The first project would be included in the other two as a git submodule.

@benatkin
Copy link
Contributor Author

benatkin commented May 1, 2011

I think the coffee-command one should be called coffee, and I hope you publish it to npm before someone else does! I've tried npm i coffee several times when I wanted the coffee command.

Edit: Before somebody else publishes something entirely different called coffee. The name coffee is already taken by coffee-script for JavaScript related stuff, I think.

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.

4 participants