Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

set $MANPATH in Bundler::Runtime#setup_environment #1624

Merged
merged 1 commit into from

3 participants

@sunaku

This lets bundle exec man ... show man pages from bundled gems.

@indirect
Owner

Thanks for the patch! Can you please also remove the changes to MANPATH in the Bundler.with_clean_env and with_original_env methods?

@sunaku

I didn't find anything to do: with_original_env already replaces the current (possibly modified) ENV with ORIGINAL_ENV so that takes care of any MANPATH changes we made.

Also, I had to move the code out to a separate setup_manpath method because $LOAD_PATH is not already set up when setup_environment is called.

Can we move the setup_environment call below the spec activation code?

@indirect
Owner
@sunaku
@sunaku

I updated the patch to support with_clean_env and replaced the Dir.exist? test with a smarter one.

@sunaku sunaku set $MANPATH in Bundler::Runtime#setup_environment
This lets `bundle exec man ...` show man pages from bundled gems.
297c795
@travisbot

This pull request fails (merged 297c795 into 7f7f7c0).

@indirect indirect merged commit 297c795 into bundler:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 13, 2012
  1. @sunaku

    set $MANPATH in Bundler::Runtime#setup_environment

    sunaku authored
    This lets `bundle exec man ...` show man pages from bundled gems.
This page is out of date. Refresh to see the latest.
Showing with 20 additions and 0 deletions.
  1. +1 −0  lib/bundler.rb
  2. +19 −0 lib/bundler/runtime.rb
View
1  lib/bundler.rb
@@ -194,6 +194,7 @@ def with_original_env
def with_clean_env
with_original_env do
+ ENV['MANPATH'] = ENV['BUNDLE_ORIG_MANPATH']
ENV.delete_if { |k,_| k[0,7] == 'BUNDLE_' }
yield
end
View
19 lib/bundler/runtime.rb
@@ -36,6 +36,8 @@ def setup(*groups)
$LOAD_PATH.unshift(*load_paths)
end
+ setup_manpath
+
lock
self
@@ -226,6 +228,23 @@ def setup_environment
private
+ def setup_manpath
+ # Store original MANPATH for restoration later in with_clean_env()
+ ENV['BUNDLE_ORIG_MANPATH'] = ENV['MANPATH']
+
+ # Add man/ subdirectories from activated bundles to MANPATH for man(1)
+ manuals = $LOAD_PATH.map do |path|
+ man_subdir = path.sub(/lib$/, 'man')
+ man_subdir unless Dir[man_subdir + '/man?/'].empty?
+ end.compact
+
+ unless manuals.empty?
+ ENV['MANPATH'] = manuals.concat(
+ ENV['MANPATH'].to_s.split(File::PATH_SEPARATOR)
+ ).uniq.join(File::PATH_SEPARATOR)
+ end
+ end
+
def cache_path
root.join("vendor/cache")
end
Something went wrong with that request. Please try again.