-
-
Notifications
You must be signed in to change notification settings - Fork 905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nokogiri and libxml not playing with Rails on Mountain Lion? #742
Comments
+1. Same problem here. Ruby 1.9.3-p194, Rails 3.2.7, Nokogiri 1.5.5.
|
It sounds like something is loading libxml2 before nokogiri is being loaded. Can you try running your rails commands like this:
And paste the output? It should be a fairly long list of dyld libraries. We need to figure out how libxml2 is being loaded. Thanks! |
Hey Aaron, thanks for the reply :) Here's the output as requested:
Just a quick note to say I've been uninstalling/installing many times since I first posted the issue, and I think the latest try (in relation to the DYLD output above) I had installed it this way:
Just let me know how/if you need me to reinstall and/or repeat the DYLD command if need be :) |
OK. So the interesting lines are these:
It looks like the postgresql gem somehow depends on libxml2. When the pg extension gets loaded, something causes libxml2 to be loaded. I'm betting that if you do For fun, I used the ###
# $ ruby test.rb $(gem which pg_ext.bundle)
require 'graph'
SEEN = {}
def rawr_graph lib, grapher
return if SEEN[lib]
SEEN[lib] = true
libs = `otool -L #{lib}`.split($/).map(&:strip).drop_while { |l|
l.start_with? lib
}.map { |string| string[/[^(]*/].strip }
libs.each do |l|
grapher.edge File.basename(lib), File.basename(l)
rawr_graph l, grapher
end
end
digraph do
rotate
boxes
rawr_graph ARGV[0], self
save 'omg'
end If you run that program (like this pg -> Kerberos -> Security -> libxar -> libxml2 AFAIK, the only way to get around this issue is to ether: have nokogiri link against the system libxml2 (brew uninstall libxml2, reinstall nokogiri) or to make sure nokogiri gets required before pg. I suspect you have nokogiri listed after pg in your Gemfile. I think if you move nokogiri above pg in your gemfile, this should go away. Here is the graph on my system: |
Hi Aaron - thanks for the in-depth response :) Unfortunately it doesn't work :(
So I uninstalled libxml2 then uninstalled nokogiri, then reinstalled (Nokogiri) - but now I get:
Then I uninstalled and reinstalled with:
But it still gives me (what looks like the same) error - referring to 2.8.0 (weird!) (I also made sure Nokogiri is called before the pg gem in the Gemfile):
I also installed graph, and tried to run your script but I get:
Does any of that give you any further clues? Sorry to be a pain. |
Can you post your Gemfile? |
Here ya go Aaron:
|
Hi Aaron, not sure if it's any help, but I created a new test app, and only added Nokogiri to the gem file (and also did sudo uninstall pg) but I still can't require nokogiri in Rails console:
|
You're successfully requiring nokogiri. |
Sorry Aaron, I feel so stupid now! Apologies for wasting your time - you are such a star for being so nice about it :-) |
@AstonJ don't worry about it! Are you still getting the warning? |
Nah, I think they actually stopped when I reinstalled it one of the other ways - but as I kept getting false on require I assumed it was still broke blush. Or it could be your suggestion of moving it up the Gemfile that fixed it - sorry I can't give you a definite answer. Also, after all that, I ended up going back to Lion tonight - Mountain Lion is just so horribly buggy. Thanks again for your help - you're a real gem :) |
No problem, glad to help out. I'll close this, and if anyone else gets warnings, they can comment and I'll reopen. :) |
Hi there -
but still no dice. Any thoughts? |
From memory I think I did something like.. Moved gem 'nokogiri' in the Gemfile to the top (just below gem 'rails') then:
If that doesn't work you could try:
|
Heyo - that did it. Makes sense regarding the above mentioned comment about pg requiring nokogiri and using other extensions. Thanks!! |
You're welcome - glad you got it sorted :) |
i just installed Mavericks and was having the same issue. From @tenderlove comments above i realized that Postgres was loading libxml before Nokogiri, however moving the Nokogiri gem declaration to the top of the Gemfile (as others suggested) did not work for me. Instead, I used the libxml that ships with Postgres.app to build Nokogiri and was good to go: bundle config build.pg --with-pg-config=/Applications/Postgres93.app/Contents/MacOS/bin/pg_config
# use Postgres.app libxml2 to compile Nokogiri
bundle config build.nokogiri --with-xml2-lib=/Applications/Postgres93.app/Contents/MacOS/lib --with-xml2-include=/Applications/Postgres93.app/Contents/MacOS/include/libxml2
bundle install note: i have these gems installed locally in |
Thanks Firien for your comment. I have been dealing with this issue and following the previous comments and yours was really helpful to fix mine. |
Same here; kudos for Firien; I was able to load nokogiri 1.4.7 w/ Mavericks using this command:
|
I've installed Nokogiri, and everything works fine in irb, however, in the Rails console (or when running any Rails command) I get:
nokogiri -v shows:
I installed Nokogiri with:
As libxml2 with brew now installs 2.8.0 (still showing 2.7.8 in the instructions on the Nokogiri site - which is what I followed first).
Is this is a bug? Or have I messed up the install somehow? (Thanks in advance for any help.)
The text was updated successfully, but these errors were encountered: