Linuxbrew-core: Cygwin

Created on 18 Aug 2017  Â·  24Comments  Â·  Source: Homebrew/linuxbrew-core

This is more an inquiry than an issue I guess.

Limited to using cygwin for dev tools in a windows environment. Came accross linuxbrew. Tried to run linuxbrew under cygwin. brew update results in alot of error messages about Uninitialized constants for MacOS. Am I wasting time by trying to get it to run under cygwin?

examples include:

Error: Invalid formula: /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/z3.rb
uninitialized constant Formulary::FormulaNamespace98065879044ad60940d7323e233bb47f::Z3::MacOS
Error: Invalid formula: /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/zimg.rb
uninitialized constant MinimumMacOSRequirement::MacOS
Error: Invalid formula: /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/znapzend.rb
uninitialized constant #<Class:0x000006052f2e10>::MacOS
Error: Invalid formula: /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/zorba.rb
uninitialized constant MinimumMacOSRequirement::MacOS
Error: Invalid formula: /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/zurl.rb
uninitialized constant Formulary::FormulaNamespace4f99bdcb6a60c6907d599fa065afdf70::Zurl::MacOS
Error: Cannot tap homebrew/core: invalid syntax in tap!
Error: Failure while executing: /home/linuxbrew/.linuxbrew/bin/brew tap homebrew/core
Failed during: /home/linuxbrew/.linuxbrew/bin/brew update --force
outdated question

Most helpful comment

Create a symlink $(brew --prefix)/lib/ld.so:

ln -s /bin/false $(brew --prefix)/lib/ld.so

A code fix would be something like:

diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb
index 245cee3c7..80962db72 100644
--- a/Library/Homebrew/cmd/install.rb
+++ b/Library/Homebrew/cmd/install.rb
@@ -316,6 +316,7 @@ module Homebrew

   # Symlink the dynamic linker, ld.so
   def symlink_ld_so
+    return if ENV["HOMEBREW_SYSTEM"] == "Cygwin"
     ld_so = HOMEBREW_PREFIX/"lib/ld.so"
     return if ld_so.readable?
     sys_interpreter = ["/lib64/ld-linux-x86-64.so.2", "/lib/ld-linux.so.3", "/lib/ld-linux.so.2", "/lib/ld-linux-armhf.so.3"].find do |s|

Check the case "Cygwin". It may be "cygwin".

All 24 comments

Please enclose copy-and-paste blocks in triple back ticks.
See https://help.github.com/articles/basic-writing-and-formatting-syntax/#quoting-code

Linuxbrew is known to work on Windows Subsystem for Linux, also known as Bash on Ubuntu on Windows. You can try that if that's an option for you.

As far as I know no one has yet run Linuxbrew on Cygwin. In principle it should work with a couple of fixes. The first is that it's not detecting that you're running on "Linux" (or a Linux emulation system). Modify OS.linux? to return true, and everything may start working. There'll probably be a few more surprises.

  def self.linux?
    return false if ENV["HOMEBREW_TEST_GENERIC_OS"]
    RbConfig::CONFIG["host_os"].include? "linux"
  end

https://github.com/Linuxbrew/brew/blob/master/Library/Homebrew/os.rb#L9-12

Can you please also report the value of…

brew irb <<<'RbConfig::CONFIG["host_os"]'

I'd strongly recommend Windows Subsystem for Linux if that's an option for you. With Cygwin you'll have to compile everything from source. With WSL you can use the precompiled binary packages called bottles.

All the formulae we use work fine on Windows Subsystem for Linux. Therefore I second the advise to use it, if possible.

Modified os.rb to return true for linux.

if I run brew update --force (as it overwrites os.rb)

returns MacOS is still an undefined constant.

Modifying os.rb and running "brew install hello" attempts to update, overwriting os.rb

Also ran the requested IRB command:

$  /home/linuxbrew/.linuxbrew/bin/brew irb <<<'RbConfig::CONFIG["host_os"]'

==> Interactive Homebrew Shell
Example commands available with: brew irb --examples
Switch to inspect mode.
RbConfig::CONFIG["host_os"]
"cygwin"

I'd love to use Bash, but work has only approved cygwin. I will understand if it's more hassle than it's worth to discuss cygwin issues.

disabling Autoupdate and trying again.

You can also git commit your change to os.rb to prevent it from being overwritten.

diff --git a/Library/Homebrew/os.rb b/Library/Homebrew/os.rb
index 7acee9993..59164c053 100644
--- a/Library/Homebrew/os.rb
+++ b/Library/Homebrew/os.rb
@@ -8,7 +8,8 @@ module OS

   def self.linux?
     return false if ENV["HOMEBREW_TEST_GENERIC_OS"]
-    RbConfig::CONFIG["host_os"].include? "linux"
+    host_os = RbConfig::CONFIG["host_os"]
+    host_os.include?("linux") || host_os == "cygwin"
   end

   ::OS_VERSION = ENV["HOMEBREW_OS_VERSION"]

Hmm, I may have hit an untenable issue. the above gets brew to run. Any brew command now errors about glibc (Because glibc isn't part of cygwin, It uses newlib instead).

$ brew config
HOMEBREW_VERSION: 1.2.6-dirty
ORIGIN: https://github.com/Linuxbrew/brew
HEAD: 20bcce2c176469cec271b46d523eef1510217436
Last commit: 3 weeks ago
Core tap: N/A
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_REPOSITORY: /home/linuxbrew/.linuxbrew/Homebrew
HOMEBREW_CELLAR: /home/linuxbrew/.linuxbrew/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://linuxbrew.bintray.com
CPU: octa-core 64-bit skylake
Homebrew Ruby: 2.3.3 => /usr/bin/ruby.exe
Clang: N/A
Git: 2.14.1 => /bin/git
Perl: /bin/perl
Error: Invalid formula: /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebre                                                                               w/homebrew-core/Formula/gcc.rb
Unable to locate the system's glibc
Error: Invalid formula: /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebre                                                                               w/homebrew-core/Formula/llvm.rb
Unable to locate the system's glibc
Error: Cannot tap homebrew/core: invalid syntax in tap!
Error: Failure while executing: /home/linuxbrew/.linuxbrew/bin/brew tap homebrew                                                                               /core -q


As a hack, try…

diff --git a/Library/Homebrew/requirements/glibc_requirement.rb b/Library/Homebrew/requirements/glibc_requirement.rb
index e52bf2315..7070fecf0 100644
--- a/Library/Homebrew/requirements/glibc_requirement.rb
+++ b/Library/Homebrew/requirements/glibc_requirement.rb
@@ -6,6 +6,7 @@ class GlibcRequirement < Requirement
   @system_version = nil

   def self.system_version
+    @system_version = "2.19"
     return @system_version if @system_version
     libc = ["/lib/x86_64-linux-gnu/libc.so.6", "/lib64/libc.so.6", "/usr/lib64/libc.so.6", "/lib/libc.so.6", "/usr/lib/libc.so.6", "/lib/i386-linux-gnu/libc.so.6", "/lib/arm-linux-gnueabihf/libc.so.6"].find do |s|
       Pathname.new(s).executable?

That gets rid of the glibc error in brew commands:

$ brew config
HOMEBREW_VERSION: 1.2.6-dirty
ORIGIN: https://github.com/Linuxbrew/brew
HEAD: 20bcce2c176469cec271b46d523eef1510217436
Last commit: 4 weeks ago
Core tap: N/A
HOMEBREW_PREFIX: /home/linuxbrew/.linuxbrew
HOMEBREW_REPOSITORY: /home/linuxbrew/.linuxbrew/Homebrew
HOMEBREW_CELLAR: /home/linuxbrew/.linuxbrew/Cellar
HOMEBREW_BOTTLE_DOMAIN: https://linuxbrew.bintray.com
CPU: octa-core 64-bit skylake
Homebrew Ruby: 2.3.3 => /usr/bin/ruby.exe
Clang: N/A
Git: 2.14.1 => /bin/git
Perl: /bin/perl
Python: /bin/python => /bin/python2.7.exe
Ruby: /bin/ruby => /usr/bin/ruby.exe
Java: 1.8.0_131
Kernel: CYGWIN_NT-10.0 2.8.2(0.313/5/3) x86_64 Cygwin
OS: N/A
Host glibc: 2.19
/usr/bin/gcc: 5.4.0
glibc: N/A
gcc: N/A
xorg: N/A

Brew install now reports it's unable to locate system's ld.so


$ brew install hello
Error: Unable to locate the system's ld.so

Sorry, that should have been @system_version = "2.23" or even @system_version = "2.99". We're upgrading glibc today from 2.19 to 2.23.

Create a symlink $(brew --prefix)/lib/ld.so:

ln -s /bin/false $(brew --prefix)/lib/ld.so

A code fix would be something like:

diff --git a/Library/Homebrew/cmd/install.rb b/Library/Homebrew/cmd/install.rb
index 245cee3c7..80962db72 100644
--- a/Library/Homebrew/cmd/install.rb
+++ b/Library/Homebrew/cmd/install.rb
@@ -316,6 +316,7 @@ module Homebrew

   # Symlink the dynamic linker, ld.so
   def symlink_ld_so
+    return if ENV["HOMEBREW_SYSTEM"] == "Cygwin"
     ld_so = HOMEBREW_PREFIX/"lib/ld.so"
     return if ld_so.readable?
     sys_interpreter = ["/lib64/ld-linux-x86-64.so.2", "/lib/ld-linux.so.3", "/lib/ld-linux.so.2", "/lib/ld-linux-armhf.so.3"].find do |s|

Check the case "Cygwin". It may be "cygwin".

Added the symlink, Suspicious failure occurs in brew install hello:

$ brew install hello
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb:203:in `dump': instance of IO needed (TypeError)
        from /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb:203:in `rescue in <main>'
        from /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb:192:in `<main>'
Error: Suspicious failure

Try this patch to give you a more informative error message

diff --git a/Library/Homebrew/utils/fork.rb b/Library/Homebrew/utils/fork.rb
index 92f5bf899..3ccc2cdb1 100644
--- a/Library/Homebrew/utils/fork.rb
+++ b/Library/Homebrew/utils/fork.rb
@@ -38,7 +38,7 @@ module Utils
           Process.wait(pid) unless socket.nil?
           raise Marshal.load(data) unless data.nil? || data.empty?
           raise Interrupt if $CHILD_STATUS.exitstatus == 130
-          raise "Suspicious failure" unless $CHILD_STATUS.success?
+          raise "Suspicious failure: #{CHILD_STATUS}" unless $CHILD_STATUS.success?
         end
       end
     end

Made the change, results in:

$ brew install hello
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb:203:in `dump': instance of IO needed (TypeError)
        from /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb:203:in `rescue in <main>'
        from /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb:192:in `<main>'
Error: uninitialized constant Utils::CHILD_STATUS
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/utils/fork.rb:41:in `block (3 levels) in safe_fork'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/utils.rb:397:in `ignore_interrupts'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/utils/fork.rb:26:in `block (2 levels) in safe_fork'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/utils/fork.rb:7:in `open'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/utils/fork.rb:7:in `block in safe_fork'
/usr/share/ruby/2.3.0/tmpdir.rb:89:in `mktmpdir'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/utils/fork.rb:6:in `safe_fork'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula_installer.rb:714:in `build'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula_installer.rb:309:in `install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:376:in `install_formula'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:226:in `block in install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:224:in `each'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:224:in `install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb:95:in `<main>'

Sorry, I had a typo. It should have been
Try this patch to give you a more informative error message

diff --git a/Library/Homebrew/utils/fork.rb b/Library/Homebrew/utils/fork.rb
index 92f5bf899..3ccc2cdb1 100644
--- a/Library/Homebrew/utils/fork.rb
+++ b/Library/Homebrew/utils/fork.rb
@@ -38,7 +38,7 @@ module Utils
           Process.wait(pid) unless socket.nil?
           raise Marshal.load(data) unless data.nil? || data.empty?
           raise Interrupt if $CHILD_STATUS.exitstatus == 130
-          raise "Suspicious failure" unless $CHILD_STATUS.success?
+          raise "Suspicious failure: #{$CHILD_STATUS}" unless $CHILD_STATUS.success?
         end
       end
     end

Revised Changes:


$ brew install hello
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb:203:in `dump': instance of IO needed (TypeError)
        from /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb:203:in `rescue in <main>'
        from /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/build.rb:192:in `<main>'
Error: Suspicious failure: pid 14256 exit 1


fork is failing, and fork is tricky on Cygwin.
https://www.cygwin.com/faq.html#faq.using.fixing-fork-failures
https://www.cygwin.com/faq.html#faq.api.fork

How did you install ruby?

Homebrew Ruby: 2.3.3 => /usr/bin/ruby.exe

We've run into an issue here that may be tricky to troubleshoot and debug. I think we've hit the end of the line. If you're able to resolve this issue, we'd welcome a PR to bring Linuxbrew to Cygwin.

Ruby was installed from the cygwin packages. I'll poke around and see if I can find a solution. I appreciate the help regardless.

No worries. I'm going to close this issue, but feel free to continue commenting if you learn anything.

@sjackman anychance you could chime in here ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

slhck picture slhck  Â·  7Comments

half2me picture half2me  Â·  7Comments

iMichka picture iMichka  Â·  6Comments

julian45 picture julian45  Â·  7Comments

oliver-la picture oliver-la  Â·  7Comments