Skip to content

Commit

Permalink
Issue vagrant-landrush#231 Adding embedded/bin directory of Vagrant t…
Browse files Browse the repository at this point in the history
…o PATH in case it exists to make sure there is at least one Ruby interpreter
  • Loading branch information
hferentschik committed Aug 1, 2016
1 parent a338300 commit 1be114f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/landrush/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def self.upstream

# Used to start the Landrush DNS server as a child process using ChildProcess gem
def self.start
ensure_ruby_on_path
if Vagrant::Util::Platform.windows?
# Need to handle Windows differently. Kernel.spawn fails to work, if the shell creating the process is closed.
# See /~https://github.com/vagrant-landrush/landrush/issues/199
Expand Down Expand Up @@ -266,8 +267,19 @@ def self.terminate_process(pid)
end
end

# On a machine with just Vagrant installed there might be no other Ruby except the
# one bundled with Vagrant. Let's make sure the embedded bin directory containing
# the Ruby executable is added to the PATH.
def self.ensure_ruby_on_path
vagrant_binary = Vagrant::Util::Which.which('vagrant')
vagrant_binary = File.realpath(vagrant_binary) if File.symlink?(vagrant_binary)
# in a Vagrant installation the Ruby executable is in ../embedded/bin relative to the vagrant executable
embedded_bin_dir = File.join(File.dirname(File.dirname(vagrant_binary)), 'embedded', 'bin')
ENV['PATH'] += File::PATH_SEPARATOR + embedded_bin_dir if File.exist?(embedded_bin_dir)
end

private_class_method :write_pid, :read_pid, :delete_pid_file, :pid_file, :process_status, :ensure_path_exits,
:terminate_process
:terminate_process, :ensure_ruby_on_path
end
end

Expand Down

0 comments on commit 1be114f

Please sign in to comment.