Created
April 27, 2011 20:53
-
-
Save hidenowt/945178 to your computer and use it in GitHub Desktop.
Truque para o Bundler com extensões de C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Gemfile | |
source 'http://rubygems.org' | |
source "http://gems.github.com" | |
gem 'rails', '3.0.6' | |
gem 'pg' | |
$ bundle install | |
Fetching source index for http://rubygems.org/ | |
Fetching source index for http://gems.github.com/ | |
Installing pg (0.11.0) with native extensions `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) | |
checking for pg_config... no | |
No pg_config... trying anyway. If building fails, please try again with | |
--with-pg-config=/path/to/pg_config | |
*** extconf.rb failed *** | |
Could not create Makefile due to some reason, probably lack of | |
necessary libraries and/or headers. Check the mkmf.log file for more | |
details. You may need configuration options. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Você usa um projeto rails que tem o arquivo GemFile e toda vez que vai usar o comando bundle para instalar as gems e algumas delas precisa de extensões de C, existe uma flag especial para instalação, sem ter que ficar instalando essa gem pelo rubygems no local do bundle. | |
Se você realmente precisa para passar essas flags para uma extensão de C, você pode usar o comando de bundle config: | |
# Exemplo para a gem pg no Mac OSX | |
# Vale notar que onde tem 'build.pg', esse 'pg' é o nome da gem. | |
$ bundle config build.pg --with-pg-config=/usr/local/PostgreSQL/9.0/bin/pg_config | |
Bundler irá armazenar esta configuração em ~/.bundle/config e o bundler usará a configuração de qualquer bundle install executado. Com isso você pode instalar o gem quantas vezes se necessário. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
O arquivo criado pelo bundle config é esse: | |
$ cat ~/.bundle/config | |
--- | |
BUNDLE_BUILD__PG: --with-pg-config=/usr/local/PostgreSQL/9.0/bin/pg_config |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Depois basta executar novamente o bundle install no seu projeto: | |
$ bundle install | |
Fetching source index for http://rubygems.org/ | |
Fetching source index for http://gems.github.com/ | |
Installing pg (0.11.0) with native extensions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment