[Pkg-javascript-devel] npm debian package

Jérémy Lal jerry at edagames.com
Fri Oct 7 07:39:39 UTC 2011


On 07/10/2011 01:06, Isaac Schlueter wrote:
> So, then, as a change to npm, you're suggesting that if the `--prefix`
> setting is `/usr`, then it should look for the globalconfig file as
> /etc/npmrc, and the globalignore file as /etc/npmignore.
> 
> Then, you'll put a file at /etc/npmrc to override that prefix, so that
> it's actually putting things in /usr/local instead of /usr.
> 
> I'm not sure how I feel about putting in some special case for when
> prefix==/usr.  It's inelegant, to say the least.  Special-casing based
> on the location of the npm executable is even worse.

What's inelegant is having /usr/etc/npmrc.
You cannot fit in the same scheme what goes in /usr/local and what goes in / :
/usr/(bin|lib|share)/npm /etc/npmrc
/usr/local/(bin|lib|share) /usr/local/etc/npmrc
The hierarchy is just not the same when prefix is changed, please acknowledge that.
 
> Also, if you actually install npm into prefix=/usr, but then configure
> it to operate on prefix=/usr/local, then `npm install npm -g` will
> result in two copies of npm installed, which is confusing to users.

That is right and this is what a debian user would expect to happen.
He can remove the extra /usr/local copy and fall back on his feet to the
dpkg copy if he wants to.
There are other "package managers" for other languages in debian that just
allow to do the same.
 
> It would be better, in my opinion, to install npm into a prefix of
> /usr/local, and then symlink the /usr/local/bin/npm to /usr/bin/npm,
> and symlink /usr/local/etc/{npmrc,npmignore} into /etc.

I could not do that :
http://www.debian.org/doc/debian-policy/ch-opersys.html#s9.1.2
"As mandated by the FHS, packages must not place any files in /usr/local,
 either by putting them in the file system archive to be unpacked by dpkg
 or by manipulating them in their maintainer scripts."
And it exists for a good reason : what the user put in /usr/local is up
to him.

Jérémy.
 
> On Thu, Oct 6, 2011 at 14:18, Jérémy Lal <jerry at edagames.com> wrote:
>> Thank you for your answers,
>> here is what i propose that would fit :
>>
>>
>> On 06/10/2011 19:28, Isaac Schlueter wrote:
>>> Patching node won't do the trick.  npm finds the real actual location
>>> of the node executable in the path using the `node-which` library.
>>> This is to prevent installing into some buried place like
>>> /usr/local/Cellar/node/0.4.12/exec/lib/node_modules when node is
>>> symlinked out of there to /usr/local/bin/node.
>>
>> ok.
>> patching node just to fix this was a bad idea anyway.
>>
>>
>>> I'd definitely recommend configuring npm to live someplace where you
>>> can allow it to have full reign over the global install space.  It
>>> won't ever do anything outside its global "prefix" config (or the
>>> local package for non-global installs).
>>> It appears that this is the set of constraints:
>>>
>>> 1. global config *must* be /etc/npmrc
>>> 2. `which npm` *must* be /usr/local/bin/npm
>> The debian package must distribute npm executable in /usr/bin/npm,
>> or else it won't be accepted. That does not prevent npm from reigning
>> over /usr/local/{bin,lib/node_modules,share/man}
>>
>>> 3. npm source *must not* be patched in any dramatic manner
>>> 4. npm global installs *must* still work, but *must not* write
>>> directly in /usr/local/{bin,lib/node_modules,share/man}
>> That's not what i meant at all.
>> npm-g can do whatever it wants to /usr/local/*
>> Anyway please read below.
>>
>>> I would much rather use npm's extensive configuration options to
>>> accomplish this, and not make any changes to the source itself.  If
>>> there's some reason you can't do this with the ~/.npmrc or the
>>> <prefix>/etc/npmrc files, then let's talk about what npm needs to
>>> change to support this use case.
>>
>> Here's what i propose for a minimal change to npm, that makes it possible to
>> be installed and used 100% as intended :
>>
>> if `which npm` is /usr/bin/npm, let npm find /etc/npmrc as the global config;
>> instead of /usr/etc/npmrc, which is a non-standard place to put a config file.
>> Same goes for /usr/etc/npmignore, but having /etc/npmrc is enough : the npm
>> debian package will distribute /usr/bin/npm along with /etc/npmrc containing at least
>> prefix=/usr/local
>> globalignorefile=/etc/npmignore
>>
>> It would be fantastic we could agree upon that.
>>
>> Jérémy.
>>
>>




More information about the Pkg-javascript-devel mailing list