Bug 974983 - The gem executable path does not exist
The gem executable path does not exist
Status: CLOSED CURRENTRELEASE
Product: OpenShift Online
Classification: Red Hat
Component: Containers (Show other bugs)
2.x
Unspecified Unspecified
medium Severity low
: ---
: ---
Assigned To: Hiro Asari
libra bugs
:
Depends On: 974632
Blocks:
  Show dependency treegraph
 
Reported: 2013-06-17 06:16 EDT by Jianwei Hou
Modified: 2015-05-14 19:21 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-07-22 11:16:44 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Jianwei Hou 2013-06-17 06:16:04 EDT
Description of problem:
Create a ruby application, in rhcsh, run 'gem env' and notice the executable path is /var/lib/openshift/$UUID/bin. However, the executable path does not actually exist, and user do not have sufficient privildge to create such a directory

Version-Release number of selected component (if applicable):
On devenv_3368

How reproducible:
Always

Steps to Reproduce:
1. Create a ruby application
2. ssh into gear, run 'gem env'
3. go to the executable directory

Actual results:
After step 2:
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.24
  - RUBY VERSION: 1.9.3 (2013-05-15 patchlevel 429) [x86_64-linux]
  - INSTALLATION DIRECTORY: /var/lib/openshift/51bea33b1354510733000002/.gem/ruby/1.9.1
  - RUBY EXECUTABLE: /opt/rh/ruby193/root/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /var/lib/openshift/51bea33b1354510733000002/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /var/lib/openshift/51bea33b1354510733000002/.gem/ruby/1.9.1
     - /opt/rh/ruby193/root/usr/share/gems
     - /opt/rh/ruby193/root/usr/local/share/gems
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

After step 3:
[rails-jhou.dev.rhcloud.com 51bea33b1354510733000002]\> ls /var/lib/openshift/51bea33b1354510733000002/bin
ls: cannot access /var/lib/openshift/51bea33b1354510733000002/bin: No such file or directory


Expected results:
Maybe the executable path should be valid[rails-jhou.dev.rhcloud.com 51bea33b1354510733000002]\> ls /var/lib/openshift/51bea33b1354510733000002/bin
ls: cannot access /var/lib/openshift/51bea33b1354510733000002/bin: No such file or directory


Additional info:
Comment 1 Hiro Asari 2013-06-17 12:14:03 EDT
https://bugzilla.redhat.com/show_bug.cgi?id=974632 should move $GEM_HOME to ~/.gem. We still need to add $GEM_HOME/bin to $PATH.
Comment 2 Hiro Asari 2013-06-17 12:46:17 EDT
See https://github.com/openshift/origin-server/pull/2865
Comment 3 Hiro Asari 2013-06-17 12:47:03 EDT
[rack-fooooooooooo.dev.rhcloud.com 172097536760743733493760]\> gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.24
  - RUBY VERSION: 1.9.3 (2013-05-15 patchlevel 429) [x86_64-linux]
  - INSTALLATION DIRECTORY: /var/lib/openshift/172097536760743733493760/.gem
  - RUBY EXECUTABLE: /opt/rh/ruby193/root/usr/bin/ruby
  - EXECUTABLE DIRECTORY: /var/lib/openshift/172097536760743733493760/.gem/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /var/lib/openshift/172097536760743733493760/.gem
     - /var/lib/openshift/172097536760743733493760/.gem/ruby/1.9.1
     - /opt/rh/ruby193/root/usr/share/gems
     - /opt/rh/ruby193/root/usr/local/share/gems
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/
Comment 4 Hiro Asari 2013-06-17 13:33:40 EDT
Note that $PATH will be set up in such a way that the primary cartridge's OPENSHIFT_*_PATH_ELEMENT will take precedence. This means that, on a Ruby cartridge, the executables that the platform installs (such as 'thor', 'rake') will be used even when a different one was installed via 'gem'.
Comment 5 openshift-github-bot 2013-06-27 10:18:01 EDT
Commit pushed to master at https://github.com/openshift/origin-server

https://github.com/openshift/origin-server/commit/fcc90265dee4fcaa7b9e4804775dfafec736ea0b
Bug 974983

Set up $PATH so that executables installed by a gem can be found.
Comment 6 Xiaoli Tian 2013-07-09 01:50:32 EDT
Hi, Hiro

Are there any more changes for this bug? if not, please help to move it to ON_QA.

Thanks
Comment 7 Jianwei Hou 2013-07-09 22:26:17 EDT
Tested on devenv_3471

New environment variable added
[r18-jhou.dev.rhcloud.com .gem]\> env|grep RUBYGEMS
OPENSHIFT_RUBYGEMS_PATH_ELEMENT=/var/lib/openshift/539525222203891642269696/.gem/bin

