Skip to content
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

fix empty RbConfig::CONFIG["prefix"] when configured --with-rubyarchprefix #643

Closed
wants to merge 1 commit into from

Conversation

lotheac
Copy link

@lotheac lotheac commented Jun 27, 2014

This fixes RbConfig::CONFIG["prefix"] being empty when ruby was configured
--with-rubyarchprefix. The 'why' is pretty convoluted:

rbconfig.rb is not generated by autoconf for some reason I cannot fathom, but
instead, at compile-time, miniruby is used to run tool/mkconfig.rb to generate
it. mkconfig.rb parses the config.status shell script to do that; that's weird,
but okay. The actually relevant lines in the script look like this:

S["rubyarchdir"]="${rubyarchprefix}/${ruby_version}"

So mkconfig.rb has code to expand these variables as well. But it doesn't end
here. TOPDIR in rbconfig.rb is what is used to figure out CONFIG["prefix"];
this is done by chopping off the part without the prefix from the full path of
the file:

TOPDIR = File.dirname(__FILE__).chomp!("/lib/amd64/ruby/2.0.0")

and

CONFIG["prefix"] = (TOPDIR || DESTDIR + "/opt/niksula")

I don't know why this needs to be done at runtime. Anyway, the bug lies in the
mkconfig.rb code that generates the TOPDIR line above. After reading the
variables from config.status, "prefix" and "exec_prefix" are set to the empty
string, and the expansion is only done after this. That means, if your
rubyarchprefix happens to begin with either "${prefix}" or "${exec_prefix}",
you will get a correctly generated TOPDIR line (one that does not contain your
prefix). However, if you used --with-rubyarchprefix to set it explicitly,
you're not so lucky: there is no prefix or exec_prefix variable there, so you
get the full rubyarchdir path on the TOPDIR line in rbconfig.rb, and thus the
prefix resolves to empty at runtime.

Because I don't know why TOPDIR is decided at runtime, I'm leaving it like that
with this patch; otherwise I'd just set it to be prefix.

I tested this against ruby 2.1.2 release version.

@nobu nobu closed this in bffd639 Jun 27, 2014
nobu added a commit that referenced this pull request Jun 27, 2014
* tool/mkconfig.rb: vars["prefix"] may not set.  [fix GH-643]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
mmasaki pushed a commit to mmasaki/ruby that referenced this pull request Aug 10, 2014
* tool/mkconfig.rb: fix empty RbConfig::CONFIG["prefix"] when
  configured --with-rubyarchprefix, remove prefix from rubyarchdir
  after expansion for the case it does not start with '$(prefix)'.
  [fix rubyGH-643]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
mmasaki pushed a commit to mmasaki/ruby that referenced this pull request Aug 10, 2014
* tool/mkconfig.rb: vars["prefix"] may not set.  [fix rubyGH-643]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant