ruby / ruby/rubygems

Bundler creates a gemspec with an exe directory defined, even when it shouldn't

Open
#4,884 3 comments 0 reactions 1 assignee View on GitHub

@hsbt is already working on this.

Since Oct 28, 2025.

Bundler
Dominant language
Ruby
Stars
4k
Forks
1.9k
Avg merge
1d 2h
Merged PRs (30d)
81

Description

Describe the problem as clearly as you can

When creating a new gem with the bundler gem command, the created gemspec always contains spec.bindir = "exe" even if the --no-exe flag is passed, or if the --bin flag is passed. In the former case, I'd expect lines related to "exe" to be omitted or commented out. In the latter base, I'd expect the gemspec lines to use "bin" rather than "exe".

Post steps to reproduce the problem
$ bundle gem gemspec-test \
    --no-coc \
    --no-exe \
    --no-mit \
    --test=none \
    --ci=none

$ fgrep exe gemspec-test/*gemspec
  spec.bindir        = "exe"
  spec.executables   = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }

Please note that"bin/console and bin/setup are still created because the global ~/.bundle/config contains:

BUNDLE_CONSOLE: "irb"

Therefore:

# Ruby pipe just redacts the $HOME directory. Otherwise, this is the actual output.
$ bundle config console | ruby -pe 'gsub ENV["HOME"], "$HOME"'
Settings for `console` in order of priority. The top value will be used
Set for the current user ($HOME/.bundle/config): "irb"
Ruby, Rubygems, and Bundler Settings
  • How your ruby is setup (OS package, from source, using a version manager).
    • from source, using a package manager (see versions below)

    • How bundler & rubygems are configured.

      • Global ~/.bundle/config

        ---
        BUNDLE_ALLOW_OFFLINE_INSTALL: "true"
        BUNDLE_AUTO_INSTALL: "true"
        BUNDLE_CACHE_ALL: "true"
        BUNDLE_CLEAN: "true"
        BUNDLE_CONSOLE: "irb"
        BUNDLE_DEFAULT_INSTALL_USES_PATH: "true"
        BUNDLE_DISABLE_SHARED_GEMS: "false"
        BUNDLE_GEM__TEST: "rspec"
        BUNDLE_GEM__CI: "github"
        BUNDLE_GEM__COC: "true"
        BUNDLE_GEM__CHANGELOG: "true"
        BUNDLE_GEM__RUBOCOP: "true"
        
      • Global ~/.gemrc

        ---
        :backtrace: false
        :bulk_threshold: 1000
        :sources:
        - https://rubygems.org
        :update_sources: true
        :verbose: true
        :concurrent_downloads: 4
        gem: >-
            --both
        install: >-
            --env-shebang
            --suggestions
            --wrappers
        update: >-
            --conservative
            --env-shebang
            --minimal-deps
            --patch
            --suggestions
            --wrappers
        
    • The version of each involved piece of software that you are using.

      • Ruby: 3.0.2
        • Rubygems: 3.2.22
        • Bundler: 2.2.26
      • macOS 11.5.2
        • Ruby build and management
          • chruby: 0.3.9
          • ruby-install: 0.8.2
        • Tested with all of the following shells:
          • OS-provided shells
            • /bin/sh: Bash 3.2.57(1)-release (x86_64-apple-darwin20)
            • /bin/zsh: zsh 5.8 (x86_64-apple-darwin20.0)
          • Homebrew-provided shells
            • Bash 5.1.8(1)-release
            • Fish Shell 3.3.1
Which command did you run?
bundle gem gemspec-test \
    --no-coc \
    --no-exe \
    --no-mit \
    --test=none \
    --ci=none
What were you expecting to happen?

The file generated at gemspec-test/gemspec-test.gemspec not to contain exe as the spec.bindir, or to look for executables in a non-existent exe directory. It still creates gemspec-test/bin , likely due to the Bundler console settings, but the gemspec should then either omit the exe lines, or use the bin directory that's generated instead.

Mostly, I expected not to see this in the newly-generated gemspec:

spec.bindir        = "exe"
spec.executables   = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
What actually happened?

See above. The generated gemspec still defines spec.bindir = "exe" and looks for executable files there.

If not included with the output of your command, run bundle env and paste the output below

Environment

Bundler             2.2.26
  Platforms         ruby, x86_64-darwin-20
Ruby                3.0.2p107 (2021-07-07 revision 0db68f023372b634603c74fca94588b457be084c) [x86_64-darwin20]
  Full Path         $HOME/.rubies/ruby-3.0.2/bin/ruby
  Config Dir        $HOME/.rubies/ruby-3.0.2/etc
RubyGems            3.2.22
  Gem Home          $HOME/.gem/ruby/3.0.2
  Gem Path          $HOME/.gem/ruby/3.0.2:$HOME/.rubies/ruby-3.0.2/lib/ruby/gems/3.0.0
  User Home         $HOME
  User Path         $HOME/.gem/ruby/3.0.0
  Bin Dir           $HOME/.gem/ruby/3.0.2/bin
Tools               
  Git               2.33.0
  RVM               not installed
  rbenv             not installed
  chruby            0.3.9
  rubygems-bundler  (1.4.5)

Bundler Build Metadata

Built At          2021-08-17
Git SHA           21fd333002
Released Version  true

Bundler settings

allow_offline_install
  Set for the current user ($HOME/.bundle/config): true
auto_install
  Set for the current user ($HOME/.bundle/config): true
cache_all
  Set for the current user ($HOME/.bundle/config): true
clean
  Set for the current user ($HOME/.bundle/config): true
console
  Set for the current user ($HOME/.bundle/config): "irb"
default_install_uses_path
  Set for the current user ($HOME/.bundle/config): true
disable_shared_gems
  Set for the current user ($HOME/.bundle/config): false
gem.changelog
  Set for the current user ($HOME/.bundle/config): true
gem.ci
  Set for the current user ($HOME/.bundle/config): "github"
gem.coc
  Set for the current user ($HOME/.bundle/config): true
gem.rubocop
  Set for the current user ($HOME/.bundle/config): "true"
gem.test
  Set for the current user ($HOME/.bundle/config): "rspec"

Contributor guide

Open the contributing guide

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.