Skip to content

Struct::Passwd#gecos #1930

Merged
merged 5 commits into from Nov 20, 2012

3 participants

@hosiawak
Rubinius member

Repro (current master in 1.8.7 mode):

require 'etc'
a = Etc.getpwent
a.gecos

NoMethodError: undefined method `gecos' on an instance of Struct::Passwd.

@ileitch
Rubinius member
ileitch commented Oct 4, 2012

There are cross platform issues here. Etc is implement with FFI. @brixen @dbussink What's the recommended approach for dealing with this in Rubinius? Implement Etc in C?

@brixen
Rubinius member
brixen commented Oct 4, 2012

What are the issues? You can deal with platform issues in either rakelib/platform.rake or in lib/etc.rb.ffi.

@ileitch
Rubinius member
ileitch commented Oct 4, 2012

struct passwd differs. Mostly just extra members, though there are is one type difference MRI implements. I've not been able to find an example of detecting member presence with FFI (possible?). Conditionals on the platform are the recommended approach then?

@brixen
Rubinius member
brixen commented Oct 4, 2012

Look at rakelib/platform.rake. We also have detection code in configure if it is needed.

@hosiawak
Rubinius member

I've added a spec for Struct::Passwd and the #gecos field to Struct::Passwd (needed to run Chef on rbx). The extra platform dependent members that MRI implements (change, quota, age, class, comment, expire)

https://github.com/ruby/ruby/blob/trunk/ext/etc/etc.c

aren't in MRI's official docs http://www.ruby-doc.org/stdlib-1.9.3/libdoc/etc/rdoc/Etc.html#method-c-getpwent

and I couldn't figure out how to make the detection code in configure work with ffi either nor how to write a spec for them (the detection code is in configure, it passes compile flags to rubinius but how do you get to them in mspec in a way that's implementation independent ?)

@brixen brixen merged commit a27d1ff into rubinius:master Nov 20, 2012

1 check failed

Details default The Travis build failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.