So I discovered one way to achieve this (though probably not optimal at all 
...) using LoadError so that if the dated vagrant gem is uninstalled, the 
Rakefile will add the [deb,rpm] package paths and attempt again.

Comments/Alternate suggestions more than welcome ...


+
 require 'rbconfig'
 require 'rubygems'
-require 'vagrant'
+begin
+  require 'vagrant'
+rescue LoadError
+  VAGRANT_PKG_REQ_PREFIX = "*/opt/vagrant/embedded/gems/gems/*"
+  puts "vagrant library require files from gem not found, attempting
vagrant [deb,rpm] package require paths under #{VAGRANT_PKG_REQ_PREFIX}"
+  Dir.glob("#{VAGRANT_PKG_REQ_PREFIX}*/lib").each do |pkg_req_dir|
+    $LOAD_PATH.unshift File.expand_path("#{pkg_req_dir}", __FILE__)
+  end
+  # attempt to load vagrant library again, this time failing by terminating
+  require 'vagrant'
+end
 require 'uri'



On Sunday, July 19, 2015 at 11:00:31 AM UTC+2, Adam Burns wrote:
>
>
> I finally got the TAILS Rakefile to call Vagrant 1.7.3 (installed from 
> RPM) with the following (ugly) diffs:
>
> +$LOAD_PATH.unshift 
> File.expand_path('/opt/vagrant/embedded/gems/gems/vagrant-1.7.3/lib/', 
> __FILE__)
> +$LOAD_PATH.unshift 
> File.expand_path('/opt/vagrant/embedded/gems/gems/hashicorp-checkpoint-0.1.4/lib',
>  
> __FILE__)
> +$LOAD_PATH.unshift 
> File.expand_path('/opt/vagrant/embedded/gems/gems/log4r-1.1.10/lib', 
> __FILE__)
> +$LOAD_PATH.unshift 
> File.expand_path('/opt/vagrant/embedded/gems/gems/childprocess-0.5.5/lib', 
> __FILE__)
> +$LOAD_PATH.unshift 
> File.expand_path('/opt/vagrant/embedded/gems/gems/erubis-2.7.0/lib', 
> __FILE__)
>
>
> Could someone help a ruby/rake n00b with the proper way to add a recursive 
> search path  for require?
>
> Many Thanks!
>

-- 
This mailing list is governed under the HashiCorp Community Guidelines - 
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of 
those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
--- 
You received this message because you are subscribed to the Google Groups 
"Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vagrant-up/0481a60d-18a3-431b-bafe-8fdc142ef40b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to