ruby / ruby/racc

Shebang mode fails on JRuby due to bash script launcher

Open
#95 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Yacc
Stars
569
Forks
93
Avg merge
4d 19h
Merged PRs (30d)
4

Description

The "shebang" mode for the parser generator does not work properly on some configurations of JRuby due to the jruby command being a bash script.

This leads to the following error in CI (see #93):

Failure:
Racc::TestRaccCommand#test_executable_parser [/Users/headius/projects/racc/test/test_racc_command.rb:57]:
Expected false to be truthy.

In many installs of JRuby, including the default tarball you can download from https://jruby.org, the jruby command is actually implemented using a bash script. Due to stupidity in the design of shebangs on most *nix systems, this means that the jruby script cannot be used directly in the shebang line of a Ruby script, because bash will attempt to execute both the jruby command and the target script with bash.

This is the reason that RubyGems with binscripts are usually installed using so-called "env shebangs" on JRuby, like so:

#!/usr/bin/env jruby

It is possible to install the jruby-launcher gem which will install a native jruby binary that works with the non-env shebang. This may be an option to get the test to pass, but it may be better to use an env shebang when generating the parser script.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with test/test_racc_command.rb, especially Racc::TestRaccCommand#test_executable_parser, and reproduce the failure on JRuby. Trace how shebang-mode parser scripts are generated and compare the non-env and env shebang behavior; done means the executable parser test passes on the affected JRuby configurations.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, ruby
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.