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

bin/dev fails to install Foreman in specific circumstances #65

Merged
merged 1 commit into from
Jan 14, 2022

Conversation

davidstosik
Copy link
Contributor

So this might be an unexpected edge case, but I would expect it to become more common as time passes and people using jsbundling-rails update to new versions of Ruby.

Here's the scenario:

  • Start in a pristine environment.
  • Install rbenv to manage Ruby versions.
  • Start a project with, let's say Ruby 2.7.5:
     rbenv install 2.7.5
     rbenv local 2.7.5
     gem install rails
     rails new testapp -j esbuild
     cd testapp
  • Start the dev environment once, using bin/dev. It will install Foreman "globally". (actually, it looks like rails new should have, but it installed again when I ran bin/dev)
  • We now have a shim for foreman in ~/.rbenv/shims/foreman (which is going to cause problems, because bin/dev relies on the command not existing)
  • Now let's update to Ruby 3.0.3:
    rbenv install 3.0.3
    rbenv local 3.0.3
    sed -i '' -e 's/ruby "2.7.5"/ruby "3.0.3"/' Gemfile
    bundle update --ruby
  • All packages from the Gemfile get installed again. Unfortunately foreman is not in the Gemfile.
  • The foreman command is in my path:
    command -v foreman
    #=> /Users/david-stosik/.rbenv/shims/foreman
  • Unfortunately, foreman is not installed. Running bin/dev, or foreman, raises the following error:
    rbenv: foreman: command not found
    
    The `foreman' command exists in these Ruby versions:
      2.7.5
  • Instead of command -v foreman, it looks like relying on gem is a better bet:
    gem list --silent --installed --exact rails
    echo $?
    #=> 0
    gem list --silent --installed --exact foreman
    echo $?
    #=> 1

As the script relies on gem anyway to install Foreman, using it to check if Foreman is installed beforehands does not seem like a big deal?

@dhh dhh merged commit 7f5a45d into rails:main Jan 14, 2022
@davidstosik davidstosik deleted the foreman-install-shim branch January 16, 2022 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants