-
Notifications
You must be signed in to change notification settings - Fork 3
Fix libxml failure #39
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,209 @@ | ||
| name: windows | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| test-windows-scripts: | ||
| name: Test Windows Setup Scripts | ||
| runs-on: windows-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| ruby: ['3.2'] | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Ruby | ||
| uses: ruby/setup-ruby@v1 | ||
| with: | ||
| ruby-version: ${{ matrix.ruby }} | ||
| bundler-cache: false | ||
|
|
||
| - name: Verify MSYS2 Installation | ||
| shell: pwsh | ||
| run: | | ||
| if (Test-Path "C:\msys64") { | ||
| Write-Host "✓ MSYS2 found at C:\msys64" | ||
| } else { | ||
| Write-Host "✗ MSYS2 not found" | ||
| exit 1 | ||
| } | ||
|
|
||
| - name: Install libxml2 via MSYS2 | ||
| shell: cmd | ||
| run: | | ||
| # C:\msys64\usr\bin\pacman.exe -S --needed --noconfirm mingw-w64-x86_64-libxml2 mingw-w64-x86_64-libiconv mingw-w64-x86_64-zlib | ||
|
|
||
| C:\msys64\usr\bin\pacman.exe -S --needed --noconfirm mingw-w64-ucrt-x86_64-libxml2 mingw-w64-ucrt-x86_64-libiconv mingw-w64-ucrt-x86_64-zlib | ||
|
|
||
| - name: Set Environment Variables | ||
| shell: pwsh | ||
| run: | | ||
| $rubyPlatform = ruby -e "puts RUBY_PLATFORM" | ||
| Write-Host "Ruby platform: $rubyPlatform" | ||
|
|
||
| # $envPath = "C:\msys64\mingw64" | ||
| $envPath = "C:\msys64\ucrt64" | ||
|
|
||
| echo "ICONV_INCLUDE=$envPath\include" >> $env:GITHUB_ENV | ||
| echo "WINDOWS_XML2_INCLUDE=$envPath\include\libxml2" >> $env:GITHUB_ENV | ||
| echo "WINDOWS_XML2_LIB=$envPath\lib" >> $env:GITHUB_ENV | ||
| echo "MSYS2_PATH=$envPath" >> $env:GITHUB_ENV | ||
|
|
||
| # Set PATH to include MSYS2 bin directory for DLL resolution | ||
| $rubyBin = ruby -e "puts RbConfig::CONFIG['bindir']" | ||
| Write-Host "Ruby bin directory: $rubyBin" | ||
| Write-Host "PATH environment variable: $env:Path" | ||
| $env:Path += ";$envPath;$envPath\lib;$envPath\include;$envPath\include\libxml2;$rubyBin" | ||
| echo "PATH=$env:Path" >> $env:GITHUB_ENV | ||
| Write-Host "PATH environment variable: $env:Path" | ||
|
|
||
| Write-Host "Environment variables set:" | ||
| Write-Host " ICONV_INCLUDE=$envPath\include" | ||
| Write-Host " WINDOWS_XML2_INCLUDE=$envPath\include\libxml2" | ||
| Write-Host " WINDOWS_XML2_LIB=$envPath\lib" | ||
| Write-Host " PATH=$env:Path" | ||
|
|
||
| - name: Install libxml-ruby | ||
| shell: pwsh | ||
| run: | | ||
| Write-Host "ICONV_INCLUDE=$env:ICONV_INCLUDE" | ||
| Write-Host "WINDOWS_XML2_INCLUDE=$env:WINDOWS_XML2_INCLUDE" | ||
| Write-Host "WINDOWS_XML2_LIB=$env:WINDOWS_XML2_LIB" | ||
| Write-Host "MSYS2_PATH=$env:MSYS2_PATH" | ||
|
|
||
| Write-Host "Files in $env:ICONV_INCLUDE are" | ||
| dir -Path $env:ICONV_INCLUDE | ForEach-Object { | ||
| Write-Host $_.Name | ||
| } | ||
|
|
||
| Write-Host "Files in $env:WINDOWS_XML2_INCLUDE are" | ||
| dir -Path $env:WINDOWS_XML2_INCLUDE | ForEach-Object { | ||
| Write-Host $_.Name | ||
| } | ||
|
|
||
| Write-Host "Files in $env:WINDOWS_XML2_LIB are" | ||
| dir -Path $env:WINDOWS_XML2_LIB | ForEach-Object { | ||
| Write-Host $_.Name | ||
| } | ||
|
|
||
| Write-Host "Files in $env:MSYS2_PATH are" | ||
| dir -Path $env:MSYS2_PATH | ForEach-Object { | ||
| Write-Host $_.Name | ||
| } | ||
|
|
||
| $rubyPlatform = ruby -e "puts RUBY_PLATFORM" | ||
| Write-Host "Installing libxml-ruby for $rubyPlatform..." | ||
|
|
||
| gem install libxml-ruby --version 5.0.3 -- --with-xml2-include=$env:WINDOWS_XML2_INCLUDE --with-xml2-lib=$env:WINDOWS_XML2_LIB --with-xml2-dir=$env:MSYS2_PATH --with-iconv-include=$env:ICONV_INCLUDE | ||
|
|
||
| if ($LASTEXITCODE -eq 0) { | ||
| Write-Host "✓ libxml-ruby installed successfully" | ||
| } else { | ||
| Write-Host "✗ Failed to install libxml-ruby" | ||
| exit 1 | ||
| } | ||
|
|
||
| - name: Copy Required DLLs | ||
| shell: pwsh | ||
| run: | | ||
| $msys2Path = $env:MSYS2_PATH | ||
| $rubyBin = ruby -e "puts RbConfig::CONFIG['bindir']" | ||
|
|
||
| $libxmlrubyfilepath = gem which libxml-ruby | ||
| $libxmlrubyfolder = Split-Path -Path $libxmlrubyfilepath -Parent | ||
| Write-Host "Folder of libxml-ruby is $libxmlrubyfolder" | ||
|
|
||
| $sourcedir = "$msys2Path\bin" | ||
| Write-Host "Files in $sourcedir are:" | ||
| dir -Path $sourcedir -File | ForEach-Object { | ||
| Write-Host $_.Name | ||
| } | ||
|
|
||
| Write-Host "Copying DLLs from $msys2Path\bin to $rubyBin..." | ||
| $dlls = @("libxml2-16.dll", "libiconv-2.dll", "zlib1.dll") | ||
| foreach ($dll in $dlls) { | ||
| $source = "$msys2Path\bin\$dll" | ||
| $dest = "$rubyBin\$dll" | ||
| $dest2 = "$libxmlrubyfolder\$dll" | ||
|
|
||
| if (Test-Path $source) { | ||
| Copy-Item $source $dest -Force | ||
| Copy-Item $source $dest2 -Force | ||
| Write-Host "✓ Copied $dll" | ||
| } else { | ||
| Write-Host "✗ $dll not found at $source" | ||
| } | ||
| } | ||
|
|
||
| Write-Host "Files in $libxmlrubyfolder\${{ matrix.ruby }} are" | ||
| dir -Path "$libxmlrubyfolder\${{ matrix.ruby }}" | ForEach-Object { | ||
| Write-Host $_.Name | ||
| } | ||
| Write-Host "Copying SO from $libxmlrubyfolder\${{ matrix.ruby }} to $rubyBin..." | ||
| $source = "$libxmlrubyfolder\${{ matrix.ruby }}\libxml_ruby.so" | ||
| $dest = "$rubyBin\libxml_ruby.so" | ||
|
|
||
| if (Test-Path $source) { | ||
| Copy-Item $source $dest -Force | ||
| Copy-Item $source "$libxmlrubyfolder\libxml_ruby.so" -Force | ||
| Write-Host "✓ Copied libxml_ruby.so" | ||
| } else { | ||
| Write-Host "✗ libxml_ruby.so not found at $source" | ||
| } | ||
|
|
||
| - name: Test libxml-ruby Installation | ||
| shell: pwsh | ||
| run: | | ||
| Write-Host "Inspec PATH environment variable: $env:Path" | ||
|
|
||
| ruby -e @" | ||
| require 'libxml' | ||
| puts "libxml-ruby version: #{LibXML::XML::VERSION}" | ||
| puts "libxml2 version: #{LibXML::XML::LIBXML_VERSION}" | ||
|
|
||
| # Test basic parsing | ||
| doc = LibXML::XML::Document.string('<root><child attr="value"/></root>') | ||
| puts "Root element: #{doc.root.name}" | ||
| puts "Child element: #{doc.root.child.name}" | ||
| puts "Attribute value: #{doc.root.child['attr']}" | ||
| puts "" | ||
| puts "✓ libxml-ruby is working correctly!" | ||
| "@ | ||
|
|
||
| - name: Test Moxml with LibXML Adapter | ||
| shell: pwsh | ||
| run: | | ||
| bundle install | ||
|
|
||
| ruby -e @" | ||
| require 'moxml' | ||
|
|
||
| # Configure to use LibXML adapter | ||
| Moxml.configure do |config| | ||
| config.adapter = :libxml | ||
| end | ||
|
|
||
| # Create a document | ||
| doc = Moxml.new.create_document | ||
| root = doc.create_element('root') | ||
| doc.add_child(root) | ||
|
|
||
| child = doc.create_element('child') | ||
| child['attr'] = 'value' | ||
| child.text = 'Hello from Windows!' | ||
| root.add_child(child) | ||
|
|
||
| puts "Document created with LibXML adapter:" | ||
| puts doc.to_xml(indent: 2) | ||
| puts "" | ||
| puts "✓ Moxml with LibXML adapter is working on Windows!" | ||
| "@ | ||
|
|
||
| bundle exec rake |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,18 +7,26 @@ gemspec | |||||||||||||||||
|
|
||||||||||||||||||
| gem "byebug" | ||||||||||||||||||
| gem "get_process_mem" | ||||||||||||||||||
| gem "libxml-ruby", "~> 5.0" | ||||||||||||||||||
| gem "nokogiri", "~> 1.18" | ||||||||||||||||||
| gem "oga", "~> 3.4" | ||||||||||||||||||
| gem "ox", "~> 2.14" | ||||||||||||||||||
| gem "rake" | ||||||||||||||||||
| gem "rexml" | ||||||||||||||||||
| gem "rspec" | ||||||||||||||||||
| gem "simplecov", require: false | ||||||||||||||||||
| gem "rubocop" | ||||||||||||||||||
| gem "rubocop-performance" | ||||||||||||||||||
| gem "rubocop-rake" | ||||||||||||||||||
| gem "rubocop-rspec" | ||||||||||||||||||
| gem "simplecov", require: false | ||||||||||||||||||
| gem "tempfile" | ||||||||||||||||||
| # Provides iteration per second benchmarking for Ruby | ||||||||||||||||||
| gem "benchmark-ips" | ||||||||||||||||||
|
|
||||||||||||||||||
| # Needed by get_process_mem on Windows | ||||||||||||||||||
| gem "sys-proctable" if Gem.win_platform? | ||||||||||||||||||
|
|
||||||||||||||||||
| if Gem.win_platform? | ||||||||||||||||||
| gem "libxml-ruby", "5.0.4" | ||||||||||||||||||
| else | ||||||||||||||||||
| gem "libxml-ruby" | ||||||||||||||||||
| end | ||||||||||||||||||
|
Comment on lines
+28
to
+32
|
||||||||||||||||||
| if Gem.win_platform? | |
| gem "libxml-ruby", "5.0.4" | |
| else | |
| gem "libxml-ruby" | |
| end | |
| # Pinning libxml-ruby to 5.0.4 for all platforms to ensure consistent behavior. | |
| # If a newer version is required, update this constraint after verifying cross-platform compatibility. | |
| gem "libxml-ruby", "5.0.4" |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,39 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #!/usr/bin/env ruby | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| require "rubygems" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # spec = Gem::Specification.find_by_name("libxml-ruby") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| spec = Gem::Specification.find_by_name("moxml") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| spec = Gem::Specification.find_by_name("moxml") | |
| gem_name = ENV["GEM_NAME"] || ARGV[0] || "libxml-ruby" | |
| spec = Gem::Specification.find_by_name(gem_name) |
Copilot
AI
Nov 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This debug script contains extensive commented-out code (lines 8-12, 17-37) that should be removed before merging. Commented code clutters the codebase and can be retrieved from version control history if needed.
| # all_files = Dir.glob("#{spec.full_gem_path}/**/*").select { |f| File.file?(f) } | |
| # all_files.each do |file| | |
| # puts file | |
| # end | |
| # check PATH | |
| puts ENV.fetch("PATH", nil) | |
| # patch lib/libxml-ruby.rb | |
| # filepath = "a.txt" | |
| filepath = File.expand_path("#{spec.full_gem_path}/dlls") | |
| ENV["PATH"] = "#{ENV.fetch("PATH", nil)};#{filepath}" | |
| puts "Patched PATH:" | |
| puts ENV.fetch("PATH", nil) | |
| # original_content = File.read(filepath) | |
| # line_to_add = "ENV['PATH'] = ENV['PATH'] + ';' + File.expand_path(File.dirname(__FILE__))\nputs 'Patched PATH: ' + ENV['PATH']" | |
| # # Combine the new line with the original content | |
| # new_content = line_to_add + "\n" + original_content | |
| # # Overwrite the file with the new content | |
| # File.write(filepath, new_content) | |
| # puts "new_content================" | |
| # puts new_content | |
| # puts "===========================" | |
| # check PATH | |
| puts ENV.fetch("PATH", nil) | |
| filepath = File.expand_path("#{spec.full_gem_path}/dlls") | |
| ENV["PATH"] = "#{ENV.fetch("PATH", nil)};#{filepath}" | |
| puts "Patched PATH:" | |
| puts ENV.fetch("PATH", nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
after-setup-rubystep runs the debug script but always succeeds due to|| true. This masks failures and defeats the purpose of running it in CI. Either:|| trueto catch failures, or