tiny_tds icon indicating copy to clipboard operation
tiny_tds copied to clipboard

vendor/bundle/ruby/3.4.0/gems/tiny_tds-3.3.0/lib/tiny_tds/tiny_tds.so (LoadError)

Open jyothu opened this issue 2 months ago • 6 comments

Ruby: 3.4.6 tiny_tds: 3.3.0 OS: Windows Platform: x64-mingw-ucrt

We bundle all gems into the vendor/bundle directory and ship that in our production build. On the production machine, bundle install runs without issues. However, when we execute any rake command, we see the following error:

rake aborted!
LoadError: 126: The specified module could not be found.   -
C:/Program Files (x86)/XXXXXX/XXXXX/vendor/bundle/ruby/3.4.0/gems/tiny_tds-3.3.0/lib/tiny_tds/tiny_tds.so (LoadError)

The tiny_tds.so file does exist in that directory. My question is: even though x64-mingw-ucrt is already listed in the Gemfile.lock, why is the platform-specific TinyTDS gem not being installed?

Also, what additional DLLs (currently, I can see only libsybdb-5.dll)or dependencies does TinyTDS require on Windows that could cause this LoadError 126?

jyothu avatar Nov 21 '25 05:11 jyothu

LoadError 126 is quite a generic issue and just tells that something along our DLL / library chain was not found.

how do you add the gems to the production build? at my company, we do something like:

bundle config set --local path 'vendor/bundle'
bundle install --jobs=$($env:NUMBER_OF_PROCESSORS)

and then package everything into a ZIP. Then, on the target machine, we can do:

bundle install --local

which installs everything into the global directory that Ruby expects by default.

andyundso avatar Nov 21 '25 09:11 andyundso

Thank you, @andyundso , for your response. Yes, we follow a similar approach:

bundle config set --local path 'vendor/bundle'
bundle install --no-cache --standalone   # Not sure if this part is relevant?

After that, we package everything into a ZIP. On the target machine, we run bundle install --local, which completes successfully.

However, when running rake tasks in production, we encounter the following error:

vendor/bundle/ruby/3.4.0/gems/tiny_tds-3.0.0/lib/tiny_tds/tiny_tds.so (LoadError)
Caused by:
LoadError: cannot load such file -- tiny_tds/3.4/tiny_tds (LoadError)

Interestingly, this setup works fine on my Windows development machine where I simply run bundle install. But the error consistently appears in production. I also tried packaging with the mri platform, but the issue persists.

Any help would be greatly appreciated.

jyothu avatar Nov 24 '25 07:11 jyothu

I actually pasted you a wrong example, sorry about that.

If you use bundle cache --all --all-platforms on your machine, you get all .gem files including the platform-specific ones. you want to package up these files, which still allows you to run bundle install --local on the target machine.

andyundso avatar Nov 25 '25 09:11 andyundso

In my Gemfile.lock, the x64-mingw-ucrt platform is already listed, but the platform-specific tiny_tds gem still doesn’t get installed.

We generate the build on Windows, and our production environment is also Windows, so there is no cross-platform scenario involved.

What would you suggest here?

Also, when exactly should the bundle cache --all --all-platforms command be executed?

However, gem install tiny_tds -v "3.3.0" --platform x64-mingw-ucrt works correctly on my development machine. And platform-specific tiny_tds gem got installed.

So I copied:

  • the platform-specific gem folder (tiny_tds-3.3.0-x64-mingw-ucrt)
  • the .gemspec

into the vendor/bundle directory inside the production installation. I also updated Gemfile.lock accordingly.

bundle install --local succeeds, but when running a rake task, I still get the same error:

jyothu avatar Nov 26 '25 02:11 jyothu

my current assumption is that something goes wrong when you copy your local bundler folder (vendor/bundle) to the production machine. so it could be that the tiny_tds.so that lands on your production server is a locally compiled version from your dev machine that does not use platform-independent paths compared to our precompiled gem, which would explain the load errors.

So my suggestion would be to proceed as follows:

  1. On your development machine, run bundle cache --all --all-platforms.
  2. This downloads all the .gem into vendor/cache.
  3. Ship your code to your production machine. Make sure to include vendor/cache, but not vendor/bundle.
  4. On your production machine, invoke bundle install.
  5. This will install the gems from the vendor/cache folder and hopefully correctly resolve the platform-specific gem.

andyundso avatar Nov 26 '25 17:11 andyundso

@andyundso Thank you for your response. Let me try this and will get back to you!

jyothu avatar Nov 27 '25 00:11 jyothu