Problem with linked Ruby scaffolding gem dependencies


#1

I’ve got an app requiring the mysql2 gem. I’ve got mysql-client in my deps and rubygems and everything else builds clean, but running I’m getting complaints about not being able to find libatomic.so.1 from the gem:

learnchef-backend.default(O): /hab/pkgs/chefops/learnchef-backend/0.1.0/20180813171110/app/vendor/bundle/ruby/2.5.0/gems/mysql2-0.4.10/lib/mysql2.rb:31:in `require': libatomic.so.1: cannot open shared object file: No such file or directory - /hab/pkgs/chefops/learnchef-backend/0.1.0/20180813171110/app/vendor/bundle/ruby/2.5.0/gems/mysql2-0.4.10/lib/mysql2/mysql2.so (LoadError)

However, inside the package itself, it looks like it is linked correctly once, and incorrectly a second time?

ldd /hab/pkgs/chefops/learnchef-backend/0.1.0/20180813170432/app/vendor/bundle/ruby/2.5.0/gems/mysql2-0.4.10/lib/mysql2/mysql2.so| grep atomic
libatomic.so.1 => not found
libatomic.so.1 => /hab/pkgs/core/gcc-libs/7.3.0/20180608091701/lib/libatomic.so.1 (0x00007f7c5858e000)

#2

@jb can you share the plan for this?


#3

sure!

pkg_origin=chefops
pkg_version="0.1.0"
pkg_license=("Proprietary")

pkg_scaffolding="core/scaffolding-ruby"

scaffolding_ruby_pkg="core/ruby/$(cat ${PLAN_CONTEXT}/../.ruby-version)"

pkg_deps=(
  core/curl
  core/mysql-client
)

do_build() {
  grep -v '#' "$PLAN_CONTEXT/../.env-example" | while read -r VAR; do
    export ${VAR}
  done
  export LC_ALL="en_US.UTF-8"
  export LANG="en_US.UTF-8"
  do_default_build
}

declare -A scaffolding_env

scaffolding_env[SENTRY_DSN]="{{cfg.sentry_dsn}}"
scaffolding_env[SECRET_KEY_BASE]="{{cfg.secret_key_base}}"
scaffolding_env[GITHUB_KEY]="{{cfg.github.key}}"
scaffolding_env[GITHUB_SECRET]="{{cfg.github.secret}}"
scaffolding_env[LINKEDIN_KEY]="{{cfg.linkedin.key}}"
scaffolding_env[LINKEDIN_SECRET]="{{cfg.linkedin.secret}}"
scaffolding_env[GOOGLE_KEY]="{{cfg.google.key}}"
scaffolding_env[GOOGLE_SECRET]="{{cfg.google.secret}}"
scaffolding_env[TWITTER_CONSUMER_KEY]="{{cfg.twitter.consumer_key}}"
scaffolding_env[TWITTER_CONSUMER_SECRET]="{{cfg.twitter.consumer_secret}}"
scaffolding_env[SUPERMARKET_KEY]="{{cfg.supermarket.key}}"
scaffolding_env[SUPERMARKET_SECRET]="{{cfg.supermarket.secret}}"
scaffolding_env[MARKETO_HOST]="{{cfg.marketo.host}}"
scaffolding_env[MARKETO_CLIENT_ID]="{{cfg.marketo.client_id}}"
scaffolding_env[MARKETO_CLIENT_SECRET]="{{cfg.marketo.client_secret}}"
scaffolding_env[MARKETO_CAMPAIGN_ID]="{{cfg.marketo.campaign_id}}"

#4

@joshbrand gave me some inside peeks into the code and it appears this is because our glibc version doesn’t have support for glibc 2.25.

verbose ldd output:

ldd -v ../app/vendor/bundle/ruby/2.5.0/gems/mysql2-0.4.10/lib/mysql2/mysql2.so
../app/vendor/bundle/ruby/2.5.0/gems/mysql2-0.4.10/lib/mysql2/mysql2.so: /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6: version `GLIBC_2.25' not found (required by /hab/pkgs/core/ruby/2.5.1/20180702162818/lib/libruby.so.2.5)
	linux-vdso.so.1 (0x00007ffd8ebf9000)
	libruby.so.2.5 => /hab/pkgs/core/ruby/2.5.1/20180702162818/lib/libruby.so.2.5 (0x00007f3a797c2000)
	libmysqlclient.so.20 => /hab/pkgs/core/mysql-client/5.7.21/20180608165812/lib/libmysqlclient.so.20 (0x00007f3a79202000)
	libpthread.so.0 => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libpthread.so.0 (0x00007f3a78fe5000)
	libm.so.6 => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libm.so.6 (0x00007f3a78ce7000)
	librt.so.1 => /hab/pkgs/core/glibc/2.22/20170513201042/lib/librt.so.1 (0x00007f3a78adf000)
	libatomic.so.1 => not found
	libssl.so.1.0.0 => not found
	libcrypto.so.1.0.0 => not found
	libdl.so.2 => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libdl.so.2 (0x00007f3a788db000)
	libcrypt.so.1 => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libcrypt.so.1 (0x00007f3a786a3000)
	libc.so.6 => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6 (0x00007f3a782ff000)
	/hab/pkgs/core/glibc/2.22/20170513201042/lib64/ld-linux-x86-64.so.2 (0x00007f3a79f05000)
	libssl.so.1.0.0 => /hab/pkgs/core/openssl/1.0.2n/20180608102213/lib/libssl.so.1.0.0 (0x00007f3a7808c000)
	libcrypto.so.1.0.0 => /hab/pkgs/core/openssl/1.0.2n/20180608102213/lib/libcrypto.so.1.0.0 (0x00007f3a77c2e000)
	libatomic.so.1 => /hab/pkgs/core/gcc-libs/7.3.0/20180608091701/lib/libatomic.so.1 (0x00007f3a77a26000)
	libstdc++.so.6 => /hab/pkgs/core/gcc-libs/7.3.0/20180608091701/lib/libstdc++.so.6 (0x00007f3a77624000)
	libgcc_s.so.1 => /hab/pkgs/core/gcc-libs/7.3.0/20180608091701/lib/libgcc_s.so.1 (0x00007f3a7740d000)
	libz.so.1 => /hab/pkgs/core/zlib/1.2.11/20180608050617/lib/libz.so.1 (0x00007f3a771ef000)

	Version information:
	../app/vendor/bundle/ruby/2.5.0/gems/mysql2-0.4.10/lib/mysql2/mysql2.so:
		libc.so.6 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libmysqlclient.so.20 (libmysqlclient_20.0) => /hab/pkgs/core/mysql-client/5.7.21/20180608165812/lib/libmysqlclient.so.20
		libpthread.so.0 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libpthread.so.0
	/hab/pkgs/core/ruby/2.5.1/20180702162818/lib/libruby.so.2.5:
		libcrypt.so.1 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libcrypt.so.1
		libdl.so.2 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libdl.so.2
		ld-linux-x86-64.so.2 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib64/ld-linux-x86-64.so.2
		libpthread.so.0 (GLIBC_2.3.3) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libpthread.so.0
		libpthread.so.0 (GLIBC_2.12) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libpthread.so.0
		libpthread.so.0 (GLIBC_2.3.2) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libpthread.so.0
		libpthread.so.0 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libpthread.so.0
		libm.so.6 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libm.so.6
		libc.so.6 (GLIBC_2.14) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.8) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.6) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.25) => not found
		libc.so.6 (GLIBC_2.3) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.4) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.3.4) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.17) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.9) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
	/hab/pkgs/core/mysql-client/5.7.21/20180608165812/lib/libmysqlclient.so.20:
		libgcc_s.so.1 (GCC_3.0) => /hab/pkgs/core/gcc-libs/7.3.0/20180608091701/lib/libgcc_s.so.1
		libstdc++.so.6 (CXXABI_1.3) => /hab/pkgs/core/gcc-libs/7.3.0/20180608091701/lib/libstdc++.so.6
		libdl.so.2 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libdl.so.2
		libc.so.6 (GLIBC_2.14) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.3) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libpthread.so.0 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libpthread.so.0
	/hab/pkgs/core/glibc/2.22/20170513201042/lib/libpthread.so.0:
		ld-linux-x86-64.so.2 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib64/ld-linux-x86-64.so.2
		ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /hab/pkgs/core/glibc/2.22/20170513201042/lib64/ld-linux-x86-64.so.2
		libc.so.6 (GLIBC_2.14) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.3.2) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_PRIVATE) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
	/hab/pkgs/core/glibc/2.22/20170513201042/lib/libm.so.6:
		libc.so.6 (GLIBC_PRIVATE) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
	/hab/pkgs/core/glibc/2.22/20170513201042/lib/librt.so.1:
		libpthread.so.0 (GLIBC_2.3.2) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libpthread.so.0
		libpthread.so.0 (GLIBC_PRIVATE) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libpthread.so.0
		libpthread.so.0 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libpthread.so.0
		libc.so.6 (GLIBC_2.14) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.3.2) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_PRIVATE) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
	/hab/pkgs/core/glibc/2.22/20170513201042/lib/libdl.so.2:
		ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /hab/pkgs/core/glibc/2.22/20170513201042/lib64/ld-linux-x86-64.so.2
		libc.so.6 (GLIBC_PRIVATE) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
	/hab/pkgs/core/glibc/2.22/20170513201042/lib/libcrypt.so.1:
		libc.so.6 (GLIBC_2.14) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_PRIVATE) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
	/hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6:
		ld-linux-x86-64.so.2 (GLIBC_2.3) => /hab/pkgs/core/glibc/2.22/20170513201042/lib64/ld-linux-x86-64.so.2
		ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /hab/pkgs/core/glibc/2.22/20170513201042/lib64/ld-linux-x86-64.so.2
	/hab/pkgs/core/openssl/1.0.2n/20180608102213/lib/libssl.so.1.0.0:
		libc.so.6 (GLIBC_2.14) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
	/hab/pkgs/core/openssl/1.0.2n/20180608102213/lib/libcrypto.so.1.0.0:
		libdl.so.2 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libdl.so.2
		libc.so.6 (GLIBC_2.3) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.7) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.14) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
	/hab/pkgs/core/gcc-libs/7.3.0/20180608091701/lib/libatomic.so.1:
		libpthread.so.0 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libpthread.so.0
		libc.so.6 (GLIBC_2.14) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
	/hab/pkgs/core/gcc-libs/7.3.0/20180608091701/lib/libstdc++.so.6:
		libm.so.6 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libm.so.6
		ld-linux-x86-64.so.2 (GLIBC_2.3) => /hab/pkgs/core/glibc/2.22/20170513201042/lib64/ld-linux-x86-64.so.2
		libgcc_s.so.1 (GCC_4.2.0) => /hab/pkgs/core/gcc-libs/7.3.0/20180608091701/lib/libgcc_s.so.1
		libgcc_s.so.1 (GCC_3.3) => /hab/pkgs/core/gcc-libs/7.3.0/20180608091701/lib/libgcc_s.so.1
		libgcc_s.so.1 (GCC_3.0) => /hab/pkgs/core/gcc-libs/7.3.0/20180608091701/lib/libgcc_s.so.1
		libc.so.6 (GLIBC_2.14) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.18) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.16) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.3) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.17) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.3.2) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
	/hab/pkgs/core/gcc-libs/7.3.0/20180608091701/lib/libgcc_s.so.1:
		libc.so.6 (GLIBC_2.14) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
	/hab/pkgs/core/zlib/1.2.11/20180608050617/lib/libz.so.1:
		libc.so.6 (GLIBC_2.14) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6
		libc.so.6 (GLIBC_2.2.5) => /hab/pkgs/core/glibc/2.22/20170513201042/lib/libc.so.6

#5

Following up with the solution: We needed to include core/gcc-libs (for libatomic) and core/openssl (for crypto). The reason this was so confusing was because the studio includes these by default and ldd was seeing them as part of it’s dynamic search path. However, the shared object itself wasn’t linked to them because we didn’t have the aforementioned deps at build time.