Bug 177091 - www/npm: Attempts to install files at /root
Summary: www/npm: Attempts to install files at /root
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Po-Chuan Hsieh
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-18 22:40 UTC by John Marino
Modified: 2014-01-22 11:50 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Marino 2013-03-18 22:40:00 UTC
The DragonFly version poudriere sets up most of the jail as "read-only" which makes it obvious when ports are trying to install files outside of $LOCALBASE.  In this case, www/npm is trying to write to /root and it fails at the install phase:

===>  Installing for npm-1.2.12
===>   npm-1.2.12 depends on package: node>=0.8.0 - found
===>   Generating temporary packing list
===>  Checking if www/npm already installed
node cli.js install -g -f
npm WARN using --force I sure hope you know what you are doing.
npm ERR! addLocal Could not install .
npm ERR! Error: EROFS, mkdir '/root/.npm'
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System DragonFly 3.3-DEVELOPMENT
npm ERR! command "node" "/wrkdirs/www/npm/work/npm-1.2.12/cli.js" "install" "-g" "-f"
npm ERR! cwd /wrkdirs/www/npm/work/npm-1.2.12
npm ERR! node -v v0.10.0
npm ERR! npm -v 1.2.12
npm ERR! path /root/.npm
npm ERR! code EROFS
npm ERR! errno 56
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /wrkdirs/www/npm/work/npm-1.2.12/npm-debug.log
npm ERR! not ok code 0
*** Error code 56

Stop.
make: stopped in /wrkdirs/www/npm/work/npm-1.2.12

Fix: 

I suspect the makefile needs patching to prevent mkdir at $HOME
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2013-03-18 22:40:08 UTC
Responsible Changed
From-To: freebsd-ports-bugs->sunpoet

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 Chris Rees 2013-04-01 17:31:30 UTC
This patch fixes the problem for me:

http://www.bayofrum.net/~crees/patches/npm-dont-touch-base.diff

John, can you confirm?

Chris
Comment 3 John Marino 2013-04-02 22:02:11 UTC
I can confirm to the extent that I no longer have this error.  The 
package still doesn't build, but it's not because it's attempting to 
install in /root.

Thanks
Comment 4 dfilter service freebsd_committer freebsd_triage 2013-04-18 17:32:47 UTC
Author: sunpoet
Date: Thu Apr 18 16:32:40 2013
New Revision: 316049
URL: http://svnweb.freebsd.org/changeset/ports/316049

Log:
  - Change cache directory from ~/.npm to WRKSRC/tmp to avoid access on ~root/
  
  PR:		ports/177091
  Submitted by:	John Marino <draco@marino.st>
  Obtained from:	crees
  Feature safe:	yes

Modified:
  head/www/npm/Makefile

Modified: head/www/npm/Makefile
==============================================================================
--- head/www/npm/Makefile	Thu Apr 18 16:13:41 2013	(r316048)
+++ head/www/npm/Makefile	Thu Apr 18 16:32:40 2013	(r316049)
@@ -44,6 +44,9 @@ RUN_DEPENDS+=	node-devel>=0.8.0:${PORTSD
 RUN_DEPENDS+=	node>=0.8.0:${PORTSDIR}/www/node
 .endif
 
+post-patch:
+	@${REINPLACE_CMD} -e 's|node cli.js|& --cache ${WRKSRC}/tmp|' ${WRKSRC}/Makefile
+
 # maintainer section:
 # require: bash, git, gmake, node
 
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 5 Po-Chuan Hsieh freebsd_committer freebsd_triage 2013-04-18 17:33:42 UTC
State Changed
From-To: open->closed

Committed, with minor changes. Thanks!
Comment 6 Lapo Luchini 2014-01-22 11:41:04 UTC
# npm install -g

still uses /root/.npm and /root/tmp and clutters / quite fast.
I have a 1GB root UFS, and other than that it just feels wrong to me:
I'd suggest to have something like this by default:

# npm set cache=/var/cache/npm
# npm set tmp=/tmp/npm