Gems,ruby and ldaps

I need to use net-ldap, but a recent version requires ruby 2.0, i used
gem install rails 4.2.4 and had some success for a while

gem -v
2.4.8

gem list
addressable (2.5.1, 2.4.0)
amazon-ec2 (0.9.17)
aws-sdk (2.9.43, 2.5.10)
aws-sdk-core (2.9.43, 2.5.10)
aws-sdk-resources (2.9.43, 2.5.10)
aws-sigv4 (1.0.0)
azure (0.7.9, 0.7.6)
azure-core (0.1.8, 0.1.4)
bigdecimal (1.3.2, 1.2.6)
builder (3.2.3, 3.2.2)
bundler (1.15.1)
bundler-unload (1.0.2)
configparser (0.1.6, 0.1.4)
curb (0.9.3)
daemons (1.2.4)
defaults (1.0.1)
eventmachine (1.2.3, 1.2.0.1)
executable-hooks (1.3.2)
faraday (0.12.1, 0.9.2)
faraday_middleware (0.11.0.1, 0.10.0)
gem-wrappers (1.2.7)
hashie (3.5.5, 3.4.4)
inflection (1.0.0)
io-console (0.4.6, 0.4.3)
jmespath (1.3.1)
json (2.1.0, 1.8.3, 1.8.1)
memcache-client (1.8.5)
mime-types (3.1, 2.99.2)
mime-types-data (3.2016.0521)
mini_portile2 (2.2.0, 2.1.0)
minitest (5.10.2, 5.4.3)
multipart-post (2.0.0)
mustermann (1.0.0)
mysql (2.9.1)
net-ldap (0.16.0, 0.12.1)
nokogiri (1.8.0, 1.6.8)
ox (2.5.0, 2.4.4)
parse-cron (0.1.4)
pkg-config (1.2.3, 1.1.7)
polyglot (0.3.5)
power_assert (1.0.2, 0.2.2)
psych (2.2.4, 2.0.8)
public_suffix (2.0.5)
rack (2.0.3, 1.6.4)
rack-protection (2.0.0, 1.5.3)
rake (12.0.0, 10.4.2)
rdoc (5.1.0, 4.2.0)
rubygems-bundler (1.4.4)
rubygems-update (2.6.12)
rvm (1.11.3.9)
scrub_rb (1.0.1)
sequel (4.47.0, 4.38.0)
sinatra (2.0.0, 1.4.7)
sqlite3 (1.3.13, 1.3.11)
systemu (2.6.5)
test-unit (3.2.4, 3.0.8)
thin (1.7.1, 1.7.0)
thor (0.19.4, 0.19.1)
tilt (2.0.7, 2.0.5)
to_yaml (0.3.0)
treetop (1.6.8)
trollop (2.1.2)
uuidtools (2.1.5)
xml-simple (1.1.5)
zendesk_api (1.14.4, 1.13.4)

running
ruby -Swd /var/lib/one/remotes/auth/ldap/authenticate user - pass

