# Rubygems user install of extensions

**URL:** <https://www.ruby-forum.com/t/rubygems-user-install-of-extensions/69922>\
**Category:** Ruby\
**Created:** [September 25, 2006, 4:46pm UTC](https://www.ruby-forum.com/t/rubygems-user-install-of-extensions/69922 "2006-09-25T16:46:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dimitri\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e68b1a/32.png) [@Dimitri\_A](https://www.ruby-forum.com/u/Dimitri_A)\
**Post date:** [September 25, 2006, 4:46pm UTC](https://www.ruby-forum.com/t/rubygems-user-install-of-extensions/69922/1 "2006-09-25T16:46:46Z")

</div>

Hello,

My problem is that I am trying to run a gems installation as a non-root  
user, and this doesn’t work out-of-the-box for any gems that include the  
building of extensions with mkmf. For each gem (example: mongrel), I  
need  
to add the following lines to extconf.rb:

require ‘etc’  
user = ENV[‘USER’]  
group = Etc.getpwnam(user).gid

module Config  
MAKEFILE\_CONFIG[“INSTALL”] = “/usr/bin/install -c -o #{user} -g  
#{group}”  
end

and regenerate the gem.

I was wondering if anyone else ran into a similar problem when  
installing a  
gem that included extensions? Do you have other solutions? Is there  
any  
way of specifying MAKEFILE\_CONFIG[“INSTALL”] in .gemrc, for example?

This happens with both 0.8.11 and svn trunk of rubygems (I applied  
Tilman  
Sauerbeck’s patch from  
[http://rubyforge.org/pipermail/rubygems-developers/2006-July/002056.html](http://rubyforge.org/pipermail/rubygems-developers/2006-July/002056.html),  
to  
solve an unrelated problem).

(This is obviously on UNIX, FreeBSD in my case; I don’t know if  
something  
similar would have to be done for Windows.)

Thanks for taking the time.

- Dimitri

---

<div class="post-metadata">

**Author:** ![Dimitri\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e68b1a/32.png) [@Dimitri\_A](https://www.ruby-forum.com/u/Dimitri_A)\
**Post date:** [October 1, 2006, 4:06pm UTC](https://www.ruby-forum.com/t/rubygems-user-install-of-extensions/69922/2 "2006-10-01T16:06:47Z")

</div>

Hi,

At Mon, 25 Sep 2006 23:44:20 +0900,  
Dimitri A. wrote in [ruby-talk:216293]:

> MAKEFILE\_CONFIG[“INSTALL”] = “/usr/bin/install -c -o #{user} -g #{group}”  
> end

INSTALL should not have -o and -g options by default. Why do  
you need those options? Does your /usr/bin/install want to  
change owner and group even if run by a non-root user?

---

<div class="post-metadata">

**Author:** ![Dimitri\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e68b1a/32.png) [@Dimitri\_A](https://www.ruby-forum.com/u/Dimitri_A)\
**Post date:** [October 2, 2006, 9:38am UTC](https://www.ruby-forum.com/t/rubygems-user-install-of-extensions/69922/3 "2006-10-02T09:38:22Z")

</div>

Hi,

On 10/1/06, Nobuyoshi N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> INSTALL should not have -o and -g options by default. Why do  
> you need those options? Does your /usr/bin/install want to  
> change owner and group even if run by a non-root user?

This is from the standard ports install on FreeBSD. I’ve also posted to  
rubygems-developers and was able to narrow it down to ports’ way of  
setting  
this variable, i.e. it doesn’t do this on Linux. So, seeing this as a  
ports  
problem, I created a PR  
([103801 – lang/ruby18: unprivileged rubygems install of gems with extensions fails](http://www.freebsd.org/cgi/query-pr.cgi?pr=103801)),  
and hope for a resolution soon. In the meantime, does anyone know of a  
standard rubygems way to override this or any other variable in the  
.gemrc  
file?

- Dimitri

---

<div class="post-metadata">

**Author:** ![Dimitri\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e68b1a/32.png) [@Dimitri\_A](https://www.ruby-forum.com/u/Dimitri_A)\
**Post date:** [October 3, 2006, 4:50am UTC](https://www.ruby-forum.com/t/rubygems-user-install-of-extensions/69922/4 "2006-10-03T04:50:32Z")

</div>

Hi,

At Mon, 2 Oct 2006 16:37:08 +0900,  
Dimitri A. wrote in [ruby-talk:217631]:

> This is from the standard ports install on FreeBSD. I’ve also posted to  
> rubygems-developers and was able to narrow it down to ports’ way of setting  
> this variable, i.e. it doesn’t do this on Linux. So, seeing this as a ports  
> problem, I created a PR ([103801 – lang/ruby18: unprivileged rubygems install of gems with extensions fails](http://www.freebsd.org/cgi/query-pr.cgi?pr=103801)),  
> and hope for a resolution soon. In the meantime, does anyone know of a  
> standard rubygems way to override this or any other variable in the .gemrc  
> file?

You could override the definition in Makefile by make  
INSTALL=‘/usr/bin/install -c’.

BTW, do ports have to be built by root? For instance, RPM used  
to be built by an ordinary user and ownerships are described in  
spec files.

---

<div class="post-metadata">

**Author:** ![Dimitri\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e68b1a/32.png) [@Dimitri\_A](https://www.ruby-forum.com/u/Dimitri_A)\
**Post date:** [October 3, 2006, 8:38am UTC](https://www.ruby-forum.com/t/rubygems-user-install-of-extensions/69922/5 "2006-10-03T08:38:42Z")

</div>

Hi,

On 10/3/06, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> You could override the definition in Makefile by make  
> INSTALL=‘/usr/bin/install -c’

Thanks for the tip! I ran across this problem when installing gems that  
compiled extensions, though. I know of no way to override this in the  
gem  
environment. So, my workaround is to edit rbconfig.rb and correct the  
CONFIG[“INSTALL”] line.

> BTW, do ports have to be built by root? For instance, RPM used  
> to be built by an ordinary user and ownerships are described in  
> spec files.

AFAIK, they do not _have_ to be built by root, but do need to be  
installed  
by root. My practise is to do a ‘make install’ in the appropriate ports  
directory, as this will also take in all dependencies and install them.  
I  
haven’t tried it using ‘sudo’, though.

- Dimitri
