Skip to content
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

Support invocation of ign command on Windows shells (Command Prompt, Powershell, Git Bash) #70

Closed
traversaro opened this issue Oct 29, 2021 · 0 comments · Fixed by #73
Closed
Labels
enhancement New feature or request help wanted Extra attention is needed Windows Windows support

Comments

@traversaro
Copy link
Contributor

traversaro commented Oct 29, 2021

Desired behavior

I would like that after installing ign-tools on Windows, the ign command was available in the three main shells used on Windows:

  • Command Prompt
  • Powershell
  • Git Bash

Actually, I already found a solution for this, and I wanted to mark it down before I forgot.

Git Bash

The least used shell on Windows is the one on which the solution is easier: just rename (or copy) the content of the <prefix>/bin/ign.rb in <prefix>/bin/ign, and the shebang works fine on Windows. However, the name used on Windows is ign.rb instead of just ign due to PR #57 by @ahcorde, so probably there is a reason for that. The summary of the PR reports "Windows requires the extension to run the Ruby file.", but in my case ruby ign on both PowerShell and Command Prompt works fine even without any .rb extension. If for some reason ign.rb is needed, we can anyhow install both ign and ign.rb.

Command Prompt & PowerShell

If instead you are on Command Prompt or PowerShell, an easy way to make sure that if you type ign then eventually the ign ruby script is invoked is to add/install in <prefix>/bin a proxy ign.bat script that just invokes the ruby installer. In particular, I tried a bit and the following script seems to be working fine:

@echo off
REM %~dp0 is the directory in which this bat script is, see
REM https://stackoverflow.com/questions/112055/what-does-d0-mean-in-a-windows-batch-file
REM %* redirects the arguments to the output, see 
REM https://serverfault.com/questions/22443/do-windows-batch-files-have-a-construction/22541#22541
ruby %~dp0\ign.rb %*

even if the script is written as a .bat, it seems to be working fine also when invoking ign from PowerShell.

Alternatives considered

Manually invoke the executables that will be eventually added via #7 . However, a lot of tutorials exists that refer to ign, and in any case it will take a long time to read feature parity, so it would be convenient to have some way to run ign on Windows.

Implementation suggestion

Reverting #57 and installing just on Windows the bat script reported earlier should fix the issue. I would be happy to propose a PR, but probably we need to understand the context and motivation of PR #57 .

Additional context

I wanted to easily debug the test failure in conda-forge/libignition-tools-feedstock#12 (comment) .

@traversaro traversaro added the enhancement New feature or request label Oct 29, 2021
@osrf-triage osrf-triage added this to Inbox in Core development Oct 29, 2021
@chapulina chapulina added the Windows Windows support label Oct 29, 2021
@chapulina chapulina removed this from Inbox in Core development Nov 12, 2021
@chapulina chapulina added the help wanted Extra attention is needed label Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed Windows Windows support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants