Skip to content

Support pkg-config #39

Closed
Closed

Description

@tyrro

While installing the ruby-lua gem, I found out that the plugin doesn't support pkg-config. Other plugins such as asdf-ruby support pkg-config. Homebrew's Lua package supports it as well. Is it possible to include the support in this plugin?

In case you're interested in the error message due to the absence of pkg-config, I have included it here. Thank you for creating this plugin.

Error due to the absence of pkg-config
Installing ruby-lua 0.6.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/human/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/gems/ruby-lua-0.6.0/ext
/Users/human/.asdf/installs/ruby/2.6.8/bin/ruby -I /Users/human/.asdf/installs/ruby/2.6.8/lib/ruby/2.6.0 -r ./siteconf20240706-11547-1pxuoc6.rb extconf.rb
checking for lua-config... no
checking for pkg-config... yes
Package lua was not found in the pkg-config search path.
Perhaps you should add the directory containing `lua.pc'
to the PKG_CONFIG_PATH environment variable
No package 'lua' found
Package lua was not found in the pkg-config search path.
Perhaps you should add the directory containing `lua.pc'
to the PKG_CONFIG_PATH environment variable
No package 'lua' found
Package lua5.1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `lua5.1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'lua5.1' found
Package lua5.1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `lua5.1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'lua5.1' found
Package lua5.2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `lua5.2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'lua5.2' found
Package lua5.2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `lua5.2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'lua5.2' found
Package lua5.3 was not found in the pkg-config search path.
Perhaps you should add the directory containing `lua5.3.pc'
to the PKG_CONFIG_PATH environment variable
No package 'lua5.3' found
Package lua5.3 was not found in the pkg-config search path.
Perhaps you should add the directory containing `lua5.3.pc'
to the PKG_CONFIG_PATH environment variable
No package 'lua5.3' found
checking for lua.h... no
*** 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.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-lua50-dir
	--without-lua50-dir
	--with-lua50-include
	--without-lua50-include=${lua50-dir}/include
	--with-lua50-lib
	--without-lua50-lib=${lua50-dir}/lib
	--with-lua-dir
	--without-lua-dir
	--with-lua-include
	--without-lua-include=${lua-dir}/include
	--with-lua-lib
	--without-lua-lib=${lua-dir}/lib
	--with-lua51-dir
	--without-lua51-dir
	--with-lua51-include
	--without-lua51-include=${lua51-dir}/include
	--with-lua51-lib
	--without-lua51-lib=${lua51-dir}/lib
	--with-lua52-dir
	--without-lua52-dir
	--with-lua52-include
	--without-lua52-include=${lua52-dir}/include
	--with-lua52-lib
	--without-lua52-lib=${lua52-dir}/lib
	--with-lua53-dir
	--without-lua53-dir
	--with-lua53-include
	--without-lua53-include=${lua53-dir}/include
	--with-lua53-lib
	--without-lua53-lib=${lua53-dir}/lib
 extconf failure: need liblua50 (headers not found)

        Install the library or try one of the following options to extconf.rb:

        --with-lua-lib=/path/to/liblua/lib
        --with-lua-include=/path/to/liblua/include
    or
        --with-lua50-lib=/path/to/liblua/lib
        --with-lua50-include=/path/to/liblua/include


To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/human/.asdf/installs/ruby/2.6.8/lib/ruby/gems/2.6.0/extensions/arm64-darwin-23/2.6.0/ruby-lua-0.6.0/mkmf.log

extconf failed, exit code 1

Activity

  1. Stratus3D commented on Jul 8, 2024

    @Stratus3D
    Owner

    Hi @tyrro ! I'm not familiar with pkg-config, can you provide a rough example of how I'd add support to asdf-lua, and how it'd be used once support is added? Happy to add it if I can.

    Also, PR is welcome if you want to try implementing support for it!

  2. Stratus3D commented on May 1, 2026

    @Stratus3D
    Owner

    Closing due to lack of a response. @tyrro happy to reopen if you can provide more details on this, as well as impact this is having in your work.

  3. tyrro commented on May 5, 2026

    @tyrro
    Author

    Hi @Stratus3D — following up on this since the issue was closed. I originally opened it while debugging a native gem build failure with ruby-lua. After digging deeper, I found that adding pkg-config support wouldn't actually fix the underlying problem, so I took a different approach.

    Why pkg-config didn't work here:

    ruby-lua's extconf.rb tries several detection strategies in order. The one that fires with an asdf-installed Lua is the dir_config("lua") branch, which hardcodes -llualib -llua in the linker flags. Since Lua 5.1, liblualib was merged into liblua, so asdf installs only ship liblua.a — there is no liblualib.a — causing ld: library 'lualib' not found.

    Even if pkg-config were supported:

    • The exec-env hook (where PKG_CONFIG_PATH would be exported) only fires when a Lua shim is directly invoked (e.g. lua, luac). When bundle install runs Ruby to compile a native gem, the Lua exec-env is never sourced, so the env var is invisible to the compiler/linker.
    • The lua-config binary (another fallback in extconf.rb) fails when invoked from a gem build directory that has no .tool-versions, printing "No version is set for command lua-config".

    The actual fix:

    Creating a liblualib.a → liblua.a symlink in the install script is the minimal, targeted fix. It matches what Homebrew does and requires no changes to shell environment or gem build flags. I've opened a PR with this single change:

    ➡️ #50

    Happy to discuss further or adjust the approach if needed. Thanks!

  4. Stratus3D commented on May 9, 2026

    @Stratus3D
    Owner

    Hi @tyrro ,

    Are you using AI to generate your comments? I'm not getting paid to maintain this library, I'm happy to help you directly, but I'm unwilling to give your AI agent free assistance.

    In any case, it sounds like this is an issue with should be fixed in ruby-lua. It is not a bug in Lua or this asdf-lua plugin.

  5. tyrro commented on Jun 9, 2026

    @tyrro
    Author

    Hi @Stratus3D ,

    Yes, I used AI to help draft the above comment. I'm not an expert on this entire codebase, so I used it to help translate my thoughts into technical terms. I completely understand if you don't want to engage with it.

    Regarding the PR itself: the workaround I suggested is actually how I've been successfully running asdf-lua on my local machine. Since the ruby-lua gem is no longer maintained, this seemed like the most viable path forward for my setup.

    I understand if this falls outside the scope of this plugin, but I wanted to share what worked for me. Thank you for creating and maintaining asdf-lua!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions