Skip to content
This repository was archived by the owner on Jan 16, 2025. It is now read-only.

Stack overflow error #13012

Closed
sidnair opened this issue Jun 25, 2012 · 23 comments
Closed

Stack overflow error #13012

sidnair opened this issue Jun 25, 2012 · 23 comments

Comments

@sidnair
Copy link

sidnair commented Jun 25, 2012

brew at head doesn't work for me. I'm on a brand new OS X 10.7.3.

I installed successfully with the install_homebrew.rb script, but running any brew command fails.

Here's the trace:
$ brew
/usr/local/Library/Homebrew/utils.rb:385:in 'xctools_fucked?': stack level too deep (SystemStackError)
from /usr/local/Library/Homebrew/utils.rb:302:in 'locate'
from /usr/local/Library/Homebrew/utils.rb:339:in 'dev_tools_path'
from /usr/local/Library/Homebrew/utils.rb:313:in 'locate'
from /usr/local/Library/Homebrew/utils.rb:339:in 'dev_tools_path'
from /usr/local/Library/Homebrew/utils.rb:313:in 'locate'
from /usr/local/Library/Homebrew/utils.rb:339:in 'dev_tools_path'
from /usr/local/Library/Homebrew/utils.rb:313:in 'locate'
from /usr/local/Library/Homebrew/utils.rb:339:in 'dev_tools_path'
... 661 levels...
from /usr/local/Library/Homebrew/utils.rb:339:in 'dev_tools_path'
from /usr/local/Library/Homebrew/global.rb:96
from /usr/local/bin/brew:10:in 'require'
from /usr/local/bin/brew:10

It looks like this is caused by commit 3c52a30. locate and dev_tools_path call each other on the lines in the stack trace. I checked out brew at the commit before that and extracted it to /usr/local, and it worked.

@MikeMcQuaid
Copy link
Member

Paging @samueljohn.

@Sharpie
Copy link
Contributor

Sharpie commented Jun 25, 2012

Just for reference, which version of OS X and Ruby are you using? This works fine for me on 10.7.3 and ruby 1.8.7 so there may be another factor influencing this error.

@sidnair
Copy link
Author

sidnair commented Jun 25, 2012

That's weird...I'm on OS X 10.7.3 and ruby 1.8.7 as well.

ruby --v: ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0]

@jacknagel
Copy link
Contributor

I think that this code path is only hit if the CLT is not installed? Regardless, clearly these methods should not call each other.

@wronco
Copy link

wronco commented Jun 25, 2012

I experienced this same problem - after installing Xcode and letting it run its setup tasks, I no longer get the error. I agree with jacknagel above, though, it would probably be great if the methods did not call each other.

@jbajor
Copy link

jbajor commented Jun 25, 2012

Have you installed Command Line Tools? 'XCode' -> 'Preferences' -> 'Downloads'.

@sidnair
Copy link
Author

sidnair commented Jun 25, 2012

I had installed XCode, but hadn't touched it at all. So, command line tools weren't installed and the xcode-select path was /Development, which didn't exist, instead of /Applications/Xcode.app/Contents/Developer.

@samueljohn
Copy link
Contributor

O.o oh what have I done?
Will have a look tomorrow. Never have seen this in my tests.

@MikeMcQuaid
Copy link
Member

Very quick and dirty fix attempt but can someone who can still reproduce this try 0b2665a (updated) from #13021. Thanks!

@MikeMcQuaid
Copy link
Member

And if that sucks can you suggest a better solution? Otherwise we need to revert.

@jbajor
Copy link

jbajor commented Jun 25, 2012

I have had the same error. Installing "Command Line Tools" for XCode solved the problem (as I suggested an hour ago). You obviously cannot run tools like 'strip' or 'gcc' if they are not installed. Believe me, brew is working fine on 10.7.3/4.

mistydemeo added a commit that referenced this issue Jun 25, 2012
Under certain circumstances, MacOS.locate and MacOS.dev_tools_path would call
each other recursively. This was limited to systems with Xcode minus the CLT.
See #13012.
@mistydemeo
Copy link
Contributor

Hotfix pushed in 78b9e85.

Can someone with only Xcode and no Command Line Tools please test? This should fix the recursion and also make builds work.

@stevewanless
Copy link

I just installed Homebrew a little while ago. Got the documented error;
/usr/local/Library/Homebrew/utils.rb:385:in `xctools_fucked?': stack level too deep (SystemStackError)

Made the change from mistydemeo and it's now working

@mistydemeo
Copy link
Contributor

Thank you, @stevewanless. Can you try installing some software, and tell me if that works?

@MikeMcQuaid
Copy link
Member

All hail @mistydemeo!

@samueljohn
Copy link
Contributor

At first sorry all, that was my fault and I couldn't respond yesterday timely.

I analyzed the issue. The good news: None of the existing homebrew users are affected so there need to revert.

On systems with only Xcode (that was not supported at all up to now) which have xcode-select set to a wrong path (like /Developer which does not exist on a fresh Lion) the method MacOS.locate(tool) resorts to the find the tool in MacOS.dev_tools_path. And my assumption that unless xctools_fucked?, I can use /usr/bin/xcrun does not hold, obviously.

Thanks @mistydemeo for your patch. We could also make xctools_fucked? always check if the directory does exist. That would also have solved the recursion thingy.

@samueljohn
Copy link
Contributor

I think I have a proper fix (#13037) for this issue by assuring that it's safe to call locate from dev_tools_path by checking

elsif not xctools_fucked? and system "/usr/bin/xcrun -find make 1>/dev/null 2>&1".

Now, it's safe to call locate, because we know that xcrun can find "make".

I have tested this with different settings of xcode-select (hint: sudo vim /usr/share/xcode-select/xcode_dir_path) for Xcode-only and CLT-only on Lion.

@samueljohn
Copy link
Contributor

Oh forgot to say, that I was able to reproduce on my Xcode-only setup when xcode-select points to nonexistant /Developer.

samueljohn added a commit to samueljohn/homebrew that referenced this issue Jun 27, 2012
Undoing parts of the hot fix 78b9e85.

The only thing missing was to check for `system "/usr/bin/xcrun -find make 1>/dev/null 2>&1"`
and then it's safe to call locate.

This commit restores the original functionality but without the risk for recursion
and improves the logic of `MacOS.locate`. See below.

To important changes in this commit:

- For Xcode _and_ CLT: don't add the SDK and leave things as before.
So if `MacOS.clt_installed?`, then no `SDKROOT` and `-L` and `-I`
directories are set in `ENV.macosxsdk`.

- Improved the logic for `MacOS.locate` for Xcode-only situations
by assuring that the xcode-select path is correct. This is done
by checking that `bin/make` exists and is executable. Otherwise it
was possible to set xcode-select to an empty dir.
This check is done in `MacOS.sdk_path` too.
We are now able to use Xcode wherever it is and can work even, if
xcode-select is set to invalid values. (Remember some users don't
have sudo access and that is needed to fix xcode-select).

Some minor whitespace fixes.
Minor backtick fix in doctor.rb's printout.
@adamv adamv closed this as completed in 9c82fc2 Jun 27, 2012
Sharpie pushed a commit to Sharpie/homebrew that referenced this issue Jul 1, 2012
Under certain circumstances, MacOS.locate and MacOS.dev_tools_path would call
each other recursively. This was limited to systems with Xcode minus the CLT.
See Homebrew#13012.
Sharpie pushed a commit to Sharpie/homebrew that referenced this issue Jul 1, 2012
Undoing parts of the hot fix 78b9e85.

The only thing missing was to check for `system "/usr/bin/xcrun -find make 1>/dev/null 2>&1"`
and then it's safe to call locate.

This commit restores the original functionality but without the risk for recursion
and improves the logic of `MacOS.locate`. See below.

To important changes in this commit:

- For Xcode _and_ CLT: don't add the SDK and leave things as before.
So if `MacOS.clt_installed?`, then no `SDKROOT` and `-L` and `-I`
directories are set in `ENV.macosxsdk`.

- Improved the logic for `MacOS.locate` for Xcode-only situations
by assuring that the xcode-select path is correct. This is done
by checking that `bin/make` exists and is executable. Otherwise it
was possible to set xcode-select to an empty dir.
This check is done in `MacOS.sdk_path` too.
We are now able to use Xcode wherever it is and can work even, if
xcode-select is set to invalid values. (Remember some users don't
have sudo access and that is needed to fix xcode-select).

Some minor whitespace fixes.
Minor backtick fix in doctor.rb's printout.

Signed-off-by: Adam Vandenberg <[email protected]>
RuiPereira added a commit to RuiPereira/homebrew that referenced this issue Jul 5, 2012
* master: (113 commits)
  ren 1.0
  fakeroot 1.18.4
  ice fails with clang
  gnu-prolog fails with (some versions of) clang
  uudeview fails with clang
  elasticsearch 0.19.7
  cairo: fix llvm compile error, add --universal
  mjpegtools fails with clang
  libmxml 2.7
  Extract MacOS module to separate file
  Refactor MacOS.
  remove confusing comments
  Fix Homebrew#13012 properly and don't set the SDK if CLT
  chromedriver 21.0.1180.4
  gphoto2 2.4.14
  libgphoto2 2.4.14
  Remove metapixel
  Remove lbdb.
  wxmac: use standard C++ string classes
  Voldemort 0.90.1
  ...
eproxus pushed a commit to eproxus/homebrew that referenced this issue Jul 18, 2012
Under certain circumstances, MacOS.locate and MacOS.dev_tools_path would call
each other recursively. This was limited to systems with Xcode minus the CLT.
See Homebrew#13012.
eproxus pushed a commit to eproxus/homebrew that referenced this issue Jul 18, 2012
Undoing parts of the hot fix 78b9e85.

The only thing missing was to check for `system "/usr/bin/xcrun -find make 1>/dev/null 2>&1"`
and then it's safe to call locate.

This commit restores the original functionality but without the risk for recursion
and improves the logic of `MacOS.locate`. See below.

To important changes in this commit:

- For Xcode _and_ CLT: don't add the SDK and leave things as before.
So if `MacOS.clt_installed?`, then no `SDKROOT` and `-L` and `-I`
directories are set in `ENV.macosxsdk`.

- Improved the logic for `MacOS.locate` for Xcode-only situations
by assuring that the xcode-select path is correct. This is done
by checking that `bin/make` exists and is executable. Otherwise it
was possible to set xcode-select to an empty dir.
This check is done in `MacOS.sdk_path` too.
We are now able to use Xcode wherever it is and can work even, if
xcode-select is set to invalid values. (Remember some users don't
have sudo access and that is needed to fix xcode-select).

Some minor whitespace fixes.
Minor backtick fix in doctor.rb's printout.

Signed-off-by: Adam Vandenberg <[email protected]>
snakeyroc3 pushed a commit to snakeyroc3/homebrew that referenced this issue Dec 17, 2012
Under certain circumstances, MacOS.locate and MacOS.dev_tools_path would call
each other recursively. This was limited to systems with Xcode minus the CLT.
See Homebrew#13012.
snakeyroc3 pushed a commit to snakeyroc3/homebrew that referenced this issue Dec 17, 2012
Undoing parts of the hot fix 78b9e85.

The only thing missing was to check for `system "/usr/bin/xcrun -find make 1>/dev/null 2>&1"`
and then it's safe to call locate.

This commit restores the original functionality but without the risk for recursion
and improves the logic of `MacOS.locate`. See below.

To important changes in this commit:

- For Xcode _and_ CLT: don't add the SDK and leave things as before.
So if `MacOS.clt_installed?`, then no `SDKROOT` and `-L` and `-I`
directories are set in `ENV.macosxsdk`.

- Improved the logic for `MacOS.locate` for Xcode-only situations
by assuring that the xcode-select path is correct. This is done
by checking that `bin/make` exists and is executable. Otherwise it
was possible to set xcode-select to an empty dir.
This check is done in `MacOS.sdk_path` too.
We are now able to use Xcode wherever it is and can work even, if
xcode-select is set to invalid values. (Remember some users don't
have sudo access and that is needed to fix xcode-select).

Some minor whitespace fixes.
Minor backtick fix in doctor.rb's printout.

Signed-off-by: Adam Vandenberg <[email protected]>
@spark85
Copy link

spark85 commented Dec 23, 2012

Hi, I'm still having this problem. How do I fix it? How do I install or use this fix?

@samueljohn
Copy link
Contributor

Exactly this problem? I doubt it. Unless you haven't updated since then. Please brew update and if your issue still remains please open a new issue @spark85.

@spark85
Copy link

spark85 commented Dec 23, 2012

I ran brew update and everything was already up to date. When I try and run 'gem install pg' it does not install, because it does not find the PostgreSQL libraries.

Let me give you more background on the problems I'm experiencing.
I am trying install Ruby on Rails on Heroku. When I try and build a project with the 'pg' database, I get an error that the database can't be found.

The command bundle install leads to this errror:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb 

checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
.
.
.
.An error occurred while installing pg (0.14.1), and Bundler cannot continue.
Make sure that gem install pg -v '0.14.1' succeeds before bundling.

So I've run 'gem install pg -v 0.14.1' which does not return any error message, but it also doesn't fix the problem.
I found the Gem on my filesystem, and checked the log file gem_make.out file, and I find the samy error message from before.

Online I was advised to re install PostgreSQL first, either with their installer script or using brew. Other people suggested adding the pg_config file to the path variable. That seemed to solve the problem for many people, but not for me.

On another note, in the process of installing the EnterpriseDB script, the wizard wanted me to connect to a database on port 5342, which it didn't seem to create.

I believe the libraries are installed correctly, but the Heroku installer is looking for some file in the wrong place, or with a different name, or some other conflict.

Thank you,

@jacknagel
Copy link
Contributor

...none of that has anything to do with this issue.

I can install the pg gem against Homebrew's postgresql without issue. Try asking on stackoverflow or something.

@spark85
Copy link

spark85 commented Jan 2, 2013

Hi...I need to add arguements to the bundle install. Sorry for complaining.

@Homebrew Homebrew locked and limited conversation to collaborators Feb 16, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.