Bug 1379679

Summary: Not able to build a rubygem RPM with additional SCL package
Product: Red Hat Software Collections Reporter: Satoe Imaishi <simaishi>
Component: rubyAssignee: ruby maint <ruby-maint>
Status: CLOSED NOTABUG QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rh-ruby23CC: jorton, slukasik, vondruch
Target Milestone: alpha   
Target Release: 2.2   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-10-03 10:15:52 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 1378545    
Attachments:
Description Flags
Brew build log none

Description Satoe Imaishi 2016-09-27 12:30:55 UTC
Created attachment 1205175 [details]
Brew build log

Description of problem:

  Not able to build a rubygem RPM with another SCL package


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

  rh-ruby23


Steps to Reproduce:

In %build section of RPM spec file, enable 2 SCL packages and run a build

%{?scl:scl enable %{scl} rh-postgresql95 - << \EOF}
%gem_install
%{?scl:EOF}


Actual results:

The build fails with the following error:

/opt/rh/rh-ruby23/root/usr/share/rubygems/rubygems/defaults/operating_system.rb:123:in `default_dir': undefined method `[]' for nil:NilClass (NoMethodError)


Additional info:

Tried swapping the order of %{scl} and rh-postgresql95, as well as splitting to 2 'scl enable' lines but neither worked.

Enabling an additional SCL package worked with rh-ruby22.

.spec file to reproduce this issue: http://pkgs.devel.redhat.com/cgit/rpms/rubygem-pg/tree/rubygem-pg.spec?h=cfme-rh-ruby23-5.7-rhel-7&id=128d2dec737c257ca369d587df38733213fdd789

Brew scratch build: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=11812821

Comment 1 Joe Orton 2016-09-28 08:35:08 UTC
I don't understand why the default_dir logic is failing in operating_system.rb (will leave that to Vit & Pavel), but you could work around that by over-riding X_SCLS:

%{?scl:scl enable %{scl} rh-postgresql95 - << \EOF}
X_SCLS="rh-ruby23"
%gem_install
%{?scl:EOF}

AFAICT this shouldn't make any difference to the build.

Comment 2 Satoe Imaishi 2016-09-28 14:23:14 UTC
Thank you for the workaround, verified it builds fine with X_SCLS.

Comment 3 Vít Ondruch 2016-09-29 11:40:37 UTC
(In reply to Joe Orton from comment #1)
> X_SCLS="rh-ruby23"

This is definitely not the right solution, since it installs the gem files into rh-ruby23 directory structure.

What is the collection you are working on? Is it the "cfme" collection and is this [1] the metapackage?

I am asking, since the error is actually in your collection metapackage. It does not set GEM_PATH env variable, as is suggested by the guidelines [2].

But this metapackage is complete rubbish I must say (no offense). It does not even contain the 'enable' scriptlet nor other stuff we commonly provide in meta package, such as -build, -runtime and -scldevel subpackages.

Please take look at rh-ror42 metapackage [3], which is metapackage of collection building atop of rh-ruby23.


[1] http://pkgs.devel.redhat.com/cgit/rpms/cfme/tree/cfme.spec?h=cfme-rh-ruby23-5.7-rhel-7
[2] https://access.redhat.com/documentation/en-US/Red_Hat_Software_Collections/2/html/Packaging_Guide/sect-Extending_the_rh-ruby22_Software_Collections.html
[3] http://pkgs.devel.redhat.com/cgit/rpms/rh-ror42/tree/rh-ror42.spec?h=rhscl-2.3-rh-ror42-rhel-7

Comment 4 Satoe Imaishi 2016-09-29 13:17:12 UTC
No, it's not 'cfme', but it's 'rubygem-pg' [1].

This itself isn't a new collection, but just a rubygem RPM that goes with rh-ruby23.  So I don't think we need to build all those subpackages described in the guideline. But I will go over the document.  Thank you for the reference.

I've added "X_SCLS=%{scl}" in the spec file (rather than hard-coding rh-ruby23). I see rh-ror42 is setting it the same way, so at least that part is good, I hope.

[1] http://pkgs.devel.redhat.com/cgit/rpms/rubygem-pg/tree/rubygem-pg.spec?h=cfme-rh-ruby23-5.7-rhel-7&id=ebbb088138aca7a3f03e589ec5c13da9f474f57c

Comment 5 Vít Ondruch 2016-10-03 10:15:52 UTC
(In reply to Satoe Imaishi from comment #4)
> No, it's not 'cfme', but it's 'rubygem-pg' [1].
> 
> This itself isn't a new collection, but just a rubygem RPM that goes with
> rh-ruby23.

I am sorry, but something like this is not supported. The only supported way how to extend the collection is described in the documentation I referred above.

> So I don't think we need to build all those subpackages
> described in the guideline. But I will go over the document.  Thank you for
> the reference.
> 
> I've added "X_SCLS=%{scl}" in the spec file (rather than hard-coding
> rh-ruby23).

You are not supposed to install anything into rh-ruby23 directory structure.

> I see rh-ror42 is setting it the same way, so at least that part
> is good, I hope.

rh-ror42 is doing so, because it is metapackage. That is completely different reason.


I am sorry, but I am closing this ticket, since you are not following guidelines and best practices.

Comment 6 Vít Ondruch 2016-10-03 10:43:06 UTC
Of course please don't hesitate to contact me if you need some help creating proper SCL extension, i.e. proper metapackage and rubygem-pg packages.