tag:help.rubygems.org,2010-01-19:/discussions/problems/256-gem-install-mygem-does-not-install-the-gemRubyGems.org: Discussion 2011-04-07T20:59:31Ztag:help.rubygems.org,2010-01-19:Comment/24177922010-07-30T18:51:24Z2010-07-30T18:51:24Z"gem install mygem" does not install the gem <div><p>Do you have a source code repository somewhere your gem?</p>
<p>If not, can you upload your completed gem?</p></div>Eric Hodeltag:help.rubygems.org,2010-01-19:Comment/24177922010-08-02T05:08:22Z2010-08-02T05:09:46Z"gem install mygem" does not install the gem <div><p>Yes, I do have! But, let me upload here the latest code that I have built. I haven't updated the SVN as I cannot totally get it pushed. So, below is the attachment.</p>
<p>There is one tricky thing for you. This gem is a Driver for CUBRID Database. Which means that you can install it (make and then install) if you have CUBRID installed, as there is a C API which it links to and the header files in its include directory.</p>
<p>So, if you wish to test it directly, you are welcome to download the CUBRID installer (<a href="http://www.cubrid.org/downloads">http://www.cubrid.org/downloads</a>). If not, I would be happy if you could point me to the reason why the gem cannot get installed properly.</p>
<p>Thank you drbrain!</p>
<p>Esen.</p></div>Esen Sagynovtag:help.rubygems.org,2010-01-19:Comment/24177922010-08-02T09:21:11Z2010-08-03T01:17:53Z"gem install mygem" does not install the gem <div><p>It seems like I have accidentally removed the "s.extension" specification. That's why I guess the Gem didn't know what to build.</p></div>Esen Sagynovtag:help.rubygems.org,2010-01-19:Comment/24177922010-08-02T20:34:10Z2010-08-02T20:34:10Z"gem install mygem" does not install the gem <div><p>Ok, great!</p></div>Eric Hodeltag:help.rubygems.org,2010-01-19:Comment/24177922010-08-03T02:33:21Z2010-08-03T02:34:47Z"gem install mygem" does not install the gem <div><p>drbrain,</p>
<p>In order to install the gem you have to run the command under the "sudo". However, some very weird behavior is happening with Ruby when I run the code with "sudo" command.</p>
<p>Let's say I have the following code in "myex.rb" source file:</p>
<p>if ENV["CUBRID"]<br />
puts "ENV[CUBRID] is: '#{ENV["CUBRID"]}'"
else<br />
puts "$CUBRID_BROKER is not defined. Possibly you have not installed CUBRID Database yet."
end</p>
<p>I have installed the CUBRID Database, and when I run the code by typing "ruby myex.rb" I correctly receive the path where CUBRID has been installed:</p>
<p>ENV[CUBRID] is: '/home/esen/programfiles/CUBRID'</p>
<p>However, when I run this code with "sudo" at the beginning like "sudo ruby myex.rb", the "ENV['CUBRID']" is actually nil, thus, returns the second string in the else block.</p>
<p>Am I doing something wrong?<br />
Could you please explain why "sudo" neglects all ENVironmental variables?</p></div>Esen Sagynovtag:help.rubygems.org,2010-01-19:Comment/24177922010-08-03T21:21:09Z2010-08-03T21:21:09Z"gem install mygem" does not install the gem <div><p>You've probably configured sudo to strip unfamiliar environment variables. Try sudo -E.</p></div>Eric Hodeltag:help.rubygems.org,2010-01-19:Comment/24177922010-08-04T01:15:01Z2010-08-04T01:15:01Z"gem install mygem" does not install the gem <div><p>I found the reason. Actually, by default Ubuntu is configured sudoer setting env_reset to ON, which means that when running sudo all non-system (safe) variables, including user paths, will be reset, that is cleared off. Only system variables and their save values will remain. There are several solutions:</p>
<ol>
<li>To set that env_reset to OFF, manually.<br />
</li>
<li>Manually, set the necessary paths to the safe_path.<br />
</li>
<li>Manually, add -E flag right after the sudo command and before the rest command "gem install....".<br />
</li>
<li>Manually, create alias for sudo so that it always runs -E or safe_path together.</li>
</ol>
<p>-E was exactly what I did and it worked for me just fine. However, since I am building a gem for global users and don't want to make every one of them to type -E after the sudo in order to get my gem installed.</p>
<p>I looked at other gems how they solve this problem, as I can install them without -E. For instance, I have attached the sample code found in mysql's extconf.rb file, which somehow deals with this problem as it also extracts ENV['PATH'] variable, just like me. But when installing mysql, I do not need to type -E.</p>
<p>I saw in mysql's code it adds the -E flag to the cpp_command and prints it out to the "system", but somehow I cannot replicate it.</p>
<p>Could you please look at the code and point me to the possible solution? I would be unbelievable grateful for your help! There should be some way to set this -E in runtime as if I added it manually.</p>
<p>Any guide is highly appreciated.</p>
<p>Thank you, drbrain, in advance!</p>
<p>Esen.</p></div>Esen Sagynovtag:help.rubygems.org,2010-01-19:Comment/24177922010-08-04T02:50:48Z2010-08-04T02:50:48Z"gem install mygem" does not install the gem <div><p>I forgot to attach the mysql extconf.rb code. Here is it.</p></div>Esen Sagynovtag:help.rubygems.org,2010-01-19:Comment/24177922010-08-16T20:16:42Z2010-08-16T20:16:42Z"gem install mygem" does not install the gem <div><p>Any update on this? I don't have too much experience with C extensions...maybe someone in #ruby-lang or #rubygems on IRC could help?</p></div>Nick Quarantotag:help.rubygems.org,2010-01-19:Comment/24177922010-08-17T01:10:10Z2010-08-17T04:57:20Z"gem install mygem" does not install the gem <div><p>Yeah, I found the temporary solution. The problem was in Linux Ubuntu "sudo" was reseting the ENVironmental variables like the PATH to CUBRID Database Server, which I need when installing the gem. So, I looked all over the internet posted at ruby-forum.com<br />
<a href="http://www.ruby-forum.com/topic/214260#new">http://www.ruby-forum.com/topic/214260#new</a>,<br />
and in Google Groups for Ruby on Rails<br />
<a href="http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/bc598b7d56195a2b/22ea4c28874f49c5?lnk=gst&q=cubrid#22ea4c28874f49c5">http://groups.google.com/group/rubyonrails-talk/browse_thread/threa...</a>.</p>
<p>Finally found a temp solution to use -E flag when running sudo like</p>
<p>"sudo -E gem install cubrid"</p>
<p>-E flag would give a notice to sudo not to reset the ENV variables.</p>
<p>However, I am still curious how does mysql gem solve this issue, as it also addresses the EVN variables, but I do not need to use -E flag.</p></div>Esen Sagynovtag:help.rubygems.org,2010-01-19:Comment/24177922010-08-31T01:16:16Z2010-08-31T01:16:16Z"gem install mygem" does not install the gem <div><p>Cool, considering this resolved then.</p></div>Nick Quaranto