@@ -110,28 +110,47 @@ def git_windows_bin_dir
110110 @git_windows_bin_dir ||= File . expand_path ( File . join ( omnibus_root , "embedded" , "git" , "usr" , "bin" ) )
111111 end
112112
113+ # #
114+ # # environment vars for habitat
115+ # #
116+ # def habitat_env
117+ # @habitat_env ||=
118+ # begin
119+ # # Define the necessary paths for the Habitat environment
120+ # # Custom GEM_HOME within Habitat
121+ # pkg_prefix = get_pkg_prefix
122+ # vendor_dir = File.join(pkg_prefix, "vendor")
123+ # path = [
124+ # File.join(pkg_prefix, "bin"),
125+ # ENV["PATH"].split(File::PATH_SEPARATOR), # Preserve existing PATH
126+ # ].flatten.uniq
127+
128+ # {
129+ # "PATH" => path.join(File::PATH_SEPARATOR),
130+ # "GEM_ROOT" => Gem.default_dir, # Default directory for gems
131+ # "GEM_HOME" => vendor_dir, # GEM_HOME pointing to the vendor directory
132+ # "GEM_PATH" => vendor_dir, # GEM_PATH also pointing to the vendor directory
133+ # }
134+ # end
135+ # end
136+
113137 #
114- # environment vars for habitat
138+ # environment vars for omnibus
115139 #
116- def habitat_env
117- @habitat_env ||=
118- begin
119- # Define the necessary paths for the Habitat environment
120- # Custom GEM_HOME within Habitat
121- pkg_prefix = get_pkg_prefix
122- vendor_dir = File . join ( pkg_prefix , "vendor" )
123- path = [
124- File . join ( pkg_prefix , "bin" ) ,
125- ENV [ "PATH" ] . split ( File ::PATH_SEPARATOR ) , # Preserve existing PATH
126- ] . flatten . uniq
127-
128- {
129- "PATH" => path . join ( File ::PATH_SEPARATOR ) ,
130- "GEM_ROOT" => Gem . default_dir , # Default directory for gems
131- "GEM_HOME" => vendor_dir , # GEM_HOME pointing to the vendor directory
132- "GEM_PATH" => vendor_dir , # GEM_PATH also pointing to the vendor directory
133- }
134- end
140+ def omnibus_env
141+ @omnibus_env ||=
142+ begin
143+ user_bin_dir = File . expand_path ( File . join ( Gem . user_dir , "bin" ) )
144+ path = [ omnibus_bin_dir , user_bin_dir , omnibus_embedded_bin_dir , ENV [ "PATH" ] . split ( File ::PATH_SEPARATOR ) ]
145+ path << git_bin_dir if Dir . exist? ( git_bin_dir )
146+ path << git_windows_bin_dir if Dir . exist? ( git_windows_bin_dir )
147+ {
148+ "PATH" => path . flatten . uniq . join ( File ::PATH_SEPARATOR ) ,
149+ "GEM_ROOT" => Gem . default_dir ,
150+ "GEM_HOME" => Gem . user_dir ,
151+ "GEM_PATH" => Gem . path . join ( File ::PATH_SEPARATOR ) ,
152+ }
153+ end
135154 end
136155
137156 def get_pkg_prefix
0 commit comments