Need help with Portfile

Ryan Schmidt ryandesign at macports.org
Tue Dec 9 05:46:54 PST 2014


On Dec 9, 2014, at 6:11 AM, Behrang Saeedzadeh wrote:

> As part of a Portfile I am writing, I need to install a Ruby gem, so I have added this build block:
> 
> build {
> 	   system "${prefix}/bin/gem-1.8 install CFPropertyList"
> }
> 
> This fails, because without root privileges, the gem cannot be installed.

Presumably `gem install` would install files directly into the prefix, bypassing the destroot. We would not want that. Figure out how to get `gem install` instead to install into the destroot; root permission should not be needed to do so.


> However if I change the build block to use sudo:
> 
> build {
> 	   system "sudo ${prefix}/bin/gem-1.8 install CFPropertyList"
> }
> 
> It also fails, but this time with this error message:
> 
> :info:build sh: /usr/bin/sudo: Operation not permitted
> 
> What's the proper way of invoking such commands that need root level permissions?

Set

build.asroot yes

in the portfile, but that is not the proper solution for this case. Setting a phase's asroot property to yes should not be needed in the vast majority of cases.




More information about the macports-users mailing list