brew update and can still reproduce the problem? n/abrew doctor, fixed all issues and can still reproduce the problem? n/abrew config and brew doctor and included their output with your issue? n/aIn the install block of my formula, I was trying to pass environment variables like so:
def install
system({ "FOO" => "bar" }, "env")
end
## What happened (include command output)
A Ruby exception
Error: An exception occurred within a child process: TypeError: no implicit conversion of Hash into String
HOMEBREW_VERSION: 2.4.16-144-g2314ddf ORIGIN: https://github.com/Homebrew/brew HEAD: 2314ddf9f5475b63d5e37d398d0a5990e0311afd Last commit: 4 days ago Core tap ORIGIN: https://github.com/Homebrew/homebrew-core Core tap HEAD: 40d76cc32fa516569e82cb8907c9ec382fb38cf1 Core tap last commit: 16 minutes ago Core tap branch: update-gh.rb-1599554327 HOMEBREW_PREFIX: /usr/local HOMEBREW_CASK_OPTS: [] HOMEBREW_EDITOR: vim HOMEBREW_MAKE_JOBS: 16 HOMEBREW_NO_AUTO_UPDATE: set HOMEBREW_NO_INSTALL_CLEANUP: set CPU: 16-core 64-bit kabylake Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby Clang: 11.0 build 1103 Git: 2.28.0 => /usr/local/bin/git Curl: 7.64.1 => /usr/bin/curl Java: 1.8.0_232-zulu-8.42.0.23 macOS: 10.15.6-x86_64 CLT: 1103.0.32.62 Xcode: 11.7 Please note that these warnings are just used to help the Homebrew maintainers with debugging if you file an issue. If everything you use Homebrew for is working fine: please don't worry or file an issue; just ignore this. Thanks! Warning: Homebrew/homebrew-core is not on the master branch. Check out the master branch by running: git -C "$(brew --repo homebrew/core)" checkout master Warning: Some installed formulae are deprecated or disabled. You should find replacements for the following formulae: [email protected] [email protected] Warning: You have unlinked kegs in your Cellar. Leaving kegs unlinked can lead to build-trouble and cause brews that depend on those kegs to fail to run properly once built. Run `brew link` on these: docker Warning: You have uncommitted modifications to Homebrew/brew. If this is a surprise to you, then you should stash these modifications. Stashing returns Homebrew to a pristine state but can be undone should you later need to do so for some reason. cd /usr/local/Homebrew && git stash && git clean -d -f Uncommitted files: ?? Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/patchelf-1.1.1/lib/patchelf.rb ?? Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/patchelf-1.1.1/lib/patchelf/cli.rb ?? Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/patchelf-1.1.1/lib/patchelf/exceptions.rb ?? Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/patchelf-1.1.1/lib/patchelf/helper.rb ?? Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/patchelf-1.1.1/lib/patchelf/logger.rb ?? Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/patchelf-1.1.1/lib/patchelf/mm.rb ?? Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/patchelf-1.1.1/lib/patchelf/patcher.rb ?? Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/patchelf-1.1.1/lib/patchelf/saver.rb ?? Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/patchelf-1.1.1/lib/patchelf/version.rb You have uncommitted modifications to Homebrew/homebrew-core. If this is a surprise to you, then you should stash these modifications. Stashing returns Homebrew to a pristine state but can be undone should you later need to do so for some reason. cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core && git stash && git clean -d -f Uncommitted files: M Formula/gh.rb ?? steps_output.txt Warning: Homebrew's sbin was not found in your PATH but you have installed formulae that put executables in /usr/local/sbin. Consider setting the PATH for example like so: echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.zshrc
While we have a think about this in the mean time our DSL for this is:
with_env(FOO: "bar") do
system "env"
end
or simply:
ENV["FOO"] = "bar"
system "env"
@MikeMcQuaid Thanks the the fast response and the workarounds! I did not know about with_env. I would prefer that since ENV["FOO"] = "..." can inadvertently affect subsequent processes.
Might all this warrant a mention in https://docs.brew.sh/Formula-Cookbook? I did not find instructions to set environment variables anywhere.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.