Exception `LoadError' at /usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems.rb:1222 - cannot load such file -- rubygems/defaults/operating_system
Exception `LoadError' at /usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems.rb:1231 - cannot load such file -- rubygems/defaults/ruby
/var/lib/one/remotes/auth/ldap/authenticate:42: warning: assigned but unused variable - pass
Exception `NameError' at /usr/local/rvm/gems/ruby-2.2.2/gems/psych-2.2.4/lib/psych/class_loader.rb:68 - uninitialized constant BigDecimal
Exception `NameError' at /usr/local/rvm/gems/ruby-2.2.2/gems/psych-2.2.4/lib/psych/class_loader.rb:68 - uninitialized constant Date
Exception `NameError' at /usr/local/rvm/gems/ruby-2.2.2/gems/psych-2.2.4/lib/psych/class_loader.rb:68 - uninitialized constant DateTime
Exception `NameError' at /usr/local/rvm/gems/ruby-2.2.2/gems/psych-2.2.4/lib/psych/core_ext.rb:17 - method `to_yaml' not defined in Object
Exception `NameError' at /usr/local/rvm/gems/ruby-2.2.2/gems/psych-2.2.4/lib/psych/core_ext.rb:30 - method `yaml_as' not defined in Module
Exception `NameError' at /usr/local/rvm/gems/ruby-2.2.2/gems/psych-2.2.4/lib/psych/deprecated.rb:82 - undefined method `to_yaml_properties' for class `Object'
/usr/lib/one/ruby/opennebula/xml_utils.rb:94: warning: `-' after local variable or literal is interpreted as binary operator
/usr/lib/one/ruby/opennebula/xml_utils.rb:94: warning: even though it seems like unary operator
/usr/lib/one/ruby/opennebula/xml_pool.rb:25: warning: method redefined; discarding old initialize
/usr/lib/one/ruby/opennebula/xml_element.rb:411: warning: previous definition of initialize was here
/usr/lib/one/ruby/opennebula/xml_pool.rb:31: warning: method redefined; discarding old each_element
/usr/lib/one/ruby/opennebula/xml_element.rb:417: warning: previous definition of each_element was here
Exception `LoadError' at /usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54 - cannot load such file -- nokogiri
Exception `LoadError' at /usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54 - cannot load such file -- nokogiri/2.2/nokogiri
Exception `LoadError' at /usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:133 - cannot load such file -- nokogiri/2.2/nokogiri
Exception `LoadError' at /usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54 - cannot load such file -- ox
Exception `LoadError' at /usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54 - cannot load such file -- xmlparser
Exception `LoadError' at /usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:133 - cannot load such file -- xmlparser
/usr/lib/one/ruby/opennebula/virtual_machine_pool.rb:297: warning: assigned but unused variable - acct_hash
/usr/lib/one/ruby/opennebula/host.rb:136: warning: ambiguous first argument; put parentheses or a space even after `-' operator
/usr/lib/one/ruby/opennebula/vdc.rb:176: warning: method redefined; discarding old add_host
/usr/lib/one/ruby/opennebula/vdc.rb:164: warning: previous definition of add_host was here
/usr/lib/one/ruby/opennebula/vdc.rb:192: warning: method redefined; discarding old del_host
/usr/lib/one/ruby/opennebula/vdc.rb:186: warning: previous definition of del_host was here
Exception `LoadError' at /usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54 - cannot load such file -- net/ldap
/usr/local/rvm/gems/ruby-2.2.2/gems/net-ldap-0.16.0/lib/net/ldap/password.rb:22: warning: assigned but unused variable - attribute_value
/usr/local/rvm/gems/ruby-2.2.2/gems/net-ldap-0.16.0/lib/net/ldap/instrumentation.rb:15: warning: shadowing outer local variable - payload
/usr/local/rvm/gems/ruby-2.2.2/gems/net-ldap-0.16.0/lib/net/ldap/connection.rb:303: warning: assigned but unused variable - sort_control
Trying server server 1
/usr/lib/one/ruby/opennebula/ldap_auth.rb:79: warning: File.exists? is a deprecated name, use File.exist? instead
/usr/lib/one/ruby/opennebula/ldap_auth.rb:114: warning: File.exists? is a deprecated name, use File.exist? instead
Exception `IO::EINPROGRESSWaitWritable' at /usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/socket.rb:54 - Operation now in progress - connect(2) would block
Exception `IO::EINPROGRESSWaitWritable' at /usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/socket.rb:54 - Operation now in progress - connect(2) would block
Exception `IO::EINPROGRESSWaitWritable' at /usr/local/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/socket.rb:54 - Operation now in progress - connect(2) would block
User username not found
Could not authenticate user username

The errors suggest mix-match of ruby versions that are expected and missing gems.

I am trying ldap/ldaps which I have gotten to work before. I had an issue with a self-signed cert and recent changes to ruby net-ldap. At this point, running

/usr/share/one/install_gems is not allowed as oneamdin, because of non-root. So i ran as root and now now all other gems are broken since install_gems uses ruby 1.9.1.

What is a sustainable way to use updated gems with OpenNeb 5.2?

The script install_gems from packages come with gem versions locked and should not give those problems. Are you installing from sources?

If that is the case copy the file Gemfile.lock from a distro with ruby 1.9.1 to /usr/share/one and run install_gems. Make sure that you remove the incompatible versions before.

The Ubuntu 14.04 file should be OK:

If the problem is that you have two ruby versions installed at the same time make sure that only one is executed with both root and oneadmin.

Thanks Javi,

After reverting to a version of OpenNebula without the different versions of gems, I used the install_gems script but was unable to fix the ldap problem until running a recent update. It’s weird because it seems a ruby dependency within net-ldap was updated yet net-ldap is still on 0.12.1 on OpenNebula. Works now so thanks again.