How can I specify which compiler should be used for gem install
? In Bash
CC=gcc gem install ...
does not help, because it still uses Solaris Studio on my system.
Use `gem install -v` You may already be familiar with gem install , but if you add the -v flag, you can specify the version of the gem to install. Using -v you can specify an exact version or use version comparators.
The install command installs local or remote gem into a gem repository. For gems with executables ruby installs a wrapper file into the executable directory by default. This can be overridden with the –no-wrappers option.
For sqlite3-ruby your method is supported since Jan 2011 commit. But in general it's not possible to override this because of how rubygems works. It
Unpacks the gem.
Looks into it spec & discovers that it uses 'extensions' attribute--usually a path to a specially written extconf.rb file.
Runs that file to generate a Makefile. Unless author of extconf.rb explicitly said to honor env variables, they are ignored. For example, in latest versions of sqlite3-ruby gem, its extconf.rb has a line
RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
So if you run in Bash
CC=gcc gem install sqlite3-ruby
extconf.rb will generate the Makefile with the variable CC
in it that is
set to gcc
or whatever you want.
After Makefile is generated, rubygems executes make
utility to compile the
extension.
Theoretically, if rubygems allowed us to specify additional command line
parameters for make, we could use its -e
option and then do not depend on
authors of extconf.rb at all.
(-e
option gives variables taken from the environment precedence over
variables from makefiles.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With