Skip to content
This repository was archived by the owner on Feb 1, 2021. It is now read-only.

rb-gsl broken on heroku (and similar platforms) #5

Closed
nolman opened this issue Jul 1, 2014 · 4 comments
Closed

rb-gsl broken on heroku (and similar platforms) #5

nolman opened this issue Jul 1, 2014 · 4 comments

Comments

@nolman
Copy link

nolman commented Jul 1, 2014

The change introduced in this commit: a8ce8f0 to link narray.so breaks on heroku and similar platforms as the build directories do not match the release directories.

/app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require': /tmp/build_a2e2adfe-654e-4ef3-ab4f-1c467a1882a4/vendor/bundle/ruby/2.1.0/gems/narray-0.6.0.9/src/narray.so: cannot open shared object file: No such file or directory - /app/vendor/bundle/ruby/2.1.0/extensions/x86_64-linux/2.1.0-static/rb-gsl-1.16.0.1/gsl/gsl_native.so (LoadError)
2014-07-01T05:24:15.421739+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `block in require'
2014-07-01T05:24:15.421741+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in `load_dependency'
2014-07-01T05:24:15.421746+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'
2014-07-01T05:24:15.421748+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/rb-gsl-1.16.0.1/lib/gsl.rb:9:in `rescue in <top (required)>'
2014-07-01T05:24:15.421750+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/rb-gsl-1.16.0.1/lib/gsl.rb:6:in `<top (required)>'
2014-07-01T05:24:15.421754+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `require'
2014-07-01T05:24:15.421756+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
2014-07-01T05:24:15.421758+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `each'
2014-07-01T05:24:15.421763+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `block in require'
2014-07-01T05:24:15.421799+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `each'
2014-07-01T05:24:15.421801+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `require'
2014-07-01T05:24:15.421803+00:00 app[web.1]:    from /app/vendor/bundle/ruby/2.1.0/gems/bundler-1.5.2/lib/bundler.rb:131:in `require'
2014-07-01T05:24:15.421808+00:00 app[web.1]:    from /app/config/application.rb:7:in `<top (required)>'
2014-07-01T05:24:15.421810+00:00 app[web.1]:    from /app/config/environment.rb:2:in `require'
2014-07-01T05:24:15.421812+00:00 app[web.1]:    from /app/config/environment.rb:2:in `<top (required)>'
2014-07-01T05:24:15.421814+00:00 app[web.1]:    from config.ru:3:in `require'
@blackwinter
Copy link
Owner

I'm not familiar with the build process on Heroku. Can you tell me where narray.h and narray.so are to be be found? Preferably in terms of information available from the Gem::Specification object.

NArray is configured through dir_config, so you can specify the shared object file location explicitly. I do think, however, that it should work out-of-the-box. If you could help me get there, I'd appreciate it.

@nolman
Copy link
Author

nolman commented Jul 1, 2014

At build time narray.so will be located in something along the lines of: /tmp/some_tmpdir/vendor/bundle/ruby/2.1.0/gems/narray-0.6.0.9/src/narray.so

After your app builds, heroku basically does a:
rm -rf /app
mv /tmp/some_tmpdir /app

So at runtime the path to the same file will be /app/vendor/bundle/ruby/2.1.0/gems/narray-0.6.0.9/src/narray.so. A relative path should remain unbroken? Sorry I do not have much experience with c extensions in ruby, I am not sure how other C gems with native extensions solve this problem.

@nolman
Copy link
Author

nolman commented Jul 1, 2014

Giving it more thought, does it make sense to copy the .h and .so in? Similarly to how eventmachine copies in openssl's header files? https://github.com/eventmachine/eventmachine/blob/master/ext/extconf.rb#L47

I can't think of any other gems that require .h and .so files from dependent gems, are you aware of any? I would be curious how they solve this same problem.

@blackwinter
Copy link
Owner

After your app builds, heroku basically does a:
rm -rf /app
mv /tmp/some_tmpdir /app

I see, thanks for the info.

A relative path should remain unbroken?

Unfortunately, no. Relative paths won't help much as that includes even more assumptions about the build environment into the process. We don't have the same information for rb-gsl that we have for narray at install time. In addition to that, a rake compile in the project directory would no longer work.

Giving it more thought, does it make sense to copy the .h and .so in?

I can't say I'd be in favour of such an approach. It should work, yes, but somehow I wouldn't feel comfortable doing it.

I can't think of any other gems that require .h and .so files from dependent gems, are you aware of any? I would be curious how they solve this same problem.

So would I, but a cursory search for narray specifically only revealed ruby-netcdf, ruby-fftw3 and nmap. And they don't have this exact problem as they don't try to fix the underlinking issue (see #4).

In conclusion, I think we should reconsider the "solution" for #4 so that it only applies where necessary. I don't see a way to make -l:narray.so work on Heroku.

Could you try and test rb-gsl-1.16.0.2.pre2?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants