ddnexus / pagy

🏆 The Best Pagination Ruby Gem 🥇
https://ddnexus.github.io/pagy
MIT License
4.57k stars 408 forks source link

Bug: Request for Pagy Gem: Making Commands Platform Independent #702

Closed SaidRasinlic closed 4 months ago

SaidRasinlic commented 4 months ago

👀 Before submitting...

🧐 REQUIREMENTS

💬 Description

Hello Pagy Team,

I hope this message finds you well. I'm writing to bring to your attention an issue I encountered while using the Pagy gem on Windows operating systems. Currently, some Pagy commands are not platform-independent, leading to errors when attempting to run them on Windows.

Issue:

When attempting to run Pagy commands on Windows, such as pagy demo, I encountered the following error: /Ruby32-x64/lib/ruby/gems/3.2.0/gems/pagy-8.4.0/lib -r pagy -o 0.0.0.0 -p 8000 -E showcase C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/pagy-8.4.0/apps/demo.ru -q (Errno::ENOENT) from C:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/pagy-8.4.0/bin/pagy:96:in <top (required)>'

Explanation:

The issue arises from the use of the exec method with inline environment variable assignment, which is not compatible with Windows Command Prompt or PowerShell.

Proposal:

I suggest making the Pagy commands platform-independent by using Ruby's built-in environment variable handling (ENV) and the system method. This approach will ensure consistent behavior across different platforms, including Windows.

Example:

Instead of:

exec("PAGY_INSTALL_BUNDLE='#{opts[:install]}' #{rerun || rackup}")

at C:\Ruby32-x64\lib\ruby\gems\3.2.0\gems\pagy-8.4.0\bin\pagy on line :96

Use:

ENV['PAGY_INSTALL_BUNDLE'] = opts[:install].to_s
command = "#{rerun || rackup}"
puts "Executing command: #{command} with PAGY_INSTALL_BUNDLE=#{opts[:install].to_s}"
system(command)

Benefits:


Thank you for considering my request. I believe that making Pagy commands platform-independent will enhance its value and accessibility to a wider audience of developers.

Best Regards,

Said R.

ddnexus commented 4 months ago

This is a "Feature request", not a bug and since it is very well structured, respectful and polite, it will not get just closed, but converted into a discussion.