unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* npm global prefix needs to be a writeable directory
@ 2020-11-25 23:28 Ryan Prior
  2020-11-26  6:35 ` Jelle Licht
  0 siblings, 1 reply; 4+ messages in thread
From: Ryan Prior @ 2020-11-25 23:28 UTC (permalink / raw)
  To: Development of GNU Guix and the GNU System distribution

[-- Attachment #1: Type: text/plain, Size: 614 bytes --]

Hi folks! I stumbled across an issue with the node package today and
wanted to send a report before I forget.

npm assumes that the global prefix is a writeable folder. Operations
like `npm link` will fail if it isn't. Right now our node package
doesn't set a prefix, so it defaults to the package's directory in the
store, which isn't good.

Maybe the solution is to select a folder inside the user's Guix profile
(or perhaps in their XDG_CACHE_HOME, if any) and set that explicitly as
the node global prefix using a profile hook.

In my case, I ran `npm config set prefix /home/ryan/.cache/npm` as a
workaround.

[-- Attachment #2: Type: text/html, Size: 2889 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: npm global prefix needs to be a writeable directory
  2020-11-25 23:28 npm global prefix needs to be a writeable directory Ryan Prior
@ 2020-11-26  6:35 ` Jelle Licht
  2020-11-26  7:16   ` Ryan Prior
  0 siblings, 1 reply; 4+ messages in thread
From: Jelle Licht @ 2020-11-26  6:35 UTC (permalink / raw)
  To: Ryan Prior,
	Development of GNU Guix and the GNU System distribution

Hey,

Ryan Prior <ryanprior@hey.com> writes:

> Hi folks! I stumbled across an issue with the node package today and
> wanted to send a report before I forget.
>
> npm assumes that the global prefix is a writeable folder. Operations
> like `npm link` will fail if it isn't. Right now our node package
> doesn't set a prefix, so it defaults to the package's directory in the
> store, which isn't good.

On other distros it defaults to a location that is not writable by
normal users either; it has been considered bad form to install packages
into this default global prefix using sudo for about as long as node has
been released. So I would rather say; "npm expects you to use sudo for
everything" or "npm expects you to manage your global prefix yourself"
:-)

> Maybe the solution is to select a folder inside the user's Guix profile
> (or perhaps in their XDG_CACHE_HOME, if any) and set that explicitly as
> the node global prefix using a profile hook.

Node doesn't do this on other distros either, correct?

> In my case, I ran `npm config set prefix /home/ryan/.cache/npm` as a
> workaround.

Having users set up a valid prefix is already the cannonical solution
for this exact problem, so I don't directly see why guix preventing you
from doing what you shouldn't be doing in the first place should require
extra patching.

Another way folks solved this problem has been using "nvm" which in
practice boiled down to exactly the same thing (that is, setting a
custom global prefix, just managed by nvm now).

Just my 2 cents though.

- Jelle


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: npm global prefix needs to be a writeable directory
  2020-11-26  6:35 ` Jelle Licht
@ 2020-11-26  7:16   ` Ryan Prior
  2020-11-26  8:28     ` Jelle Licht
  0 siblings, 1 reply; 4+ messages in thread
From: Ryan Prior @ 2020-11-26  7:16 UTC (permalink / raw)
  To: Development of GNU Guix and the GNU System distribution,
	Jelle Licht

[-- Attachment #1: Type: text/plain, Size: 823 bytes --]

On November 26, 2020, Jelle Licht <jlicht@fsfe.org> wrote:
> On other distros it defaults to a location that is not writable by
> normal users either;

Indeed I can confirm that Ubuntu node also has this problem.

> Node doesn't do this on other distros either, correct?
> [snip]
> Another way folks solved this problem has been using "nvm" which in
> practice boiled down to [setting a
> custom global prefix, just managed by nvm now].

I think Guix should work more like nvm than like other distros in this
case. If this is something we could handle automatically per-profile,
then that gives us the opportunity to do the right thing and save the
user some hassle.

If we decide not to go that route, I agree that we're doing no worse
than other distros that package Node. But I'm rarely satisfied with the
status quo :)

[-- Attachment #2: Type: text/html, Size: 3184 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: npm global prefix needs to be a writeable directory
  2020-11-26  7:16   ` Ryan Prior
@ 2020-11-26  8:28     ` Jelle Licht
  0 siblings, 0 replies; 4+ messages in thread
From: Jelle Licht @ 2020-11-26  8:28 UTC (permalink / raw)
  To: Ryan Prior,
	Development of GNU Guix and the GNU System distribution

Ryan Prior <ryanprior@hey.com> writes:

> On November 26, 2020, Jelle Licht <jlicht@fsfe.org> wrote:
>> On other distros it defaults to a location that is not writable by
>> normal users either;
>
> Indeed I can confirm that Ubuntu node also has this problem.
>
>> Another way folks solved this problem has been using "nvm" which in
>> practice boiled down to [setting a
>> custom global prefix, just managed by nvm now].
>
> I think Guix should work more like nvm than like other distros in this
> case. If this is something we could handle automatically per-profile,
> then that gives us the opportunity to do the right thing and save the
> user some hassle.

As long as we don't change existing behaviour by ignoring custom global
prefixes explicitly requested by the user, this seems fine to me.

Do other language-specific package managers packaged in guix not run
into similar issues?

- Jelle


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-26  8:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-25 23:28 npm global prefix needs to be a writeable directory Ryan Prior
2020-11-26  6:35 ` Jelle Licht
2020-11-26  7:16   ` Ryan Prior
2020-11-26  8:28     ` Jelle Licht

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).