The gem executable directory is valid
[r18-jhou.dev.rhcloud.com .gem]\> gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.3.7
  - RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
  - INSTALLATION DIRECTORY: /var/lib/openshift/539525222203891642269696/.gem
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /var/lib/openshift/539525222203891642269696/.gem/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /var/lib/openshift/539525222203891642269696/.gem
     - /var/lib/openshift/539525222203891642269696/.gem/ruby/1.8
     - /usr/lib/ruby/gems/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

install gem from rhcsh
[r18-jhou.dev.rhcloud.com .gem]\> gem install rake
Successfully installed rake-10.1.0
1 gem installed
Installing ri documentation for rake-10.1.0...
Installing RDoc documentation for rake-10.1.0...
[r18-jhou.dev.rhcloud.com .gem]\> gem list rake

*** LOCAL GEMS ***

rake (10.1.0, 0.8.7)
[r18-jhou.dev.rhcloud.com .gem]\> rake --version
rake, version 10.1.0
[r18-jhou.dev.rhcloud.com .gem]\> which rake
/var/lib/openshift/539525222203891642269696/.gem/bin/rake

The user installed gem takes precedence to the platform installed ones
Comment 8 Jianwei Hou 2013-07-09 22:40:40 EDT
Comment 7 is based on a ruby-1.8 application, for ruby-1.9 cartridges, the $OPENSHIFT_RUBYGEMS_PATH_ELEMENT does not take precedence to $PATH, that means platform installed gems take precedence to user installed gems. 


ruby-1.8
[r18-jhou.dev.rhcloud.com 539525222203891642269696]\> echo $PATH
/var/lib/openshift/539525222203891642269696/.gem/bin::/bin:/usr/bin:/usr/sbin
[r18-jhou.dev.rhcloud.com 539525222203891642269696]\> gem list rake

*** LOCAL GEMS ***

rake (10.1.0, 0.8.7)
[r18-jhou.dev.rhcloud.com 539525222203891642269696]\> which rake
/var/lib/openshift/539525222203891642269696/.gem/bin/rake


ruby-1.9
[r19-jhou.dev.rhcloud.com .gem]\> echo $PATH
/opt/rh/ruby193/root/usr/bin:/var/lib/openshift/51dcc4626bb15a0e4e000001/.gem/bin:/opt/rh/ruby193/root/usr/bin::/bin:/usr/bin:/usr/sbin
[r19-jhou.dev.rhcloud.com .gem]\> gem list rake

*** LOCAL GEMS ***

rake (10.1.0, 0.9.2.2)
rake-compiler (0.8.3)
[r19-jhou.dev.rhcloud.com .gem]\> which rake
/opt/rh/ruby193/root/usr/bin/rake


The ruby-1.8 and ruby-1.9 cartridges behave differently, so assign this back in case this is not what we expect.
Comment 9 openshift-github-bot 2013-07-10 10:56:34 EDT
Commit pushed to master at https://github.com/openshift/origin-server

https://github.com/openshift/origin-server/commit/136f0ec6b5611045c7bd0693e721187ed4118cdc
Bug 974983

Set up $PATH so that ~/.gem/bin precedes /opt/rh/ruby193/root/usr/bin or
/usr/bin (as appropriate).

This effectively reverts fcc9026, which added RubyGems' path during the
user setup. That commit was incomplete, since that led to inconsistency
with the 1.9 apps (see
https://bugzilla.redhat.com/show_bug.cgi?id=974983#c8).

Instead, we use $OPENSHIFT_RUBY_PATH_ELEMENT to ensure that $PATH is
correct. (It is possible to use $OPENSHIFT_RUBYGEMS_PATH_ELEMENT still,
but that relies on $*_PATH_ELEMENT processing order, which we need to
avoid here.)
Comment 10 Jianwei Hou 2013-07-11 02:04:43 EDT
Tested on devenv_3482, the $PATH issue has been fix for ruby applications.

ruby-1.8
[r18-jhou.dev.rhcloud.com 51de481b36ff800a00000004]\> echo $PATH
/var/lib/openshift/51de481b36ff800a00000004/.gem/bin:/var/lib/openshift/51de481b36ff800a00000004/.gem/bin::/bin:/usr/bin:/usr/sbin


ruby-1.9
[r19s-jhou.dev.rhcloud.com 51de478436ff800a00000001]\> echo $PATH
/var/lib/openshift/51de478436ff800a00000001/.gem/bin:/opt/rh/ruby193/root/usr/bin:/var/lib/openshift/51de478436ff800a00000001/haproxy/usr/bin:/var/lib/openshift/51de478436ff800a00000001/.gem/bin:/opt/rh/ruby193/root/usr/bin::/bin:/usr/bin:/usr/sbin

@Hiro, can you please move this bug to ON_QA? thanks
Comment 11 Jianwei Hou 2013-07-11 21:42:52 EDT
Mark as verified according to Comment 10
Comment 12 Hiro Asari 2013-07-12 10:58:48 EDT
I should note that Comment 4 is invalid now. Gem-installed scripts take precedence.

Note You need to log in before you can comment on or make changes to this bug.