Skip to content

Fix load path for precompiled code on Windows #582

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

Merged
merged 4 commits into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 3 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ jobs:
name: install-windows-mingw
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
Expand All @@ -80,13 +78,7 @@ jobs:

- name: Install native gem
shell: pwsh
run: |
$rubyArchitecture = (ruby -e "puts RbConfig::CONFIG['arch']").Trim()
$gemVersion = (Get-Content VERSION).Trim()
$gemToInstall = "./tiny_tds-$gemVersion-$rubyArchitecture.gem"

Write-Host "Looking to install $gemToInstall"
gem install "$gemToInstall"
run: gem install "tiny_tds-*.gem"

- name: Test if TinyTDS loads
shell: pwsh
Expand Down Expand Up @@ -191,8 +183,6 @@ jobs:
name: install-windows-ucrt
runs-on: windows-latest
steps:
- uses: actions/checkout@v4

- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
Expand All @@ -205,13 +195,7 @@ jobs:

- name: Install native gem
shell: pwsh
run: |
$rubyArchitecture = (ruby -e "puts RbConfig::CONFIG['arch']").Trim()
$gemVersion = (Get-Content VERSION).Trim()
$gemToInstall = "./tiny_tds-$gemVersion-$rubyArchitecture.gem"

Write-Host "Looking to install $gemToInstall"
gem install "$gemToInstall"
run: gem install "tiny_tds-*.gem"

- name: Test if TinyTDS loads
shell: pwsh
Expand Down Expand Up @@ -389,8 +373,6 @@ jobs:
name: install-linux
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- name: Download precompiled gem
uses: actions/download-artifact@v4
with:
Expand All @@ -407,7 +389,7 @@ jobs:
sh -c "
gem update --system 3.3.22 &&
${{ matrix.bootstrap }}
gem install --no-document ./gems/tiny_tds-$(cat VERSION)-${{ matrix.platform }}.gem &&
gem install --no-document ./gems/tiny_tds-*.gem &&
ruby -e \"require 'tiny_tds'; puts TinyTds::Gem.root_path\" &&
tsql-ttds -C &&
defncopy-ttds -v
Expand All @@ -425,7 +407,6 @@ jobs:
- true

mssql-version:
- 2017
- 2019
- 2022

Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 3.2.1

* Ensure the native Gem loads on Windows. Fixes #581.

## 3.2.0

* Reduce number of files shipped with precompiled Windows gem
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.0
3.2.1
2 changes: 1 addition & 1 deletion lib/tiny_tds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module TinyTds
# Is this file part of a fat binary gem with bundled freetds?
# This path must be enabled by add_dll_directory on Windows.
gplat = ::Gem::Platform.local
FREETDS_LIB_PATH = Dir[File.expand_path("../ports/#{gplat.cpu}-#{gplat.os}*/lib", __dir__)].first
FREETDS_LIB_PATH = Dir[File.expand_path("../ports/#{gplat.cpu}-#{gplat.os}*/{bin,lib}", __dir__)].first

add_dll_path = proc do |path, &block|
if RUBY_PLATFORM =~ /(mswin|mingw)/i && path
Expand Down